Merge branch 'main' into multi-tenant

This commit is contained in:
2024-07-16 09:51:12 +08:00
12 changed files with 78 additions and 80 deletions

View File

@@ -1,5 +1,13 @@
# 版本发布日志
## 2.2407.2-20240712
- 修复 网元版本安装MME写入host文件ip错误
- 修复 支持kvdb依赖包安装默认带的adb改为kvdb
- 修复 网元版本安装命令终止符判断#$
- 更新 CNType0表示禁止接入NA
- 修复 文件复制到本地时创建文件目录避免路径错误
## 2.2407.1-20240704
- 修复 网元版本安装MME修改S6A地址为MME_IP

View File

@@ -1,7 +1,7 @@
# Makefile for rest agent project
PROJECT = OMC
VERSION = 2.2407.1
VERSION = 2.2407.2
PLATFORM = amd64
ARMPLATFORM = aarch64
BUILDDIR = ../../build

View File

@@ -311,6 +311,27 @@ upf:
filter: ''
display: "RX TX Queue Num"
comment: ""
- name: "useSocket"
type: "int"
value: "0"
access: "read-write"
filter: '0~1'
display: "Use Socket"
comment: "data rx&tx use C socket"
- name: "enableTap"
type: "int"
value: "0"
access: "read-write"
filter: '0~1'
display: "Enable Tap"
comment: "Enable 5G ethernet LAN"
- name: "enableQer"
type: "int"
value: "0"
access: "read-write"
filter: '0~1'
display: "Enable Qer"
comment: "Enable PFCP Qer Control"
dataForwarderUpfd:
display: "Data Forwarder Upfd"
list:

View File

@@ -1,7 +1,7 @@
# Makefile for OMC-OMC-crontask project
PROJECT = OMC
VERSION = 2.2407.1
VERSION = 2.2407.2
LIBDIR = be.ems/lib
BINNAME = crontask

View File

@@ -43,7 +43,7 @@ INSERT INTO `mml_command` VALUES (1594, 'OMC', 'neManagement', 'Network Element
INSERT INTO `mml_command` VALUES (1595, 'OMC', 'neManagement', 'Network Element Management', 'add', 'neinfo', 'Add Network Element', '[{\"alias\":\"ne_type\",\"apostr\":\"false\",\"comment\":\"\",\"display\":\"NE type\",\"filter\":\"\",\"loc\":\"false\",\"name\":\"netype\",\"optional\":\"false\",\"type\":\"string\"},{\"alias\":\"ne_id\",\"apostr\":\"false\",\"comment\":\"\",\"display\":\"NE ID\",\"filter\":\"\",\"loc\":\"false\",\"name\":\"neid\",\"optional\":\"false\",\"type\":\"string\"},{\"alias\":\"rm_uid\",\"apostr\":\"false\",\"comment\":\"\",\"display\":\"Resource management UID\",\"filter\":\"\",\"loc\":\"false\",\"name\":\"rmuid\",\"optional\":\"false\",\"type\":\"string\"},{\"alias\":\"ip\",\"apostr\":\"false\",\"comment\":\"\",\"display\":\"IP address\",\"filter\":\"\",\"loc\":\"false\",\"name\":\"ip\",\"optional\":\"false\",\"type\":\"string\"},{\"alias\":\"port\",\"apostr\":\"false\",\"comment\":\"\",\"display\":\"Port\",\"filter\":\"\",\"loc\":\"false\",\"name\":\"port\",\"optional\":\"false\",\"type\":\"string\"},{\"alias\":\"ne_name\",\"apostr\":\"false\",\"comment\":\"\",\"display\":\"NE name\",\"filter\":\"\",\"loc\":\"false\",\"name\":\"nename\",\"optional\":\"false\",\"type\":\"string\"},{\"alias\":\"pv_flag\",\"apostr\":\"false\",\"comment\":\"\",\"display\":\"PV flag\",\"filter\":\"\",\"loc\":\"false\",\"name\":\"pvflag\",\"optional\":\"false\",\"type\":\"string\"}]', 'Active');
INSERT INTO `mml_command` VALUES (1596, 'OMC', 'neManagement', 'Network Element Management', 'mod', 'neinfo', 'Modify Network Element', '[{\"alias\":\"ne_type\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"NE type\",\"filter\":\"\",\"loc\":\"true\",\"name\":\"netype\",\"optional\":\"false\",\"type\":\"string\"},{\"alias\":\"ne_id\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"NE ID\",\"filter\":\"\",\"loc\":\"true\",\"name\":\"neid\",\"optional\":\"false\",\"type\":\"string\"},{\"alias\":\"rm_uid\",\"apostr\":\"false\",\"comment\":\"\",\"display\":\"Resource management UID\",\"filter\":\"\",\"loc\":\"false\",\"name\":\"rmuid\",\"optional\":\"true\",\"type\":\"string\"},{\"alias\":\"ip\",\"apostr\":\"false\",\"comment\":\"\",\"display\":\"IP address\",\"filter\":\"\",\"loc\":\"false\",\"name\":\"ip\",\"optional\":\"true\",\"type\":\"string\"},{\"alias\":\"port\",\"apostr\":\"false\",\"comment\":\"\",\"display\":\"Port\",\"filter\":\"\",\"loc\":\"false\",\"name\":\"port\",\"optional\":\"true\",\"type\":\"string\"},{\"alias\":\"ne_name\",\"apostr\":\"false\",\"comment\":\"\",\"display\":\"NE name\",\"filter\":\"\",\"loc\":\"false\",\"name\":\"nename\",\"optional\":\"true\",\"type\":\"string\"},{\"alias\":\"pv_flag\",\"apostr\":\"false\",\"comment\":\"\",\"display\":\"PV flag\",\"filter\":\"\",\"loc\":\"false\",\"name\":\"pvflag\",\"optional\":\"true\",\"type\":\"string\"}]', 'Active');
INSERT INTO `mml_command` VALUES (1597, 'OMC', 'neManagement', 'Network Element Management', 'del', 'neinfo', 'Delete Network Element', '[{\"alias\":\"ne_type\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"NE type\",\"filter\":\"\",\"name\":\"netype\",\"optional\":\"false\",\"type\":\"string\"},{\"alias\":\"ne_id\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"NE ID\",\"filter\":\"\",\"name\":\"neid\",\"optional\":\"false\",\"type\":\"string\"}]', 'Active');
INSERT INTO `mml_command` VALUES (1598, 'OMC', 'neConfigManagement', 'NE Config Parameter Management', 'dsp', 'neconfig', 'Display NE Config Parameter', '[{\"alias\":\"ne_type\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"NE type\",\"filter\":\"\",\"loc\":\"true\",\"name\":\"netype\",\"optional\":\"true\",\"type\":\"string\"},{\"alias\":\"ne_id\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"NE ID\",\"filter\":\"\",\"loc\":\"true\",\"name\":\"neid\",\"optional\":\"true\",\"type\":\"string\"},{\"alias\":\"top_tag\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"Parameter tag\",\"filter\":\"\",\"loc\":\"true\",\"name\":\"tag\",\"optional\":\"true\",\"type\":\"string\"}]', 'Active');
INSERT INTO `mml_command` VALUES (1598, 'OMC', 'neConfigManagement', 'NE Config Parameter Management', 'dsp', 'neconfig', 'Display NE Config Parameter', '[{\"alias\":\"ne_type\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"NE type\",\"filter\":\"\",\"loc\":\"true\",\"name\":\"netype\",\"optional\":\"true\",\"type\":\"string\"},{\"alias\":\"ne_id\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"NE ID\",\"filter\":\"\",\"loc\":\"true\",\"name\":\"neid\",\"optional\":\"true\",\"type\":\"string\"},{\"alias\":\"top_tag\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"Parameter tag\",\"filter\":\"\",\"loc\":\"true\",\"name\":\"tag\",\"optional\":\"true\",\"type\":\"string\"}]', 'Inactive');
INSERT INTO `mml_command` VALUES (1599, 'OMC', 'faultManagement', 'Fault Management', 'dsp', 'alarm', 'Display Alarm Information', '[{\"alias\":\"ne_type\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"NE type\",\"filter\":\"\",\"loc\":\"true\",\"name\":\"netype\",\"optional\":\"true\",\"type\":\"string\"},{\"alias\":\"ne_id\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"NE UID\",\"filter\":\"\",\"loc\":\"true\",\"name\":\"neid\",\"optional\":\"true\",\"type\":\"string\"},{\"alias\":\"ne_name\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"NE name\",\"filter\":\"\",\"name\":\"nename\",\"optional\":\"true\",\"type\":\"string\"},{\"alias\":\"alarm_code\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"Alarm code\",\"filter\":\"\",\"name\":\"alarmcode\",\"optional\":\"true\",\"type\":\"int\"},{\"alias\":\"orig_severity\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"Original severity\",\"filter\":\"{\\\"Critical\\\":\\\"Critical\\\",\\\"Major\\\":\\\"Major\\\",\\\"Minor\\\":\\\"Minor\\\",\\\"Warning\\\":\\\"Warning\\\",\\\"Event\\\":\\\"Event\\\"}\",\"name\":\"origseverity\",\"optional\":\"true\",\"type\":\"enum\"},{\"alias\":\"pv_flag\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"PV flag\",\"filter\":\"\",\"name\":\"pvflag\",\"optional\":\"true\",\"type\":\"string\"},{\"alias\":\"event_time\\u003e\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"Alarm event start time\",\"filter\":\"\",\"name\":\"starttime\",\"optional\":\"true\",\"type\":\"string\"},{\"alias\":\"event_time\\u003c\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"Alarm event end time\",\"filter\":\"\",\"name\":\"endtime\",\"optional\":\"true\",\"type\":\"string\"},{\"alias\":\"alarm_type\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"Alarm type\",\"filter\":\"{\\\"CommunicationAlarm\\\":\\\"CommunicationAlarm\\\",\\\"EquipmentAlarm\\\":\\\"EquipmentAlarm\\\",\\\"ProcessingFailure\\\":\\\"ProcessingFailure\\\",\\\"EnvironmentalAlarm\\\":\\\"EnvironmentalAlarm\\\",\\\"QualityOfServiceAlarm\\\":\\\"QualityOfServiceAlarm\\\"}\",\"name\":\"alarmtype\",\"optional\":\"true\",\"type\":\"enum\"},{\"alias\":\"alarm_status\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"Alarm status\",\"filter\":\"\",\"name\":\"alarmstatus\",\"optional\":\"true\",\"type\":\"int\"}]', 'Active');
INSERT INTO `mml_command` VALUES (1600, 'OMC', 'systemCommand', 'Linux System Command', 'run', 'shell', 'Run Shell Command', '[{\"alias\":\"cmd\",\"apostr\":\"true\",\"comment\":\"\",\"display\":\"Shell command\",\"filter\":\"\",\"loc\":\"false\",\"name\":\"cmd\",\"optional\":\"false\",\"type\":\"string\"}]', 'Inactive');
INSERT INTO `mml_command` VALUES (1601, 'OMC', 'licenseManagement', 'License Management', 'dsp', 'licenseinfo', 'Display NE License Information', '[{\"alias\":\"neType\",\"apostr\":\"false\",\"comment\":\"\",\"display\":\"NE type\",\"filter\":\"\",\"name\":\"netype\",\"optional\":\"true\",\"type\":\"string\"},{\"alias\":\"neId\",\"comment\":\"\",\"display\":\"NE ID\",\"filter\":\"\",\"name\":\"neid\",\"optional\":\"true\",\"type\":\"string\"}]', 'Inactive');

File diff suppressed because one or more lines are too long

View File

@@ -21,17 +21,9 @@ rest:
- ipv4: 0.0.0.0
ipv6:
port: 33040
- ipv4: 0.0.0.0
ipv6:
port: 34443
scheme: https
clientAuthType: 0
caFile: ./etc/certs/omc-ca.crt
certFile: ./etc/certs/omc-server.crt
keyFile: ./etc/certs/omc-server.key
webServer:
enabled: true
enabled: false
rootDir: d:/local.git/fe.ems.vue3/dist
listen:
- addr: :80
@@ -59,13 +51,13 @@ redis:
# OMC系统使用库
default:
port: 6379 # Redis port
host: "127.0.0.1" # Redis host
password: "helloearth"
host: "192.168.8.58" # Redis host
password: "redis@1234"
db: 10 # Redis db_num
# UDM网元用户库
udmuser:
port: 6379 # Redis port
host: "127.0.0.1"
port: 36379 # Redis port
host: "192.168.8.58"
password: "helloearth"
db: 0 # Redis db_num
# 多个数据源时可以用这个指定默认的数据源
@@ -78,7 +70,7 @@ mml:
port2: 5002
sleep: 200
deadLine: 10
sizeRow: 100
sizeRow: 600
sizeCol: 128
bufferSize: 65535
user: admin
@@ -87,7 +79,7 @@ mml:
# NE config
ne:
user: root
user: omcuser
etcdir: /usr/local/etc
bindir: /usr/local/bin
omcdir: /usr/local/omc
@@ -116,12 +108,12 @@ omc:
checksign: false
rootDir: ./
binDir: ./bin
backup: ./backup
upload: ./upload
frontUpload: d:/local.git/fe.ems/upload
frontTraceDir: d:/local.git/fe.ems/trace
software: ./software
license: ./license
backup: C:/usr/local/omc/backup
upload: C:/usr/local/omc/upload
frontUpload: C:/usr/local/omc/upload
frontTraceDir: C:/usr/local/omc/trace
software: C:/usr/local/omc/software
license: C:/usr/local/omc/license
gtpUri: gtp:192.168.2.219:2152
checkContentType: false
testMode: false
@@ -134,7 +126,7 @@ omc:
# email/sms
# smProxy: sms(Short Message Service)/smsc(SMS Centre)
alarm:
forwardAlarm: true
forwardAlarm: false
email:
smtp: mail.agrandtech.com
port: 25
@@ -189,12 +181,12 @@ testConfig:
file: ./etc/testconfig.yaml
# 静态文件配置, 相对项目根路径或填绝对路径
staticFile:
# 默认资源dir目录需要预先创建
default:
prefix: "/static"
dir: "./static"
# 文件上传资源目录映射,与项目目录同级
upload:
prefix: "/upload"
dir: "./upload"
# staticFile:
# # 默认资源dir目录需要预先创建
# default:
# prefix: "/static"
# dir: "./static"
# # 文件上传资源目录映射,与项目目录同级
# upload:
# prefix: "/upload"
# dir: "./upload"

View File

@@ -16,13 +16,9 @@ import (
// data = append(data, []string{"1", "2", "3"})
// err := file.WriterCSVFile(data, filePath)
func WriterFileCSV(data [][]string, filePath string) error {
// 获取文件所在的目录路径
dirPath := filepath.Dir(filePath)
// 确保文件夹路径存在
err := os.MkdirAll(dirPath, 0775)
if err != nil {
logger.Errorf("MkdirAll dir %v", err)
// 创建本地输出目录
if err := os.MkdirAll(filepath.Dir(filePath), 0775); err != nil {
return err
}
// 创建或打开文件

View File

@@ -59,6 +59,11 @@ func CompressZipByFile(zipFilePath, filePath string) error {
// CompressZipByDir 将目录下文件添加到 ZIP 压缩文件
func CompressZipByDir(zipFilePath, dirPath string) error {
// 创建本地输出目录
if err := os.MkdirAll(filepath.Dir(zipFilePath), 0775); err != nil {
return err
}
// 创建输出文件
zipWriter, err := os.Create(zipFilePath)
if err != nil {

View File

@@ -160,7 +160,7 @@ func Reset() error {
// return fmt.Errorf("not support window")
} else {
// 重置数据库
if _, err := cmd.Execf("sudo /usr/local/omc/bin/setomc.sh -m install"); err != nil {
if _, err := cmd.Execf("/usr/local/omc/bin/setomc.sh -m install"); err != nil {
return err
}
// 重启服务

View File

@@ -39,8 +39,8 @@ func (s *SSHClientSFTP) CopyDirRemoteToLocal(remoteDir, localDir string) error {
// 遍历远程文件和子目录并复制到本地
for _, remoteFile := range remoteFiles {
remotePath := filepath.Join(remoteDir, remoteFile.Name())
localPath := filepath.Join(localDir, remoteFile.Name())
remotePath := filepath.ToSlash(filepath.Join(remoteDir, remoteFile.Name()))
localPath := filepath.ToSlash(filepath.Join(localDir, remoteFile.Name()))
if remoteFile.IsDir() {
// 如果是子目录,则递归复制子目录
@@ -51,25 +51,10 @@ func (s *SSHClientSFTP) CopyDirRemoteToLocal(remoteDir, localDir string) error {
}
} else {
// 如果是文件,则复制文件内容
remoteFile, err := s.Client.Open(remotePath)
if err != nil {
if err := s.CopyFileRemoteToLocal(remotePath, localPath); err != nil {
logger.Errorf("CopyDirRemoteToLocal failed to opening remote file %s: => %s", remotePath, err.Error())
continue
}
defer remoteFile.Close()
localFile, err := os.Create(localPath)
if err != nil {
logger.Errorf("CopyDirRemoteToLocal failed to creating local file %s: => %s", localPath, err.Error())
continue
}
defer localFile.Close()
_, err = io.Copy(localFile, remoteFile)
if err != nil {
logger.Errorf("CopyDirRemoteToLocal failed to copying file contents from %s to %s: => %s", remotePath, localPath, err.Error())
continue
}
}
}
return nil
@@ -134,6 +119,10 @@ func (s *SSHClientSFTP) CopyDirLocalToRemote(localDir, remoteDir string) error {
// CopyDirRemoteToLocal 复制文件-远程到本地
func (s *SSHClientSFTP) CopyFileRemoteToLocal(remotePath, localPath string) error {
if err := os.MkdirAll(filepath.Dir(localPath), 0775); err != nil {
return err
}
// 打开远程文件
remoteFile, err := s.Client.Open(remotePath)
if err != nil {
@@ -142,21 +131,6 @@ func (s *SSHClientSFTP) CopyFileRemoteToLocal(remotePath, localPath string) erro
}
defer remoteFile.Close()
if err := os.MkdirAll(filepath.Dir(localPath), 0775); err != nil {
return err
}
// 如果目标文件已经存在,先将目标文件重命名
// if info, err := os.Stat(localPath); err == nil && !info.IsDir() {
// ext := filepath.Ext(localPath)
// name := localPath[0 : len(localPath)-len(ext)]
// newName := fmt.Sprintf("%s-%s%s", name, time.Now().Format("20060102_150405"), ext)
// err := os.Rename(localPath, newName)
// if err != nil {
// return err
// }
// }
// 创建本地文件
localFile, err := os.Create(localPath)
if err != nil {

View File

@@ -202,15 +202,15 @@ func (r *NeVersionImpl) operateCommand(action, neType string, neFilePaths []stri
omcStrArr := []string{}
omcStrArr = append(omcStrArr, pkgCmdStr)
if action == "install" {
omcStrArr = append(omcStrArr, "sudo /usr/local/omc/bin/setomc.sh -m install") // 初始化数据库
omcStrArr = append(omcStrArr, "/usr/local/omc/bin/setomc.sh -m install") // 初始化数据库
} else {
omcStrArr = append(omcStrArr, "sudo /usr/local/omc/bin/setomc.sh -m upgrade") // 升级数据库
omcStrArr = append(omcStrArr, "/usr/local/omc/bin/setomc.sh -m upgrade") // 升级数据库
}
omcStrArr = append(omcStrArr, "sudo systemctl restart restagent") // 重启服务
omcStrArr = append(omcStrArr, fmt.Sprintf("sudo rm %s", strings.Join(neFilePaths, " "))) // 删除软件包
// 2s后安装
cmdStrArr = append(cmdStrArr, fmt.Sprintf("nohup sh -c \"sleep 2s && %s\" > /dev/null 2>&1 & \n", strings.Join(omcStrArr, " && ")))
cmdStrArr = append(cmdStrArr, fmt.Sprintf("nohup sh -c \"sleep 2s && %s\" > /tmp/omc_%s.out 2>&1 & \n", strings.Join(omcStrArr, " && "), action))
// 结束
cmdStrArr = append(cmdStrArr, fmt.Sprintf("echo '%s' \n", okFlagStr))
return okFlagStr, cmdStrArr, nil
@@ -558,7 +558,8 @@ func (r *NeVersionImpl) operateRun(sshClient *ssh.ConnSSH, preinput map[string]s
}
// 命令终止符后继续执行命令
if len(cmdStrArr) > 0 && strings.LastIndex(outputStr, "~$ ") > 2 {
suffix := strings.HasSuffix(outputStr, "~]# ") || strings.HasSuffix(outputStr, "~$ ")
if len(cmdStrArr) > 0 && suffix {
if firstRead {
firstRead = false
}