1
0

merge: 合并代码20241031

This commit is contained in:
TsMask
2024-10-31 16:40:52 +08:00
parent 17f57175c7
commit 07b78e1138
30 changed files with 986 additions and 1267 deletions

View File

@@ -1,7 +1,7 @@
# 项目信息
framework:
name: "OMC"
version: "2.2410.2"
version: "2.2410.3"
# 应用服务配置
server:

View File

@@ -0,0 +1,45 @@
package ne_data_udm
import (
"fmt"
"be.ems/src/framework/cron"
"be.ems/src/framework/logger"
neDataService "be.ems/src/modules/network_data/service"
neModel "be.ems/src/modules/network_element/model"
neService "be.ems/src/modules/network_element/service"
)
var NewProcessor = &NeDataUDM{
udmAuthService: neDataService.NewUDMAuthUser,
udmSubService: neDataService.NewUDMSubUser,
neInfoService: neService.NewNeInfo,
count: 0,
}
// NeDataUDM 网元配置文件定期备份
type NeDataUDM struct {
udmAuthService *neDataService.UDMAuthUser // UDM鉴权信息
udmSubService *neDataService.UDMSubUser // UDM签约信息
neInfoService *neService.NeInfo // 网元信息服务
count int // 执行次数
}
func (s *NeDataUDM) Execute(data any) (any, error) {
s.count++ // 执行次数加一
options := data.(cron.JobData)
sysJob := options.SysJob
logger.Infof("重复 %v 任务ID %s", options.Repeat, sysJob.JobID)
// 返回结果,用于记录执行结果
result := map[string]any{
"count": s.count,
}
neList := s.neInfoService.SelectList(neModel.NeInfo{NeType: "UDM"}, false, false)
for _, neInfo := range neList {
result[fmt.Sprintf("AuthNumber_%s", neInfo.NeId)] = s.udmAuthService.ResetData(neInfo.NeId)
result[fmt.Sprintf("SubNumber_%s", neInfo.NeId)] = s.udmSubService.ResetData(neInfo.NeId)
}
return result, nil
}

View File

@@ -10,6 +10,7 @@ import (
"be.ems/src/modules/crontask/processor/getStateFromNE"
processorMonitorSysResource "be.ems/src/modules/crontask/processor/monitor_sys_resource"
processorNeConfigBackup "be.ems/src/modules/crontask/processor/ne_config_backup"
processorNeDataUDM "be.ems/src/modules/crontask/processor/ne_data_udm"
"be.ems/src/modules/crontask/processor/removeFile"
)
@@ -19,6 +20,8 @@ func InitCronQueue() {
cron.CreateQueue("monitor_sys_resource", processorMonitorSysResource.NewProcessor)
// 网元-网元配置文件定期备份
cron.CreateQueue("ne_config_backup", processorNeConfigBackup.NewProcessor)
// 网元数据-UDM数据刷新同步
cron.CreateQueue("ne_data_udm", processorNeDataUDM.NewProcessor)
// delete expired NE backup file
cron.CreateQueue("delExpiredNeBackup", delExpiredNeBackup.NewProcessor)
cron.CreateQueue("deleteExpiredRecord", deleteExpiredRecord.NewProcessor)

View File

@@ -123,17 +123,30 @@ func (s *SMFController) CDRExport(c *gin.Context) {
headerCells := map[string]string{
"A1": "ID",
"B1": "Charging ID",
"C1": "Subscriber ID Data",
"D1": "Subscriber ID Type",
"E1": "Data Volume Uplink",
"F1": "Data Volume Downlink",
"G1": "Data Total Volume",
"H1": "Duration",
"I1": "Invocation Time",
"J1": "PDU Session Charging Information",
"C1": "NE Name",
"D1": "Resource Unique ID",
"E1": "Subscriber ID Data",
"F1": "Subscriber ID Type",
"G1": "Data Volume Uplink",
"H1": "Data Volume Downlink",
"I1": "Data Total Volume",
"J1": "Duration",
"K1": "Invocation Time",
"L1": "User Identifier",
"M1": "SSC Mode",
"N1": "DNN ID",
"O1": "PDU Type",
"P1": "RAT Type",
"Q1": "PDU IPv4 Address",
"R1": "Network Function IPv4",
"S1": "PDU IPv6 Address Swith Prefix",
"T1": "Record Network Function ID",
"U1": "Record Type",
"V1": "Record Opening Time",
}
// 从第二行开始的数据
dataCells := make([]map[string]any, 0)
for i, row := range rows {
idx := strconv.Itoa(i + 2)
// 解析 JSON 字符串为 map
@@ -158,12 +171,22 @@ func (s *SMFController) CDRExport(c *gin.Context) {
subscriptionIDData = sub["subscriptionIDData"].(string)
}
}
// 网络功能 IPv4 地址
networkFunctionIPv4Address := ""
if v, ok := cdrJSON["nFunctionConsumerInformation"]; ok && v != nil {
if conInfo, conInfoOk := v.(map[string]any); conInfoOk && conInfo != nil {
networkFunctionIPv4Address = conInfo["networkFunctionIPv4Address"].(string)
}
}
// 数据量上行链路
dataVolumeUplink := []string{}
// 数据量下行链路
dataVolumeDownlink := []string{}
// 数据总量
dataTotalVolume := []string{}
if v, ok := cdrJSON["listOfMultipleUnitUsage"]; ok && v != nil {
usageList := v.([]any)
if len(usageList) > 0 {
@@ -198,32 +221,31 @@ func (s *SMFController) CDRExport(c *gin.Context) {
invocationTimestamp = v.(string)
}
// 记录打开时间
pduSessionChargingInformation := ""
User_Identifier := ""
SSC_Mode := ""
RAT_Type := ""
DNN_ID := ""
PDU_Type := ""
PDU_IPv4 := ""
PDU_IPv6 := ""
if v, ok := cdrJSON["pDUSessionChargingInformation"]; ok && v != nil {
pduInfo := v.(map[string]any)
User_Identifier := ""
if v, ok := pduInfo["userIdentifier"]; ok && v != nil {
User_Identifier = v.(string)
}
SSC_Mode := ""
if v, ok := pduInfo["sSCMode"]; ok && v != nil {
SSC_Mode = v.(string)
}
RAT_Type := ""
if v, ok := pduInfo["rATType"]; ok && v != nil {
RAT_Type = v.(string)
}
DNN_ID := ""
if v, ok := pduInfo["dNNID"]; ok && v != nil {
DNN_ID = v.(string)
}
PDU_Type := ""
if v, ok := pduInfo["pDUType"]; ok && v != nil {
PDU_Type = v.(string)
}
PDU_IPv4 := ""
PDU_IPv6 := ""
if v, ok := pduInfo["pDUAddress"]; ok && v != nil {
pDUAddress := v.(map[string]any)
if addr, ok := pDUAddress["pDUIPv4Address"]; ok && addr != nil {
@@ -234,24 +256,54 @@ func (s *SMFController) CDRExport(c *gin.Context) {
}
}
pduSessionChargingInformation = fmt.Sprintf(`User Identifier: %s
SSC Mode: %s RAT Type: %s DNN ID: %s
PDU Type: %s
PDU IPv4 Address: %s
PDU IPv6 Addres Swith Prefix: %s`, User_Identifier, SSC_Mode, RAT_Type, DNN_ID, PDU_Type, PDU_IPv4, PDU_IPv6)
// pduSessionChargingInformation = fmt.Sprintf(`User Identifier: %s
// SSC Mode: %s RAT Type: %s DNN ID: %s
// PDU Type: %s
// PDU IPv4 Address: %s
// PDU IPv6 Addres Swith Prefix: %s`, User_Identifier, SSC_Mode, RAT_Type, DNN_ID, PDU_Type, PDU_IPv4, PDU_IPv6)
}
// 记录网络参数ID
recordNFID := ""
if v, ok := cdrJSON["recordingNetworkFunctionID"]; ok && v != nil {
recordNFID = v.(string)
}
//记录开始时间
recordOpeningTime := ""
if v, ok := cdrJSON["recordOpeningTime"]; ok && v != nil {
recordOpeningTime = v.(string)
}
//记录类型
recordType := ""
if v, ok := cdrJSON["recordType"]; ok && v != nil {
recordType = v.(string)
}
dataCells = append(dataCells, map[string]any{
"A" + idx: row.ID,
"B" + idx: chargingID,
"C" + idx: subscriptionIDData,
"D" + idx: subscriptionIDType,
"E" + idx: strings.Join(dataVolumeUplink, ","),
"F" + idx: strings.Join(dataVolumeDownlink, ","),
"G" + idx: strings.Join(dataTotalVolume, ","),
"H" + idx: duration,
"I" + idx: invocationTimestamp,
"J" + idx: pduSessionChargingInformation,
"C" + idx: row.NeName,
"D" + idx: row.RmUID,
"E" + idx: subscriptionIDData,
"F" + idx: subscriptionIDType,
"G" + idx: strings.Join(dataVolumeUplink, ","),
"H" + idx: strings.Join(dataVolumeDownlink, ","),
"I" + idx: strings.Join(dataTotalVolume, ","),
"J" + idx: duration,
"K" + idx: invocationTimestamp,
"L" + idx: User_Identifier,
"M" + idx: SSC_Mode,
"N" + idx: DNN_ID,
"O" + idx: PDU_Type,
"P" + idx: RAT_Type,
"Q" + idx: PDU_IPv4,
"R" + idx: networkFunctionIPv4Address,
"S" + idx: PDU_IPv6,
"T" + idx: recordNFID,
"U" + idx: recordType,
"V" + idx: recordOpeningTime,
})
}

View File

@@ -381,7 +381,7 @@ func (s *UDMAuthController) Export(c *gin.Context) {
// 文件名
fileName := fmt.Sprintf("udm_auth_user_export_%s_%d.%s", neId, time.Now().UnixMilli(), fileType)
filePath := fmt.Sprintf("%s/%s", file.ParseUploadFileDir(uploadsubpath.EXPORT), fileName)
filePath := filepath.Join(file.ParseUploadFileDir(uploadsubpath.EXPORT), fileName)
if fileType == "csv" {
// 转换数据

View File

@@ -22,7 +22,7 @@ import (
// 实例化控制层 UDMSubController 结构体
var NewUDMSub = &UDMSubController{
udmSubService: neDataService.NewUDMSub,
udmSubService: neDataService.NewUDMSubUser,
neInfoService: neService.NewNeInfo,
}
@@ -386,7 +386,7 @@ func (s *UDMSubController) Export(c *gin.Context) {
// 文件名
fileName := fmt.Sprintf("udm_sub_user_export_%s_%d.%s", neId, time.Now().UnixMilli(), fileType)
filePath := fmt.Sprintf("%s/%s", file.ParseUploadFileDir(uploadsubpath.EXPORT), fileName)
filePath := filepath.Join(file.ParseUploadFileDir(uploadsubpath.EXPORT), fileName)
if fileType == "csv" {
// 转换数据

View File

@@ -74,6 +74,13 @@ func (r *UDMAuthUser) SelectPage(query map[string]any) map[string]any {
conditions = append(conditions, "ne_id = ?")
params = append(params, v)
}
if v, ok := query["imsis"]; ok && v != "" {
placeholder := repo.KeyPlaceholderByQuery(len(v.([]any)))
conditions = append(conditions, fmt.Sprintf("imsi in (%s)", placeholder))
for _, v := range v.([]any) {
params = append(params, v.(string))
}
}
// 构建查询条件语句
whereSql := ""

View File

@@ -110,6 +110,13 @@ func (r *UDMSubUser) SelectPage(query map[string]any) map[string]any {
conditions = append(conditions, "ne_id = ?")
params = append(params, v)
}
if v, ok := query["imsis"]; ok && v != "" {
placeholder := repo.KeyPlaceholderByQuery(len(v.([]any)))
conditions = append(conditions, fmt.Sprintf("imsi in (%s)", placeholder))
for _, v := range v.([]any) {
params = append(params, v.(string))
}
}
// 构建查询条件语句
whereSql := ""

View File

@@ -12,7 +12,7 @@ import (
)
// 实例化服务层 UDMSubUser 结构体
var NewUDMSub = &UDMSubUser{
var NewUDMSubUser = &UDMSubUser{
udmSubRepository: repository.NewUDMSub,
udmUserInfoRepository: repository.NewUDMUserInfo,
}

View File

@@ -49,6 +49,8 @@ func NeState(neInfo model.NeInfo) (map[string]any, error) {
"capability": resData["capability"],
"sn": resData["serialNum"],
"expire": resData["expiryDate"],
"hostname": resData["hostName"],
"os": resData["osInfo"],
"cpu": resData["cpuUsage"],
"mem": resData["memUsage"],
"disk": resData["diskSpace"],

View File

@@ -21,15 +21,15 @@ import (
const (
// 数据库
DbHost = "127.0.0.1"
DbPort = 33066
DbHost = "192.168.9.58"
DbPort = 13306
DbUser = "root"
DbPassswd = "1000omc@kp!"
DbName = "omc_db"
// 配置文件路径
configParamDir = "../../../config/param"
// configParamFile = "*" // 目录下全部更新
configParamFile = "omc_param_config.yaml" // 单文件更新
configParamFile = "smf_param_config.yaml" // 单文件更新
)
func TestConfig(t *testing.T) {

View File

@@ -657,11 +657,40 @@ func (r *NeVersion) operateDome(action string, neVersion model.NeVersion) error
if neInfo.NeId != neVersion.NeId {
return fmt.Errorf("error found neinfo")
}
// ========= 网元OAM配置文件 start ==========
if err := NewNeInfo.NeConfOAMWirteSync(neInfo, nil, true); err != nil {
return fmt.Errorf("error wirte OAM file info")
}
// ========= 网元OAM配置文件 end ===========
// SMSC配置修改IMS和UDM 配置
if neInfo.NeType == "SMSC" {
para5GData := NewNeInfo.Para5GData
mnc_mcc := fmt.Sprintf("mnc%s.mcc%s", para5GData["MNC_DOMAIN"], para5GData["MCC"])
smscHost := fmt.Sprintf("%s smsc.ims.%s.3gppnetwork.org", para5GData["SMSC_IP"], mnc_mcc)
smscHostCMD := fmt.Sprintf("grep -qxF '%s' /etc/hosts || echo '%s' | sudo tee -a /etc/hosts \n", smscHost, smscHost)
smscIPCMD := fmt.Sprintf("grep -qxF '%s smsc' /etc/hosts || echo '%s smsc' | sudo tee -a /etc/hosts \n", para5GData["SMSC_IP"], para5GData["SMSC_IP"])
// IMS 配置
imsNEs := NewNeInfo.SelectList(model.NeInfo{NeType: "IMS"}, false, false)
for _, v := range imsNEs {
NewNeInfo.NeRunSSHCmd(v.NeType, v.NeId, smscIPCMD)
NewNeInfo.NeRunSSHCmd(v.NeType, v.NeId, smscHostCMD)
NewNeInfo.NeRunSSHCmd(v.NeType, v.NeId, "sudo sed -i '/^#!define WITH_SMS/ s/^/#/' /usr/local/etc/ims/vars.cfg")
NewNeInfo.NeRunSSHCmd(v.NeType, v.NeId, "ims-stop || true && ims-start")
}
// UDM 配置
smscASName := fmt.Sprintf("sudo sed -i '/- name: sms_as/{n;s|serverName: .*|serverName: sip:%s:5060|}' /usr/local/etc/udm/as.yaml", para5GData["SMSC_IP"])
smscASAddress := fmt.Sprintf("sudo sed -i '/- name: sms_as/{n;s|diameterAddress: .*|diameterAddress: smsc.ims.%s.3gppnetwork.org|}' /usr/local/etc/udm/as.yaml", mnc_mcc)
udmNEs := NewNeInfo.SelectList(model.NeInfo{NeType: "UDM"}, false, false)
for _, v := range udmNEs {
NewNeInfo.NeRunSSHCmd(v.NeType, v.NeId, smscIPCMD)
NewNeInfo.NeRunSSHCmd(v.NeType, v.NeId, smscHostCMD)
NewNeInfo.NeRunSSHCmd(v.NeType, v.NeId, smscASName)
NewNeInfo.NeRunSSHCmd(v.NeType, v.NeId, smscASAddress)
NewNeInfo.NeRunSSHCmd(v.NeType, v.NeId, "sudo service udm restart")
}
}
}
// 更新Version