feat: sync ne NRM

This commit is contained in:
simon
2025-04-28 17:24:15 +08:00
parent 9507879854
commit b31ee42265
5 changed files with 82 additions and 40 deletions

View File

@@ -35,14 +35,23 @@ func (s *BarProcessor) SyncAmfNbiCM() error {
for _, ne := range amfNEs { for _, ne := range amfNEs {
adminState, operState := common.ParseStateFromStatus(ne.Status) adminState, operState := common.ParseStateFromStatus(ne.Status)
var version string = "-"
err := dborm.DefaultDB().Table("ne_version").
Where("ne_type = ? and ne_id = ?", ne.NeType, ne.NeId).
Pluck("version", &version).Error
if err != nil {
log.Errorf("Failed to query %s version: %v", ne.NeName, err)
return err
}
// 为每个网元生成ManagedElement记录 // 为每个网元生成ManagedElement记录
managedElement := amf.ManagedElement{ managedElement := amf.ManagedElement{
Id: "ME" + fmt.Sprintf("-%s-%d", ne.NeId, timestamp), // 生成唯一ID Id: fmt.Sprintf("%s-%s-ManagedElement-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName, UserLabel: ne.NeName,
VendorName: ne.VendorName, VendorName: ne.VendorName,
ManagedBy: ne.Dn, ManagedBy: ne.Dn,
ManagementIpAddress: ne.Ip, // 可以从其他表获取IP地址 ManagementIpAddress: ne.Ip, // 可以从其他表获取IP地址
SwVersion: "", // 可以从其他表获取软件版本 SwVersion: version, // 可以从其他表获取软件版本
PatchInfo: "-", PatchInfo: "-",
AdministrativeState: adminState, AdministrativeState: adminState,
OperationalState: operState, OperationalState: operState,
@@ -80,7 +89,7 @@ func (s *BarProcessor) SyncAmfNbiCM() error {
// 为每个网元生成AmfFunction记录 // 为每个网元生成AmfFunction记录
amfFunction := amf.AmfFunction{ amfFunction := amf.AmfFunction{
Id: "AF" + fmt.Sprintf("-%s-%d", ne.NeId, timestamp), // 生成唯一ID Id: fmt.Sprintf("%s-%s-AmfFunction-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-AmfFunction", UserLabel: ne.NeName + "-AmfFunction",
AdministrativeState: adminState, AdministrativeState: adminState,
OperationalState: operState, OperationalState: operState,
@@ -101,9 +110,6 @@ func (s *BarProcessor) SyncAmfNbiCM() error {
continue continue
} }
// 生成唯一ID
// amfID := fmt.Sprintf("nbi-cm-%s-amf-%d", ne.NeID, timestamp)
// 插入AmfFunction记录 // 插入AmfFunction记录
nbiCM = common.NbiCm{ nbiCM = common.NbiCm{
// Id: amfID, // Id: amfID,
@@ -128,7 +134,7 @@ func (s *BarProcessor) SyncAmfNbiCM() error {
// 创建 EpRpDynN8Amf 记录 // 创建 EpRpDynN8Amf 记录
epRpDynN8Amf := amf.EpRpDynN8Amf{ epRpDynN8Amf := amf.EpRpDynN8Amf{
Id: "N8" + fmt.Sprintf("-%s-%d", ne.NeId, timestamp), Id: fmt.Sprintf("%s-%s-EpRpDynN8Amf-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-N8", UserLabel: ne.NeName + "-N8",
LocIpAddrList: "[\"" + ne.Ip + "\"]", LocIpAddrList: "[\"" + ne.Ip + "\"]",
FarIpSubnetworkList: "[\"10.10.0.0/16\"]", FarIpSubnetworkList: "[\"10.10.0.0/16\"]",
@@ -160,7 +166,7 @@ func (s *BarProcessor) SyncAmfNbiCM() error {
// 创建 EpRpDynN11Amf 记录 // 创建 EpRpDynN11Amf 记录
epRpDynN11Amf := amf.EpRpDynN11Amf{ epRpDynN11Amf := amf.EpRpDynN11Amf{
Id: "N11" + fmt.Sprintf("-%s-%d", ne.NeId, timestamp), Id: fmt.Sprintf("%s-%s-EpRpDynN11Amf-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-N11", UserLabel: ne.NeName + "-N11",
LocIpAddrList: "[\"" + ne.Ip + "\"]", LocIpAddrList: "[\"" + ne.Ip + "\"]",
FarIpSubnetworkList: "[\"10.11.0.0/16\"]", FarIpSubnetworkList: "[\"10.11.0.0/16\"]",
@@ -192,7 +198,7 @@ func (s *BarProcessor) SyncAmfNbiCM() error {
// 创建 EpRpDynN12Amf 记录 // 创建 EpRpDynN12Amf 记录
epRpDynN12Amf := amf.EpRpDynN12Amf{ epRpDynN12Amf := amf.EpRpDynN12Amf{
Id: "N12" + fmt.Sprintf("-%s-%d", ne.NeId, timestamp), Id: fmt.Sprintf("%s-%s-EpRpDynN12Amf-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-N12", UserLabel: ne.NeName + "-N12",
LocIpAddrList: "[\"" + ne.Ip + "\"]", LocIpAddrList: "[\"" + ne.Ip + "\"]",
FarIpSubnetworkList: "[\"10.12.0.0/16\"]", FarIpSubnetworkList: "[\"10.12.0.0/16\"]",
@@ -224,7 +230,7 @@ func (s *BarProcessor) SyncAmfNbiCM() error {
// 创建 IPResource 记录 // 创建 IPResource 记录
ipResource := amf.IPResource{ ipResource := amf.IPResource{
Id: "IP" + fmt.Sprintf("-%s-%d", ne.NeId, timestamp), Id: fmt.Sprintf("%s-%s-IPResource-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-IPResource", UserLabel: ne.NeName + "-IPResource",
InterfaceType: "{Mgt,N8,N11,N12}", InterfaceType: "{Mgt,N8,N11,N12}",
LocIpV4AddrList: fmt.Sprintf("{%s,Default,Default,Default}", ne.Ip), LocIpV4AddrList: fmt.Sprintf("{%s,Default,Default,Default}", ne.Ip),

View File

@@ -34,14 +34,23 @@ func (s *BarProcessor) SyncPcfNbiCM() error {
for _, ne := range pcfNEs { for _, ne := range pcfNEs {
adminState, operState := common.ParseStateFromStatus(ne.Status) adminState, operState := common.ParseStateFromStatus(ne.Status)
var version string = "-"
err := dborm.DefaultDB().Table("ne_version").
Where("ne_type = ? and ne_id = ?", ne.NeType, ne.NeId).
Pluck("version", &version).Error
if err != nil {
log.Errorf("Failed to query %s version: %v", ne.NeName, err)
return err
}
// 为每个网元生成ManagedElement记录 // 为每个网元生成ManagedElement记录
managedElement := pcf.ManagedElement{ managedElement := pcf.ManagedElement{
Id: "ME" + fmt.Sprintf("-%s-%d", ne.NeId, timestamp), Id: fmt.Sprintf("%s-%s-ManagedElement-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName, UserLabel: ne.NeName,
VendorName: ne.VendorName, VendorName: ne.VendorName,
ManagedBy: ne.Dn, ManagedBy: ne.Dn,
ManagementIpAddress: ne.Ip, ManagementIpAddress: ne.Ip,
SwVersion: "", SwVersion: version,
PatchInfo: "-", PatchInfo: "-",
AdministrativeState: adminState, AdministrativeState: adminState,
OperationalState: operState, OperationalState: operState,
@@ -75,7 +84,7 @@ func (s *BarProcessor) SyncPcfNbiCM() error {
// 为每个网元生成PcfFunction记录 // 为每个网元生成PcfFunction记录
pcfFunction := pcf.PcfFunction{ pcfFunction := pcf.PcfFunction{
Id: "PF" + fmt.Sprintf("-%s-%d", ne.NeId, timestamp), Id: fmt.Sprintf("%s-%s-PcfFunction-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-PcfFunction", UserLabel: ne.NeName + "-PcfFunction",
AdministrativeState: adminState, AdministrativeState: adminState,
OperationalState: operState, OperationalState: operState,
@@ -112,7 +121,7 @@ func (s *BarProcessor) SyncPcfNbiCM() error {
// 为每个网元生成UdrFunction记录 // 为每个网元生成UdrFunction记录
udrFunction := pcf.UdrFunction{ udrFunction := pcf.UdrFunction{
Id: "UF" + fmt.Sprintf("-%s-%d", ne.NeId, timestamp), Id: fmt.Sprintf("%s-%s-UdrFunction-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-UdrFunction", UserLabel: ne.NeName + "-UdrFunction",
AdministrativeState: adminState, AdministrativeState: adminState,
OperationalState: operState, OperationalState: operState,
@@ -145,7 +154,7 @@ func (s *BarProcessor) SyncPcfNbiCM() error {
// 创建 IPResource 记录 // 创建 IPResource 记录
ipResource := pcf.IPResource{ ipResource := pcf.IPResource{
Id: "IP" + fmt.Sprintf("-%s-%d", ne.NeId, timestamp), Id: fmt.Sprintf("%s-%s-IPResource-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-IPResource", UserLabel: ne.NeName + "-IPResource",
InterfaceType: "{Mgt,N5,N7,N15}", InterfaceType: "{Mgt,N5,N7,N15}",
LocIpV4AddrList: fmt.Sprintf("{%s,Default,Default,Default}", ne.Ip), LocIpV4AddrList: fmt.Sprintf("{%s,Default,Default,Default}", ne.Ip),

View File

@@ -34,14 +34,23 @@ func (s *BarProcessor) SyncSmfNbiCM() error {
for _, ne := range smfNEs { for _, ne := range smfNEs {
adminState, operState := common.ParseStateFromStatus(ne.Status) adminState, operState := common.ParseStateFromStatus(ne.Status)
var version string = "-"
err := dborm.DefaultDB().Table("ne_version").
Where("ne_type = ? and ne_id = ?", ne.NeType, ne.NeId).
Pluck("version", &version).Error
if err != nil {
log.Errorf("Failed to query %s version: %v", ne.NeName, err)
return err
}
// 为每个网元生成ManagedElement记录 // 为每个网元生成ManagedElement记录
managedElement := smf.ManagedElement{ managedElement := smf.ManagedElement{
Id: "ME" + fmt.Sprintf("-%s-%d", ne.NeId, timestamp), Id: fmt.Sprintf("%s-%s-ManagedElement-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName, UserLabel: ne.NeName,
VendorName: ne.VendorName, VendorName: ne.VendorName,
ManagedBy: ne.Dn, ManagedBy: ne.Dn,
ManagementIpAddress: ne.Ip, ManagementIpAddress: ne.Ip,
SwVersion: "", SwVersion: version,
PatchInfo: "-", PatchInfo: "-",
AdministrativeState: string(adminState), AdministrativeState: string(adminState),
OperationalState: string(operState), OperationalState: string(operState),
@@ -75,7 +84,7 @@ func (s *BarProcessor) SyncSmfNbiCM() error {
// 为每个网元生成SmfFunction记录 // 为每个网元生成SmfFunction记录
smfFunction := smf.SmfFunction{ smfFunction := smf.SmfFunction{
Id: "SF" + fmt.Sprintf("-%s-%d", ne.NeId, timestamp), Id: fmt.Sprintf("%s-%s-SmfFunction-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-SmfFunction", UserLabel: ne.NeName + "-SmfFunction",
AdministrativeState: string(adminState), AdministrativeState: string(adminState),
OperationalState: string(operState), OperationalState: string(operState),
@@ -115,7 +124,7 @@ func (s *BarProcessor) SyncSmfNbiCM() error {
// 创建 AddrPool 记录 // 创建 AddrPool 记录
addrPool := smf.AddrPool{ addrPool := smf.AddrPool{
Id: "AP" + fmt.Sprintf("-%s-%d", ne.NeId, timestamp), Id: fmt.Sprintf("%s-%s-AddrPool-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-AddrPool", UserLabel: ne.NeName + "-AddrPool",
AddrType: "UE", AddrType: "UE",
IpVersion: "IPv4", IpVersion: "IPv4",
@@ -148,7 +157,7 @@ func (s *BarProcessor) SyncSmfNbiCM() error {
// 创建 EpRpDynN7Smf 记录 // 创建 EpRpDynN7Smf 记录
epRpDynN7Smf := smf.EpRpDynN7Smf{ epRpDynN7Smf := smf.EpRpDynN7Smf{
Id: "N7" + fmt.Sprintf("-%s-%d", ne.NeId, timestamp), Id: fmt.Sprintf("%s-%s-EpRpDynN7Smf-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-N7", UserLabel: ne.NeName + "-N7",
LocIpAddrList: "[\"" + ne.Ip + "\"]", LocIpAddrList: "[\"" + ne.Ip + "\"]",
FarIpSubnetworkList: "[\"10.17.0.0/16\"]", FarIpSubnetworkList: "[\"10.17.0.0/16\"]",
@@ -180,7 +189,7 @@ func (s *BarProcessor) SyncSmfNbiCM() error {
// 创建 EpRpDynN10Smf 记录 // 创建 EpRpDynN10Smf 记录
epRpDynN10Smf := smf.EpRpDynN10Smf{ epRpDynN10Smf := smf.EpRpDynN10Smf{
Id: "N10" + fmt.Sprintf("-%s-%d", ne.NeId, timestamp), Id: fmt.Sprintf("%s-%s-EpRpDynN10Smf-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-N10", UserLabel: ne.NeName + "-N10",
LocIpAddrList: "[\"" + ne.Ip + "\"]", LocIpAddrList: "[\"" + ne.Ip + "\"]",
FarIpSubnetworkList: "[\"10.20.0.0/16\"]", FarIpSubnetworkList: "[\"10.20.0.0/16\"]",
@@ -212,7 +221,7 @@ func (s *BarProcessor) SyncSmfNbiCM() error {
// 创建 IPResource 记录 // 创建 IPResource 记录
ipResource := smf.IPResource{ ipResource := smf.IPResource{
Id: "IP" + fmt.Sprintf("-%s-%d", ne.NeId, timestamp), Id: fmt.Sprintf("%s-%s-IPResource-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-IPResource", UserLabel: ne.NeName + "-IPResource",
InterfaceType: "{Mgt,N4,N7,N10,N11}", InterfaceType: "{Mgt,N4,N7,N10,N11}",
LocIpV4AddrList: fmt.Sprintf("{%s,%s,%s,%s,%s}", ne.Ip, ne.Ip, ne.Ip, ne.Ip, ne.Ip), LocIpV4AddrList: fmt.Sprintf("{%s,%s,%s,%s,%s}", ne.Ip, ne.Ip, ne.Ip, ne.Ip, ne.Ip),

View File

@@ -34,14 +34,23 @@ func (s *BarProcessor) SyncUdmNbiCM() error {
for _, ne := range udmNEs { for _, ne := range udmNEs {
adminState, operState := common.ParseStateFromStatus(ne.Status) adminState, operState := common.ParseStateFromStatus(ne.Status)
var version string = "-"
err := dborm.DefaultDB().Table("ne_version").
Where("ne_type = ? and ne_id = ?", ne.NeType, ne.NeId).
Pluck("version", &version).Error
if err != nil {
log.Errorf("Failed to query %s version: %v", ne.NeName, err)
return err
}
// 为每个网元生成ManagedElement记录 // 为每个网元生成ManagedElement记录
managedElement := udm.ManagedElement{ managedElement := udm.ManagedElement{
Id: "ME" + fmt.Sprintf("-%s-%d", ne.NeId, timestamp), Id: fmt.Sprintf("%s-%s-ManagedElement-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName, UserLabel: ne.NeName,
VendorName: ne.VendorName, VendorName: ne.VendorName,
ManagedBy: ne.Dn, ManagedBy: ne.Dn,
ManagementIpAddress: ne.Ip, ManagementIpAddress: ne.Ip,
SwVersion: "", SwVersion: version,
PatchInfo: "-", PatchInfo: "-",
AdministrativeState: string(adminState), AdministrativeState: string(adminState),
OperationalState: string(operState), OperationalState: string(operState),
@@ -75,7 +84,7 @@ func (s *BarProcessor) SyncUdmNbiCM() error {
// 为每个网元生成UdmFunction记录 // 为每个网元生成UdmFunction记录
udmFunction := udm.UdmFunction{ udmFunction := udm.UdmFunction{
Id: "UF" + fmt.Sprintf("-%s-%d", ne.NeId, timestamp), Id: fmt.Sprintf("%s-%s-UdmFunction-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-UdmFunction", UserLabel: ne.NeName + "-UdmFunction",
AdministrativeState: string(adminState), AdministrativeState: string(adminState),
OperationalState: string(operState), OperationalState: string(operState),
@@ -112,7 +121,7 @@ func (s *BarProcessor) SyncUdmNbiCM() error {
// 为每个网元生成UdrFunction记录 // 为每个网元生成UdrFunction记录
udrFunction := udm.UdrFunction{ udrFunction := udm.UdrFunction{
Id: "UDR" + fmt.Sprintf("-%s-%d", ne.NeId, timestamp), Id: fmt.Sprintf("%s-%s-UdrFunction-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-UdrFunction", UserLabel: ne.NeName + "-UdrFunction",
AdministrativeState: string(adminState), AdministrativeState: string(adminState),
OperationalState: string(operState), OperationalState: string(operState),
@@ -149,7 +158,7 @@ func (s *BarProcessor) SyncUdmNbiCM() error {
// 为每个网元生成AusfFunction记录 // 为每个网元生成AusfFunction记录
ausfFunction := udm.AusfFunction{ ausfFunction := udm.AusfFunction{
Id: "AUSF" + fmt.Sprintf("-%s-%d", ne.NeId, timestamp), Id: fmt.Sprintf("%s-%s-AusfFunction-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-AusfFunction", UserLabel: ne.NeName + "-AusfFunction",
AdministrativeState: string(adminState), AdministrativeState: string(adminState),
OperationalState: string(operState), OperationalState: string(operState),
@@ -184,7 +193,7 @@ func (s *BarProcessor) SyncUdmNbiCM() error {
// 创建 IPResource 记录 // 创建 IPResource 记录
ipResource := udm.IPResource{ ipResource := udm.IPResource{
Id: "IP" + fmt.Sprintf("-%s-%d", ne.NeId, timestamp), Id: fmt.Sprintf("%s-%s-IPResource-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-IPResource", UserLabel: ne.NeName + "-IPResource",
InterfaceType: "{Mgt,N8,N10,N12,N21}", InterfaceType: "{Mgt,N8,N10,N12,N21}",
LocIpV4AddrList: fmt.Sprintf("{%s,%s,%s,%s,%s}", ne.Ip, ne.Ip, ne.Ip, ne.Ip, ne.Ip), LocIpV4AddrList: fmt.Sprintf("{%s,%s,%s,%s,%s}", ne.Ip, ne.Ip, ne.Ip, ne.Ip, ne.Ip),

View File

@@ -34,14 +34,23 @@ func (s *BarProcessor) SyncUpfNbiCM() error {
for _, ne := range upfNEs { for _, ne := range upfNEs {
adminState, operState := common.ParseStateFromStatus(ne.Status) adminState, operState := common.ParseStateFromStatus(ne.Status)
var version string = "-"
err := dborm.DefaultDB().Table("ne_version").
Where("ne_type = ? and ne_id = ?", ne.NeType, ne.NeId).
Pluck("version", &version).Error
if err != nil {
log.Errorf("Failed to query %s version: %v", ne.NeName, err)
return err
}
// 为每个网元生成ManagedElement记录 // 为每个网元生成ManagedElement记录
managedElement := upf.ManagedElement{ managedElement := upf.ManagedElement{
Id: "ME" + fmt.Sprintf("-%s-%d", ne.NeId, timestamp), Id: fmt.Sprintf("%s-%s-ManagedElement-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName, UserLabel: ne.NeName,
VendorName: ne.VendorName, VendorName: ne.VendorName,
ManagedBy: ne.Dn, ManagedBy: ne.Dn,
ManagementIpAddress: ne.Ip, ManagementIpAddress: ne.Ip,
SwVersion: "", SwVersion: version,
PatchInfo: "-", PatchInfo: "-",
AdministrativeState: string(adminState), AdministrativeState: string(adminState),
OperationalState: string(operState), OperationalState: string(operState),
@@ -75,7 +84,7 @@ func (s *BarProcessor) SyncUpfNbiCM() error {
// 生成 InventoryUnitRack 记录 // 生成 InventoryUnitRack 记录
inventoryUnitRack := upf.InventoryUnitRack{ inventoryUnitRack := upf.InventoryUnitRack{
Id: "RACK" + fmt.Sprintf("-%s-%d", ne.NeId, timestamp), Id: fmt.Sprintf("%s-%s-InventoryUnitRack-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-Rack", UserLabel: ne.NeName + "-Rack",
VendorUnitFamilyType: "5G-UPF", VendorUnitFamilyType: "5G-UPF",
VendorUnitTypeNumber: "UPF-" + ne.NeId, VendorUnitTypeNumber: "UPF-" + ne.NeId,
@@ -112,7 +121,7 @@ func (s *BarProcessor) SyncUpfNbiCM() error {
// 生成 InventoryUnitShelf 记录 // 生成 InventoryUnitShelf 记录
inventoryUnitShelf := upf.InventoryUnitShelf{ inventoryUnitShelf := upf.InventoryUnitShelf{
Id: "SHELF" + fmt.Sprintf("-%s-%d", ne.NeId, timestamp), Id: fmt.Sprintf("%s-%s-InventoryUnitShelf-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-Shelf", UserLabel: ne.NeName + "-Shelf",
VendorUnitFamilyType: "5G-UPF-SHELF", VendorUnitFamilyType: "5G-UPF-SHELF",
VendorUnitTypeNumber: "UPF-SHELF-" + ne.NeId, VendorUnitTypeNumber: "UPF-SHELF-" + ne.NeId,
@@ -149,7 +158,7 @@ func (s *BarProcessor) SyncUpfNbiCM() error {
// 生成 InventoryUnitPack 记录 // 生成 InventoryUnitPack 记录
inventoryUnitPack := upf.InventoryUnitPack{ inventoryUnitPack := upf.InventoryUnitPack{
Id: "PACK" + fmt.Sprintf("-%s-%d", ne.NeId, timestamp), Id: fmt.Sprintf("%s-%s-InventoryUnitPack-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-Pack", UserLabel: ne.NeName + "-Pack",
VendorUnitFamilyType: "5G-UPF-PACK", VendorUnitFamilyType: "5G-UPF-PACK",
VendorUnitTypeNumber: "UPF-PACK-" + ne.NeId, VendorUnitTypeNumber: "UPF-PACK-" + ne.NeId,
@@ -186,7 +195,7 @@ func (s *BarProcessor) SyncUpfNbiCM() error {
// 生成 InventoryUnitHost 记录 // 生成 InventoryUnitHost 记录
inventoryUnitHost := upf.InventoryUnitHost{ inventoryUnitHost := upf.InventoryUnitHost{
Id: "HOST" + fmt.Sprintf("-%s-%d", ne.NeId, timestamp), Id: fmt.Sprintf("%s-%s-InventoryUnitHost-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-Host", UserLabel: ne.NeName + "-Host",
VendorUnitFamilyType: "5G-UPF-HOST", VendorUnitFamilyType: "5G-UPF-HOST",
VendorUnitTypeNumber: "UPF-HOST-" + ne.NeId, VendorUnitTypeNumber: "UPF-HOST-" + ne.NeId,
@@ -226,7 +235,7 @@ func (s *BarProcessor) SyncUpfNbiCM() error {
// 生成 InventoryUnitAccessory 记录 // 生成 InventoryUnitAccessory 记录
inventoryUnitAccessory := upf.InventoryUnitAccessory{ inventoryUnitAccessory := upf.InventoryUnitAccessory{
Id: "ACC" + fmt.Sprintf("-%s-%d", ne.NeId, timestamp), Id: fmt.Sprintf("%s-%s-InventoryUnitAccessory-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-Accessory", UserLabel: ne.NeName + "-Accessory",
VendorUnitFamilyType: "5G-UPF-ACC", VendorUnitFamilyType: "5G-UPF-ACC",
VendorUnitTypeNumber: "UPF-ACC-" + ne.NeId, VendorUnitTypeNumber: "UPF-ACC-" + ne.NeId,
@@ -265,7 +274,7 @@ func (s *BarProcessor) SyncUpfNbiCM() error {
// 生成 UpfFunction 记录 // 生成 UpfFunction 记录
upfFunction := upf.UpfFunction{ upfFunction := upf.UpfFunction{
Id: "UF" + fmt.Sprintf("-%s-%d", ne.NeId, timestamp), Id: fmt.Sprintf("%s-%s-UpfFunction-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-UpfFunction", UserLabel: ne.NeName + "-UpfFunction",
AdministrativeState: string(adminState), AdministrativeState: string(adminState),
OperationalState: string(operState), OperationalState: string(operState),
@@ -298,7 +307,7 @@ func (s *BarProcessor) SyncUpfNbiCM() error {
// 创建 EpRpDynN3Upf 记录 // 创建 EpRpDynN3Upf 记录
epRpDynN3Upf := upf.EpRpDynN3Upf{ epRpDynN3Upf := upf.EpRpDynN3Upf{
Id: "N3" + fmt.Sprintf("-%s-%d", ne.NeId, timestamp), Id: fmt.Sprintf("%s-%s-EpRpDynN3Upf-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-N3", UserLabel: ne.NeName + "-N3",
LocIpAddrList: "[\"" + ne.Ip + "\"]", LocIpAddrList: "[\"" + ne.Ip + "\"]",
FarIpSubnetworkList: "[\"10.13.0.0/16\"]", FarIpSubnetworkList: "[\"10.13.0.0/16\"]",
@@ -328,7 +337,7 @@ func (s *BarProcessor) SyncUpfNbiCM() error {
// 创建 EpRpDynN9Upf 记录 // 创建 EpRpDynN9Upf 记录
epRpDynN9Upf := upf.EpRpDynN9Upf{ epRpDynN9Upf := upf.EpRpDynN9Upf{
Id: "N9" + fmt.Sprintf("-%s-%d", ne.NeId, timestamp), Id: fmt.Sprintf("%s-%s-EpRpDynN9Upf-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-N9", UserLabel: ne.NeName + "-N9",
LocIpAddrList: "[\"" + ne.Ip + "\"]", LocIpAddrList: "[\"" + ne.Ip + "\"]",
FarIpSubnetworkList: "[\"10.19.0.0/16\"]", FarIpSubnetworkList: "[\"10.19.0.0/16\"]",
@@ -358,7 +367,7 @@ func (s *BarProcessor) SyncUpfNbiCM() error {
// 创建 IPResource 记录 // 创建 IPResource 记录
ipResource := upf.IPResource{ ipResource := upf.IPResource{
Id: "IP" + fmt.Sprintf("-%s-%d", ne.NeId, timestamp), Id: fmt.Sprintf("%s-%s-IPResource-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-IPResource", UserLabel: ne.NeName + "-IPResource",
InterfaceType: "{Mgt,N3,N4,N9}", InterfaceType: "{Mgt,N3,N4,N9}",
LocIpV4AddrList: fmt.Sprintf("{%s,%s,%s,%s}", ne.Ip, ne.Ip, ne.Ip, ne.Ip), LocIpV4AddrList: fmt.Sprintf("{%s,%s,%s,%s}", ne.Ip, ne.Ip, ne.Ip, ne.Ip),