feat: 网元参数配置数据支持版本区分功能,,适应mme版本配置

This commit is contained in:
TsMask
2025-10-17 11:06:27 +08:00
parent c325b89f6f
commit 7f7f4e2581
19 changed files with 924 additions and 351 deletions

File diff suppressed because one or more lines are too long

View File

@@ -8,6 +8,8 @@ CREATE TABLE "ne_info" (
"ne_id" text(32) NOT NULL, "ne_id" text(32) NOT NULL,
"rm_uid" text(40), "rm_uid" text(40),
"ne_name" text(64), "ne_name" text(64),
"ne_version" text(12),
"schema" text(12),
"ip" text(128), "ip" text(128),
"port" integer(11), "port" integer(11),
"pv_flag" text(32), "pv_flag" text(32),
@@ -37,4 +39,4 @@ ON "ne_info" (
-- ---------------------------- -- ----------------------------
-- Records of ne_info -- Records of ne_info
-- ---------------------------- -- ----------------------------
INSERT INTO "ne_info" VALUES (1, 'OMC', '001', '4400HXOMC001', 'OMC_001', '127.0.0.1', 33030, 'PNF', 'AreaNet', '-', '-', '-', '1,2', 0, '', 'system', 1713928436971, '', 0); INSERT INTO "ne_info" VALUES (1, 'OMC', '001', '4400HXOMC001', 'OMC_001', "2", 'http', '127.0.0.1', 33030, 'PNF', 'AreaNet', '-', '-', '-', '1,2', 0, '', 'system', 1713928436971, '', 0);

View File

@@ -0,0 +1,46 @@
-- ----------------------------
-- Table structure for ne_info
-- ----------------------------
DROP TABLE IF EXISTS "ne_info";
CREATE TABLE "ne_info" (
"id" integer NOT NULL,
"ne_type" text(32) NOT NULL,
"ne_id" text(32) NOT NULL,
"rm_uid" text(40),
"ne_name" text(64),
"ne_version" text(12),
"schema" text(12),
"ip" text(128),
"port" integer(11),
"pv_flag" text(32),
"province" text(32),
"vendor_name" text(64),
"dn" text(255),
"ne_address" text(64),
"host_ids" text(64),
"status" integer(11),
"remark" text(255),
"create_by" text(50),
"create_time" integer(20),
"update_by" text(50),
"update_time" integer(20),
PRIMARY KEY ("id")
);
-- ----------------------------
-- Indexes structure for table ne_info
-- ----------------------------
CREATE UNIQUE INDEX "ux_netype_neid"
ON "ne_info" (
"ne_type" ASC,
"ne_id" ASC
);
-- ADD COLUMN
ALTER TABLE "ne_info" ADD COLUMN "ne_version" text(12);
ALTER TABLE "ne_info" ADD COLUMN "schema" text(12);
-- ----------------------------
-- Records of ne_info
-- ----------------------------
UPDATE "ne_info" SET "ne_version" = '2', "schema" = 'http' WHERE "ne_version" IS NULL OR "schema" IS NULL;

File diff suppressed because one or more lines are too long

View File

@@ -11,6 +11,8 @@ CREATE TABLE `ne_info` (
`ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '网元ID', `ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '网元ID',
`rm_uid` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '网元资源唯一标识', `rm_uid` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '网元资源唯一标识',
`ne_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '网元名称', `ne_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '网元名称',
`ne_version` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '2' COMMENT '网元版本',
`schema` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'http' COMMENT '网元模式 http/https',
`ip` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '网元服务IP', `ip` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '网元服务IP',
`port` int DEFAULT '0' COMMENT '端口', `port` int DEFAULT '0' COMMENT '端口',
`pv_flag` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'PNF' COMMENT '网元虚拟化标识 物理PNF 虚拟VNF', `pv_flag` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'PNF' COMMENT '网元虚拟化标识 物理PNF 虚拟VNF',
@@ -30,7 +32,7 @@ CREATE TABLE `ne_info` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='网元_基础信息表 关联对应版本、授权、主机'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='网元_基础信息表 关联对应版本、授权、主机';
-- 初始网元数据 -- 初始网元数据
INSERT INTO `ne_info` VALUES (1, 'OMC', '001', '4400HXOMC001', 'OMC_001', '127.0.0.1', 33030, 'PNF', 'AreaNet', '-', '-', '-', '1,2', 0, '', 'system', 1713928436971, '', 0); INSERT INTO `ne_info` VALUES (1, 'OMC', '001', '4400HXOMC001', 'OMC_001', "2", 'http', '127.0.0.1', 33030, 'PNF', 'AreaNet', '-', '-', '-', '1,2', 0, '', 'system', 1713928436971, '', 0);
SET FOREIGN_KEY_CHECKS=1; SET FOREIGN_KEY_CHECKS=1;

View File

@@ -10,6 +10,8 @@ CREATE TABLE IF NOT EXISTS `ne_info` (
`ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '网元ID', `ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '网元ID',
`rm_uid` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '网元资源唯一标识', `rm_uid` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '网元资源唯一标识',
`ne_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '网元名称', `ne_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '网元名称',
`ne_version` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '2' COMMENT '网元版本',
`schema` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'http' COMMENT '网元模式 http/https',
`ip` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '网元服务IP', `ip` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '网元服务IP',
`port` int DEFAULT '0' COMMENT '端口', `port` int DEFAULT '0' COMMENT '端口',
`pv_flag` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'PNF' COMMENT '网元虚拟化标识 物理PNF 虚拟VNF', `pv_flag` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'PNF' COMMENT '网元虚拟化标识 物理PNF 虚拟VNF',
@@ -43,13 +45,15 @@ ALTER TABLE `ne_info` MODIFY COLUMN `vendor_name` varchar(64) CHARACTER SET utf8
ALTER TABLE `ne_info` MODIFY COLUMN `dn` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '-' COMMENT '网络标识' AFTER `vendor_name`; ALTER TABLE `ne_info` MODIFY COLUMN `dn` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '-' COMMENT '网络标识' AFTER `vendor_name`;
ALTER TABLE `ne_info` MODIFY COLUMN `host_ids` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '网元主机ID组 数据格式(ssh,telnet) UDM(ssh,telnet,redis) UPF(ssh,telnet,telnet)' AFTER `ne_address`; ALTER TABLE `ne_info` MODIFY COLUMN `host_ids` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '网元主机ID组 数据格式(ssh,telnet) UDM(ssh,telnet,redis) UPF(ssh,telnet,telnet)' AFTER `ne_address`;
ALTER TABLE `ne_info` MODIFY COLUMN `status` int(11) NULL DEFAULT 0 COMMENT '网元状态 0离线 1在线 2配置待下发 3备用模式' AFTER `host_ids`; ALTER TABLE `ne_info` MODIFY COLUMN `status` int(11) NULL DEFAULT 0 COMMENT '网元状态 0离线 1在线 2配置待下发 3备用模式' AFTER `host_ids`;
ALTER TABLE `ne_info` ADD COLUMN `ne_version` varchar(32) NULL DEFAULT '2' COMMENT '网元版本' AFTER `ne_name`;
ALTER TABLE `ne_info` ADD COLUMN `schema` varchar(12) NULL DEFAULT 'http' COMMENT '网元模式 http/https' AFTER `ne_version`;
ALTER TABLE `ne_info` COMMENT = '网元_基础信息表 关联对应版本、授权、主机'; ALTER TABLE `ne_info` COMMENT = '网元_基础信息表 关联对应版本、授权、主机';
ALTER TABLE `ne_info` MODIFY COLUMN `id` bigint(20) NOT NULL AUTO_INCREMENT; ALTER TABLE `ne_info` MODIFY COLUMN `id` bigint(20) NOT NULL AUTO_INCREMENT;
-- ---------------------------- -- ----------------------------
-- Data for ne_info -- Data for ne_info
-- ---------------------------- -- ----------------------------
INSERT IGNORE INTO `ne_info` VALUES (1, 'OMC', '001', '4400HXOMC001', 'OMC_001', '127.0.0.1', 33030, 'PNF', 'AreaNet', '-', '-', '-', '1,2', 0, '', 'system', 1713928436971, '', 0); UPDATE `ne_info` SET `ne_version` = '2', `schema` = 'http' WHERE `ne_version` IS NULL OR `schema` IS NULL;
SET FOREIGN_KEY_CHECKS=1; SET FOREIGN_KEY_CHECKS=1;

View File

@@ -0,0 +1,423 @@
mme:
system:
display: "System Config"
sort: 1
list:
- name: "mmeName"
type: "string"
value: "MME1"
filter: "0~32"
display: "MME Name"
- name: "networkName.full"
type: "string"
value: "EPC"
filter: "0~64"
display: "Full Network Name"
- name: "networkName.short"
type: "string"
value: "Next"
filter: "0~16"
display: "Short Network Name"
- name: "s1.mtu"
type: "int"
value: "1500"
access: "read-write"
filter: "576~9000"
display: "MTU"
comment: "Maximum Transmission Unit"
- name: "s1.address"
type: "string"
value: "192.168.8.220"
access: "read-write"
filter: "IP"
display: "S1 Local Address"
comment: "Local IP for S1 interface"
- name: "s6a.local.address"
type: "string"
value: "172.16.5.220"
access: "read-write"
filter: "IP"
display: "Local S6a IP"
comment: "Local IP for Diameter S6a"
- name: "s6a.local.host"
type: "string"
value: "mme.epc.mnc001.mcc001.3gppnetwork.org"
access: "read-write"
filter: "0~128"
display: "Local Hostname"
comment: "MME Diameter Host FQDN"
- name: "s6a.local.realm"
type: "string"
value: "epc.mnc001.mcc001.3gppnetwork.org"
access: "read-write"
filter: "0~128"
display: "Local Realm"
comment: "Diameter Realm"
- name: "s11.local.address"
type: "string"
value: "172.16.5.220"
access: "read-write"
filter: "IP"
display: "Local S11 IP"
- name: "n26.local.address"
type: "string"
value: "172.16.5.210"
access: "read-write"
filter: "IP"
display: "Local N26 IP"
- name: "t3402.value"
type: "string"
value: "12m"
filter: "1s~60m"
display: "T3402 Timer"
- name: "t3412.value"
type: "string"
value: "54m"
display: "T3412 Timer"
- name: "t3423.value"
type: "string"
value: "12m"
display: "T3423 Timer"
- name: "message.gtp.t3ResponseDuration"
type: "string"
value: "2s"
display: "GTP Response Timeout"
- name: "message.gtp.n3ResponseRcount"
type: "int"
value: "3"
display: "GTP Response Retries"
- name: "message.gtp.t3HoldingDuration"
type: "string"
value: "6s"
display: "GTP Holding Duration"
- name: "message.gtp.n3HoldingRcount"
type: "int"
value: "1"
display: "GTP Holding Retries"
- name: "message.s6a"
type: "string"
value: "3s"
display: "S6a Timeout"
- name: "handover.value"
type: "string"
value: "300ms"
display: "Handover Timeout"
- name: "s1Flex.instance"
type: "int"
value: "0"
access: "read-write"
filter: "0~2"
display: "mme instance id for s1 flex"
comment: "mme instance id for s1 flex"
- name: "redisDb.enable"
type: "bool"
value: "false"
access: "read-write"
filter: '{"0":"false","1":"true"}'
display: "Enable Redis"
comment: "true|false"
- name: "redisDb.netType"
type: "string"
value: "tcp"
access: "read-write"
filter: '{"tcp":"tcp"}'
display: "Network Type"
comment: "Network type for Redis (tcp)"
- name: "redisDb.addr"
type: "string"
value: "172.16.5.140:6379"
access: "read-write"
filter: "IP:Port"
display: "Redis Master Address"
comment: "IP:Port format"
- name: "redisDb.slaveAddrList"
type: "string"
value: "172.16.5.148:6379"
access: "read-write"
filter: "IP:Port"
display: "Redis Slave Addresses"
comment: "List of Redis slaves for replication"
- name: "redisDb.poolSize"
type: "int"
value: "10"
access: "read-write"
filter: "1~1000"
display: "Connection Pool Size"
comment: "Max Redis connection pool size"
- name: "relativeCapacity"
type: "int"
value: "255"
filter: "0~255"
display: "MME Relative Capacity"
comment: "Used for load balancing among MMEs"
- name: "logDir"
type: "string"
value: "/var/log/"
access: "read-write"
filter: "0~128"
display: "Log Directory"
comment: "Directory where log files will be stored"
- name: "logNum"
type: "int"
value: "10"
access: "read-write"
filter: "1~100"
display: "Log File Count"
comment: "Maximum number of log files to retain"
- name: "logSize"
type: "int"
value: "200"
access: "read-write"
filter: "1~10000"
display: "Log File Size (MB)"
comment: "Max size per log file"
- name: "logLevel"
type: "enum"
value: "debug"
access: "read-write"
filter: '{"debug":"debug","info":"info","warn":"warn","error":"error"}'
display: "Log Level"
comment: "debug|info|warn|error"
gummei:
display: "GUMMEI List"
sort: 3
array:
- name: "index"
type: "int"
value: "0"
access: "read"
filter: "0~15"
display: "Index"
comment: "0~15"
- name: "plmnId"
type: "regex"
value: "00101"
filter: "^[0-9]{5,6}$"
display: "PLMN ID"
- name: "mmeGid"
type: "int"
value: "2"
filter: "0~65535"
display: "MME Group ID"
- name: "mmeCode"
type: "int"
value: "1"
filter: "0~255"
display: "MME Code"
servedTai:
display: "TAI List"
sort: 4
array:
- name: "index"
type: "int"
value: "0"
access: "read"
filter: "0~15"
display: "Index"
comment: "0~15"
- name: "plmnId"
type: "regex"
value: "00101"
filter: "^[0-9]{5,6}$"
display: "PLMN ID"
- name: "tac"
type: "int"
value: "1"
filter: "0~65535"
display: "TAC"
s6a:
display: "HSS List"
sort: 5
array:
- name: "index"
type: "int"
value: "0"
access: "read"
filter: "0~15"
display: "Index"
comment: "0~15"
- name: "address"
type: "string"
value: "172.16.5.221"
filter: "IP"
display: "HSS Address"
- name: "priority"
type: "int"
value: "1"
filter: "1~10"
display: "Priority"
- name: "plmnList"
type: "array"
display: "PLMN IDs"
array:
- name: "index"
type: "int"
value: "0"
access: "read"
filter: "0~15"
display: "Index"
comment: "0~15"
- name: "plmnId"
type: "string"
value: ["00101"]
filter: "^[0-9]{5,6}$"
display: "PLMN ID"
s11:
display: "SGW List"
sort: 9
array:
- name: "index"
type: "int"
value: "0"
access: "read"
filter: "0~15"
display: "Index"
comment: "0~15"
- name: "address"
type: "string"
value: "172.16.5.222"
filter: "IP"
display: "SGW Address"
- name: "priority"
type: "int"
value: "1"
filter: "1~10"
display: "Priority"
- name: "tai"
type: "array"
display: "Tracking Areas"
array:
- name: "index"
type: "int"
value: "0"
access: "read"
filter: "0~15"
display: "Index"
comment: "0~15"
- name: "plmnId"
type: "string"
value: "00101"
filter: "^[0-9]{5,6}$"
display: "PLMN ID"
- name: "tac"
type: "int"
value: "1"
filter: "0~65535"
display: "TAC"
s5s8:
display: "PGW List"
sort: 11
array:
- name: "index"
type: "int"
value: "0"
access: "read"
filter: "0~15"
display: "Index"
comment: "0~15"
- name: "address"
type: "string"
value: "172.16.5.223"
filter: "IP"
display: "PGW Address"
- name: "priority"
type: "int"
value: "1"
filter: "1~10"
display: "Priority"
- name: "servedApn"
type: "array"
display: "Served APNs"
array:
- name: "index"
type: "int"
value: "0"
access: "read"
filter: "0~15"
display: "Index"
comment: "0~15"
- name: "plmnId"
type: "string"
value: "00101"
filter: "^[0-9]{5,6}$"
display: "PLMN ID"
- name: "apn"
type: "string"
value: "internet"
filter: "0~128"
display: "APN"
n26:
display: "AMF List"
sort: 13
array:
- name: "index"
type: "int"
value: "0"
access: "read"
filter: "0~15"
display: "Index"
comment: "0~15"
- name: "address"
type: "string"
value: "172.16.5.224"
filter: "IP"
display: "AMF Address"
- name: "priority"
type: "int"
value: "1"
filter: "1~10"
display: "Priority"
- name: "tai"
type: "array"
display: "Tracking Areas"
array:
- name: "index"
type: "int"
value: "0"
access: "read"
filter: "0~15"
display: "Index"
comment: "0~15"
- name: "plmnId"
type: "string"
value: "00101"
filter: "^[0-9]{5,6}$"
display: "PLMN ID"
- name: "tac"
type: "int"
value: "1"
filter: "0~65535"
display: "TAC"
enbList:
display: "Enb List Config"
sort: 19
visible: "hide"
array:
- name: "index"
type: "int"
value: "0"
access: "read-only"
filter: "0~128"
display: "Index"
comment: "0~128"
- name: "name"
type: "string"
value: ""
access: "read-write"
filter: "0~64"
display: "ENB Name"
comment: "text content length 0~64"
- name: "address"
type: "string"
value: ""
access: "read-write"
filter: "0~64"
display: "ENB Address"
comment: "text content length 0~64"
- name: "position"
type: "string"
value: ""
access: "read-write"
filter: "0~64"
display: "Position"
comment: "location description. Prohibition of spaces, length of text content 0-64"

View File

@@ -611,6 +611,13 @@ smf:
filter: "" filter: ""
display: "Local IP" display: "Local IP"
comment: "" comment: ""
- name: "ntfyEnable"
type: "bool"
value: "false"
access: "read-write"
filter: ""
display: "DHCP Server Ntfy Enable"
comment: ""
dnnselectdhcpserver: dnnselectdhcpserver:
display: "DNN Select DHCP Server" display: "DNN Select DHCP Server"
sort: 23 sort: 23
@@ -644,7 +651,7 @@ smf:
display: "DHCP Server IP" display: "DHCP Server IP"
comment: "e.g. 192.168.1.1" comment: "e.g. 192.168.1.1"
offlineChargingConfig: offlineChargingConfig:
display: "Offline Charging Config" display: "Charging Config"
sort: 25 sort: 25
list: list:
- name: "cdrFileName" - name: "cdrFileName"
@@ -682,12 +689,19 @@ smf:
filter: "0~9999" filter: "0~9999"
display: "CDR File Max Age" display: "CDR File Max Age"
comment: "Days" comment: "Days"
- name: "onlineCdrEnable"
type: "bool"
value: "false"
access: "read-write"
filter: ""
display: "Online Charging CDR Enable"
comment: ""
- name: "freeSubsCdrEnable" - name: "freeSubsCdrEnable"
type: "bool" type: "bool"
value: "false" value: "false"
access: "read-write" access: "read-write"
filter: "" filter: ""
display: "Free Subscribers CDR Enable" display: "Offline Charging CDR Enable"
comment: "" comment: ""
- name: "timeThreshold" - name: "timeThreshold"
type: "int" type: "int"

View File

@@ -164,18 +164,28 @@ func (s NeConfigController) Remove(c *gin.Context) {
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Param neType path string true "NE Type" Enums(IMS,AMF,AUSF,UDM,SMF,PCF,NSSF,NRF,UPF,MME,CBC,OMC,SGWC,SMSC) // @Param neType path string true "NE Type" Enums(IMS,AMF,AUSF,UDM,SMF,PCF,NSSF,NRF,UPF,MME,CBC,OMC,SGWC,SMSC)
// @Param neId query string true "NE ID" default(001)
// @Success 200 {object} object "Response Results" // @Success 200 {object} object "Response Results"
// @Security TokenAuth // @Security TokenAuth
// @Summary Network Element Parameter Configuration Available Attribute Values List Specify Network Element Type All Unpaged // @Summary Network Element Parameter Configuration Available Attribute Values List Specify Network Element Type All Unpaged
// @Description Network Element Parameter Configuration Available Attribute Values List Specify Network Element Type All Unpaged // @Description Network Element Parameter Configuration Available Attribute Values List Specify Network Element Type All Unpaged
// @Router /ne/config/list/{neType} [get] // @Router /ne/config/list/{neType} [get]
func (s NeConfigController) ListByNeType(c *gin.Context) { func (s NeConfigController) ListByNeType(c *gin.Context) {
language := reqctx.AcceptLanguage(c)
neId := c.DefaultQuery("neId", "001")
neType := c.Param("neType") neType := c.Param("neType")
if neType == "" { if neType == "" {
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neType is empty")) c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neType is empty"))
return return
} }
data := s.neConfigService.FindByNeType(neType)
neInfo := s.neInfoService.FindByNeTypeAndNeID(neType, neId)
if neInfo.NeId != neId || neInfo.IP == "" {
c.JSON(200, resp.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
return
}
data := s.neConfigService.FindByNeType(neInfo.NeType, neInfo.NeVersion)
c.JSON(200, resp.OkData(data)) c.JSON(200, resp.OkData(data))
} }
@@ -313,8 +323,14 @@ func (s NeConfigController) DataAdd(c *gin.Context) {
return return
} }
neInfo := s.neInfoService.FindByNeTypeAndNeID(body.NeType, body.NeId)
if neInfo.NeId != body.NeId || neInfo.IP == "" {
c.JSON(200, resp.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
return
}
// 检查是否array // 检查是否array
info := s.neConfigService.FindByNeTypeAndParamName(body.NeType, body.ParamName) info := s.neConfigService.FindByNeTypeAndParamName(body.NeType, neInfo.NeVersion, body.ParamName)
if info.ParamType != "array" { if info.ParamType != "array" {
c.JSON(200, resp.ErrMsg("this attribute does not support adding")) c.JSON(200, resp.ErrMsg("this attribute does not support adding"))
return return
@@ -326,12 +342,6 @@ func (s NeConfigController) DataAdd(c *gin.Context) {
return return
} }
neInfo := s.neInfoService.FindByNeTypeAndNeID(body.NeType, body.NeId)
if neInfo.NeId != body.NeId || neInfo.IP == "" {
c.JSON(200, resp.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
return
}
// 网元直连 // 网元直连
resData, err := neFetchlink.NeConfigAdd(neInfo, body.ParamName, body.Loc, body.ParamData) resData, err := neFetchlink.NeConfigAdd(neInfo, body.ParamName, body.Loc, body.ParamData)
if err != nil { if err != nil {
@@ -371,19 +381,19 @@ func (s NeConfigController) DataRemove(c *gin.Context) {
return return
} }
// 检查是否array
info := s.neConfigService.FindByNeTypeAndParamName(query.NeType, query.ParamName)
if info.ParamType != "array" {
c.JSON(200, resp.ErrMsg("this attribute does not support adding"))
return
}
neInfo := s.neInfoService.FindByNeTypeAndNeID(query.NeType, query.NeId) neInfo := s.neInfoService.FindByNeTypeAndNeID(query.NeType, query.NeId)
if neInfo.NeId != query.NeId || neInfo.IP == "" { if neInfo.NeId != query.NeId || neInfo.IP == "" {
c.JSON(200, resp.ErrMsg(i18n.TKey(language, "app.common.noNEInfo"))) c.JSON(200, resp.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
return return
} }
// 检查是否array
info := s.neConfigService.FindByNeTypeAndParamName(query.NeType, neInfo.NeVersion, query.ParamName)
if info.ParamType != "array" {
c.JSON(200, resp.ErrMsg("this attribute does not support adding"))
return
}
// 网元直连 // 网元直连
resData, err := neFetchlink.NeConfigDelete(neInfo, query.ParamName, query.Loc) resData, err := neFetchlink.NeConfigDelete(neInfo, query.ParamName, query.Loc)
if err != nil { if err != nil {

View File

@@ -395,6 +395,7 @@ func (s NeInfoController) Add(c *gin.Context) {
// 已有网元可获取的信息 // 已有网元可获取的信息
if body.ServerState != nil { if body.ServerState != nil {
if v, ok := body.ServerState["version"]; ok && v != nil { if v, ok := body.ServerState["version"]; ok && v != nil {
body.NeVersion = fmt.Sprint(v)
neVersion.Version = fmt.Sprint(v) neVersion.Version = fmt.Sprint(v)
} }
if v, ok := body.ServerState["sn"]; ok && v != nil { if v, ok := body.ServerState["sn"]; ok && v != nil {
@@ -497,6 +498,7 @@ func (s NeInfoController) Edit(c *gin.Context) {
// 已有网元可获取的信息 // 已有网元可获取的信息
if body.ServerState != nil { if body.ServerState != nil {
if v, ok := body.ServerState["version"]; ok && v != nil { if v, ok := body.ServerState["version"]; ok && v != nil {
body.NeVersion = fmt.Sprint(v)
neVersion.Version = fmt.Sprint(v) neVersion.Version = fmt.Sprint(v)
neVersion.UpdateBy = loginUserName neVersion.UpdateBy = loginUserName
} }

View File

@@ -3,7 +3,9 @@ package model
// NeConfig 网元_参数配置可用属性值 // NeConfig 网元_参数配置可用属性值
type NeConfig struct { type NeConfig struct {
ID int64 `json:"id" gorm:"column:id;primaryKey;autoIncrement"` ID int64 `json:"id" gorm:"column:id;primaryKey;autoIncrement"`
UpdateTime int64 `json:"updateTime" gorm:"column:update_time"` // 更新时间
NeType string `json:"neType" binding:"required" gorm:"column:ne_type"` // 网元类型 NeType string `json:"neType" binding:"required" gorm:"column:ne_type"` // 网元类型
NeVersion string `json:"neVersion" gorm:"column:ne_version"` // 网元版本 前缀匹配
ParamName string `json:"paramName" binding:"required" gorm:"column:param_name"` // 参数名 ParamName string `json:"paramName" binding:"required" gorm:"column:param_name"` // 参数名
ParamDisplay string `json:"paramDisplay" binding:"required" gorm:"column:param_display"` // 参数显示名 ParamDisplay string `json:"paramDisplay" binding:"required" gorm:"column:param_display"` // 参数显示名
ParamType string `json:"paramType" gorm:"column:param_type"` // 参数类型 list列表单层 array数组多层 ParamType string `json:"paramType" gorm:"column:param_type"` // 参数类型 list列表单层 array数组多层
@@ -11,7 +13,6 @@ type NeConfig struct {
ParamSort int64 `json:"paramSort" gorm:"column:param_sort"` // 参数排序 ParamSort int64 `json:"paramSort" gorm:"column:param_sort"` // 参数排序
ParamPerms string `json:"paramPerms" gorm:"column:param_perms"` // 操作权限 get只读 put可编辑 delete可删除 post可新增 ParamPerms string `json:"paramPerms" gorm:"column:param_perms"` // 操作权限 get只读 put可编辑 delete可删除 post可新增
Visible string `json:"visible" gorm:"column:visible"` // 可见性 默认public 单独网元self Visible string `json:"visible" gorm:"column:visible"` // 可见性 默认public 单独网元self
UpdateTime int64 `json:"updateTime" gorm:"column:update_time"` // 更新时间
// ====== 非数据库字段属性 ====== // ====== 非数据库字段属性 ======

View File

@@ -3,10 +3,17 @@ package model
// NeInfo 网元信息对象 ne_info // NeInfo 网元信息对象 ne_info
type NeInfo struct { type NeInfo struct {
ID int64 `json:"id" gorm:"column:id;primaryKey;autoIncrement"` ID int64 `json:"id" gorm:"column:id;primaryKey;autoIncrement"`
CreateBy string `json:"createBy" gorm:"column:create_by"` // 创建者
CreateTime int64 `json:"createTime" gorm:"column:create_time"` // 创建时间
UpdateBy string `json:"updateBy" gorm:"column:update_by"` // 更新者
UpdateTime int64 `json:"updateTime" gorm:"column:update_time"` // 更新时间
Remark string `json:"remark" gorm:"column:remark"` // 备注
NeType string `json:"neType" gorm:"column:ne_type" binding:"required"` // 网元类型 NeType string `json:"neType" gorm:"column:ne_type" binding:"required"` // 网元类型
NeId string `json:"neId" gorm:"column:ne_id" binding:"required"` // 网元ID NeId string `json:"neId" gorm:"column:ne_id" binding:"required"` // 网元ID
RmUID string `json:"rmUid" gorm:"column:rm_uid"` // 网元资源唯一标识
NeName string `json:"neName" gorm:"column:ne_name"` // 网元名称 NeName string `json:"neName" gorm:"column:ne_name"` // 网元名称
NeVersion string `json:"neVersion" gorm:"column:ne_version"` // 网元版本
RmUID string `json:"rmUid" gorm:"column:rm_uid"` // 网元资源唯一标识
Schema string `json:"schema" gorm:"column:schema"` // 网元模式 http/https
IP string `json:"ip" gorm:"column:ip" binding:"required"` // 网元服务IP IP string `json:"ip" gorm:"column:ip" binding:"required"` // 网元服务IP
Port int64 `json:"port" gorm:"column:port" binding:"required,number,max=65535,min=1"` // 端口 Port int64 `json:"port" gorm:"column:port" binding:"required,number,max=65535,min=1"` // 端口
PvFlag string `json:"pvFlag" gorm:"column:pv_flag" binding:"omitempty,oneof=PNF VNF"` // 网元虚拟化标识 物理PNF 虚拟VNF PvFlag string `json:"pvFlag" gorm:"column:pv_flag" binding:"omitempty,oneof=PNF VNF"` // 网元虚拟化标识 物理PNF 虚拟VNF
@@ -16,11 +23,6 @@ type NeInfo struct {
NeAddress string `json:"neAddress" gorm:"column:ne_address"` // MAC地址 NeAddress string `json:"neAddress" gorm:"column:ne_address"` // MAC地址
HostIDs string `json:"hostIds" gorm:"column:host_ids"` // 网元主机ID组 数据格式(ssh,telnet) UDM(ssh,telnet,redis) UPF(ssh,telnet,telnet) HostIDs string `json:"hostIds" gorm:"column:host_ids"` // 网元主机ID组 数据格式(ssh,telnet) UDM(ssh,telnet,redis) UPF(ssh,telnet,telnet)
Status int64 `json:"status" gorm:"column:status"` // 网元状态 0离线 1在线 2配置待下发 3备用模式 Status int64 `json:"status" gorm:"column:status"` // 网元状态 0离线 1在线 2配置待下发 3备用模式
Remark string `json:"remark" gorm:"column:remark"` // 备注
CreateBy string `json:"createBy" gorm:"column:create_by"` // 创建者
CreateTime int64 `json:"createTime" gorm:"column:create_time"` // 创建时间
UpdateBy string `json:"updateBy" gorm:"column:update_by"` // 更新者
UpdateTime int64 `json:"updateTime" gorm:"column:update_time"` // 更新时间
// ====== 非数据库字段属性 ====== // ====== 非数据库字段属性 ======

View File

@@ -41,23 +41,39 @@ func TestConfig(t *testing.T) {
if configParamFile == "*" { if configParamFile == "*" {
for _, v := range fileNameList { for _, v := range fileNameList {
params := parseData(filepath.Join(configParamDir, v)) filePath := filepath.Join(configParamDir, v)
version := parseVersion(filePath)
params := parseData(filePath)
if params == nil { if params == nil {
return return
} }
saveData(params) saveData(version, params)
} }
} else { } else {
params := parseData(filepath.Join(configParamDir, configParamFile)) filePath := filepath.Join(configParamDir, configParamFile)
version := parseVersion(filePath)
params := parseData(filePath)
if params == nil { if params == nil {
return return
} }
saveData(params) saveData(version, params)
} }
} }
// ========= Main ============= // ========= Main =============
// 根据文件名获取版本号 mme_2_param_config.yaml -> 2
func parseVersion(filePaht string) string {
version := "2"
splits := strings.Split(filepath.Base(filePaht), "_")
if len(splits) > 0 {
if splits[2] == "param" {
version = splits[1]
}
}
return version
}
// parseData 文件转map数据 // parseData 文件转map数据
func parseData(filePaht string) []map[string]string { func parseData(filePaht string) []map[string]string {
data, err := parseStrToMap(filePaht) data, err := parseStrToMap(filePaht)
@@ -74,7 +90,7 @@ func parseData(filePaht string) []map[string]string {
} }
// saveData 保存数据 // saveData 保存数据
func saveData(params []map[string]string) { func saveData(version string, params []map[string]string) {
// 定义排序函数 // 定义排序函数
sort.Slice(params, func(i, j int) bool { sort.Slice(params, func(i, j int) bool {
paramSortI := params[i]["paramSort"] paramSortI := params[i]["paramSort"]
@@ -109,6 +125,7 @@ func saveData(params []map[string]string) {
} }
neConfig := model.NeConfig{ neConfig := model.NeConfig{
NeVersion: version,
NeType: v["neType"], NeType: v["neType"],
ParamName: v["paramName"], ParamName: v["paramName"],
ParamDisplay: v["paramDisplay"], ParamDisplay: v["paramDisplay"],
@@ -157,7 +174,7 @@ func saveDB(s model.NeConfig) int64 {
db := connDB() db := connDB()
// 检查是否存在 // 检查是否存在
var id int64 var id int64
db.Raw("SELECT id FROM ne_config WHERE ne_type = ? AND param_name = ?", s.NeType, s.ParamName).Scan(&id) db.Raw("SELECT id FROM ne_config WHERE ne_type = ? AND ne_version = ? AND param_name = ?", s.NeType, s.NeVersion, s.ParamName).Scan(&id)
// 更新时间 // 更新时间
s.UpdateTime = time.Now().UnixMilli() s.UpdateTime = time.Now().UnixMilli()
if id > 0 { if id > 0 {

View File

@@ -239,3 +239,23 @@ func (r NeInfo) UpdateState(id int64, status int64) int64 {
} }
return tx.RowsAffected return tx.RowsAffected
} }
// UpdateVersion 修改网元版本
func (r NeInfo) UpdateVersion(id int64, neVersion string) int64 {
if id <= 0 {
return 0
}
tx := db.DB("").Model(&model.NeInfo{})
// 构建查询条件
tx = tx.Where("id = ?", id)
tx.Updates(map[string]any{
"ne_version": neVersion,
"update_time": time.Now().UnixMilli(),
})
// 执行更新
if err := tx.Error; err != nil {
logger.Errorf("update err => %v", err.Error())
return 0
}
return tx.RowsAffected
}

View File

@@ -21,59 +21,39 @@ type NeConfig struct {
neConfigRepository *repository.NeConfig // 网元参数配置可用属性值表 neConfigRepository *repository.NeConfig // 网元参数配置可用属性值表
} }
// RefreshByNeType 通过ne_type刷新redis中的缓存 // RefreshByNeType 通过ne_type刷新redis中的缓存 并返回分组数据
func (r *NeConfig) RefreshByNeTypeAndNeID(neType string) []model.NeConfig { func (r *NeConfig) RefreshByNeTypeAndNeID(neType string) map[string][]model.NeConfig {
// 多个 neConfig := model.NeConfig{}
if neType == "" || neType == "*" { if neType != "*" {
neConfigList := r.neConfigRepository.Select(model.NeConfig{}) neConfig.NeType = neType
if len(neConfigList) > 0 {
neConfigGroup := map[string][]model.NeConfig{}
for _, v := range neConfigList {
if item, ok := neConfigGroup[v.NeType]; ok {
neConfigGroup[v.NeType] = append(item, v)
} else {
neConfigGroup[v.NeType] = []model.NeConfig{v}
}
}
for k, v := range neConfigGroup {
key := fmt.Sprintf("%s:NeConfig:%s", constants.CACHE_NE_DATA, strings.ToUpper(k))
redis.Del("", key)
if len(v) > 0 {
for i, item := range v {
if err := json.Unmarshal([]byte(item.ParamJson), &item.ParamData); err != nil {
continue
}
v[i] = item
}
values, _ := json.Marshal(v)
redis.Set("", key, string(values), 0)
}
}
}
return neConfigList
} }
// 单个 neConfigList := r.neConfigRepository.Select(neConfig)
key := fmt.Sprintf("%s:NeConfig:%s", constants.CACHE_NE_DATA, strings.ToUpper(neType)) neConfigGroup := map[string][]model.NeConfig{}
redis.Del("", key) for _, v := range neConfigList {
neConfigList := r.neConfigRepository.Select(model.NeConfig{ if err := json.Unmarshal([]byte(v.ParamJson), &v.ParamData); err != nil {
NeType: neType, continue
}) }
if len(neConfigList) > 0 { neTypeVerKey := fmt.Sprintf("%s:%s", strings.ToUpper(v.NeType), v.NeVersion)
for i, v := range neConfigList { if item, ok := neConfigGroup[neTypeVerKey]; ok {
if err := json.Unmarshal([]byte(v.ParamJson), &v.ParamData); err != nil { neConfigGroup[neTypeVerKey] = append(item, v)
continue } else {
} neConfigGroup[neTypeVerKey] = []model.NeConfig{v}
neConfigList[i] = v
} }
values, _ := json.Marshal(neConfigList)
redis.Set("", key, string(values), 0)
} }
return neConfigList for k, v := range neConfigGroup {
key := fmt.Sprintf("%s:NeConfig:%s", constants.CACHE_NE_DATA, k)
redis.Del("", key)
if len(v) > 0 {
values, _ := json.Marshal(v)
redis.Set("", key, string(values), 0)
}
}
return neConfigGroup
} }
// ClearNeCacheByNeType 清除网元类型参数配置缓存 // ClearNeCacheByNeType 清除网元类型参数配置缓存
func (r *NeConfig) ClearNeCacheByNeType(neType string) bool { func (r *NeConfig) ClearNeCacheByNeType(neType string) bool {
key := fmt.Sprintf("%s:NeConfig:%s", constants.CACHE_NE_DATA, neType) key := fmt.Sprintf("%s:NeConfig:%s:*", constants.CACHE_NE_DATA, neType)
if neType == "*" { if neType == "*" {
key = fmt.Sprintf("%s:NeConfig:*", constants.CACHE_NE_DATA) key = fmt.Sprintf("%s:NeConfig:*", constants.CACHE_NE_DATA)
} }
@@ -85,27 +65,41 @@ func (r *NeConfig) ClearNeCacheByNeType(neType string) bool {
} }
// FindByNeType 查询网元类型参数配置 // FindByNeType 查询网元类型参数配置
func (r *NeConfig) FindByNeType(neType string) []model.NeConfig { func (r *NeConfig) FindByNeType(neType, neVersion string) []model.NeConfig {
var neConfigList []model.NeConfig data := make([]model.NeConfig, 0)
key := fmt.Sprintf("%s:NeConfig:%s", constants.CACHE_NE_DATA, strings.ToUpper(neType)) keys, _ := redis.GetKeys("", fmt.Sprintf("%s:NeConfig:%s:*", constants.CACHE_NE_DATA, strings.ToUpper(neType)))
jsonStr, _ := redis.Get("", key) if len(keys) > 0 {
if len(jsonStr) > 7 { for _, key := range keys {
err := json.Unmarshal([]byte(jsonStr), &neConfigList) neTypeVer := strings.Split(key, ":")
if err != nil { if len(neTypeVer) != 4 {
neConfigList = []model.NeConfig{} continue
}
if strings.HasPrefix(neVersion, neTypeVer[3]) {
if jsonStr, _ := redis.Get("", key); len(jsonStr) > 7 {
json.Unmarshal([]byte(jsonStr), &data)
}
return data
}
} }
} else {
neConfigList = r.RefreshByNeTypeAndNeID(neType)
} }
return neConfigList // 从数据库刷新缓存
neConfigGroup := r.RefreshByNeTypeAndNeID(neType)
for k, v := range neConfigGroup {
neTypeVer := strings.Split(k, ":")
if len(neTypeVer) == 2 && strings.HasPrefix(neVersion, neTypeVer[1]) {
data = v
break
}
}
return data
} }
// FindByNeTypeAndParamName 查询网元类型参数配置By参数名 // FindByNeTypeAndParamName 查询网元类型参数配置By参数名
func (r *NeConfig) FindByNeTypeAndParamName(neType, paramName string) model.NeConfig { func (r *NeConfig) FindByNeTypeAndParamName(neType, neVersion, paramName string) model.NeConfig {
neConfigList := r.FindByNeType(neType) neConfigList := r.FindByNeType(neType, neVersion)
var neConfig model.NeConfig var neConfig model.NeConfig
for _, v := range neConfigList { for _, v := range neConfigList {
if v.ParamName == paramName { if strings.HasPrefix(neVersion, v.NeVersion) && v.ParamName == paramName {
neConfig = v neConfig = v
break break
} }

View File

@@ -37,7 +37,7 @@ func (r NeConfig) GetOMCYaml(paramName string) []map[string]any {
// ModifyOMCYaml 修改OMC网元配置文件 // ModifyOMCYaml 修改OMC网元配置文件
func (r NeConfig) ModifyOMCYaml(paramName, loc string, paramData any) error { func (r NeConfig) ModifyOMCYaml(paramName, loc string, paramData any) error {
neConfig := r.FindByNeTypeAndParamName("OMC", paramName) neConfig := r.FindByNeTypeAndParamName("OMC", config.Version, paramName)
if neConfig.ParamType == "list" { if neConfig.ParamType == "list" {
if paramName == "notificationEmail" { if paramName == "notificationEmail" {
notificationEmailData := config.Get("notification.email").(map[string]any) notificationEmailData := config.Get("notification.email").(map[string]any)

View File

@@ -7,7 +7,6 @@ import (
"path/filepath" "path/filepath"
"runtime" "runtime"
"strings" "strings"
"time"
"be.ems/src/framework/constants" "be.ems/src/framework/constants"
"be.ems/src/framework/database/redis" "be.ems/src/framework/database/redis"
@@ -187,7 +186,6 @@ func (r NeInfo) bandNeStatus(arr *[]model.NeInfo) {
if v.Status != 0 { if v.Status != 0 {
v.Status = 0 v.Status = 0
(*arr)[i].Status = v.Status (*arr)[i].Status = v.Status
(*arr)[i].UpdateTime = time.Now().UnixMilli()
r.neInfoRepository.UpdateState(v.ID, v.Status) r.neInfoRepository.UpdateState(v.ID, v.Status)
} }
continue continue
@@ -205,8 +203,14 @@ func (r NeInfo) bandNeStatus(arr *[]model.NeInfo) {
} }
(*arr)[i].Status = status (*arr)[i].Status = status
if v.Status != status { if v.Status != status {
(*arr)[i].UpdateTime = time.Now().UnixMilli()
r.neInfoRepository.UpdateState(v.ID, status) r.neInfoRepository.UpdateState(v.ID, status)
r.RefreshByNeTypeAndNeID(v.NeType, v.NeId)
}
// 网元版本设置为当前版本
version, ok := result["version"].(string)
if ok && version != v.NeVersion {
r.neInfoRepository.UpdateVersion(v.ID, version)
r.RefreshByNeTypeAndNeID(v.NeType, v.NeId)
} }
} }
} }

View File

@@ -64,12 +64,12 @@ func (r NeVersion) checkNeVersion(arr *[]model.NeVersion) {
continue continue
} }
if v, ok := result["version"]; ok && v != nil { if v, ok := result["version"]; ok && v != nil {
ver := v.(string) ver := fmt.Sprint(v)
if ver == item.Version { if ver == item.Version {
continue continue
} }
item.Name = "-" // item.Name = "-"
item.Path = "-" // item.Path = "-"
item.Version = ver item.Version = ver
} }
if item.NeType != neInfo.NeType || item.NeId != neInfo.NeId { if item.NeType != neInfo.NeType || item.NeId != neInfo.NeId {