feat: sync capability for NBI NRM

This commit is contained in:
simon
2025-04-29 15:46:41 +08:00
parent cec34122da
commit f4a7c4cf82
5 changed files with 53 additions and 13 deletions

View File

@@ -88,6 +88,14 @@ func (s *BarProcessor) SyncAmfNbiCM() error {
continue
}
var capability int
err = dborm.DefaultDB().Table("ne_license").Where("ne_type = ? and ne_id = ?", ne.NeType, ne.NeId).
Pluck("capability", &capability).Error
if err != nil {
log.Errorf("Failed to query capability for ne_id %s: %v", ne.NeId, err)
capability = 0
}
// 为每个网元生成AmfFunction记录
amfFunction := amf.AmfFunction{
Id: fmt.Sprintf("%s-%s-AmfFunction-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
@@ -99,7 +107,7 @@ func (s *BarProcessor) SyncAmfNbiCM() error {
SbiServiceList: "Namf_Communication,Namf_EventExposure,Namf_MT,Namf_Location",
AmfGuamiList: "[{\"mcc\":\"460\",\"mnc\":\"000\",\"amfId\":\"" + ne.NeId + "\"}]",
SnssaiList: "[{\"sst\":1,\"sd\":\"000001\"}]",
MaxUser: 1000000,
MaxUser: capability,
RelativeCapacity: 30,
MaxGnbNum: 100,
}

View File

@@ -120,13 +120,21 @@ func (s *BarProcessor) SyncPcfNbiCM() error {
continue
}
var capability int
err = dborm.DefaultDB().Table("ne_license").Where("ne_type = ? and ne_id = ?", ne.NeType, ne.NeId).
Pluck("capability", &capability).Error
if err != nil {
log.Errorf("Failed to query capability for ne_id %s: %v", ne.NeId, err)
capability = 0
}
// 为每个网元生成UdrFunction记录
udrFunction := pcf.UdrFunction{
Id: fmt.Sprintf("%s-%s-UdrFunction-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-UdrFunction",
AdministrativeState: adminState,
OperationalState: operState,
MaxSubNbr: 500000,
MaxSubNbr: capability,
}
// 序列化为JSON

View File

@@ -83,6 +83,14 @@ func (s *BarProcessor) SyncSmfNbiCM() error {
continue
}
var capability int
err = dborm.DefaultDB().Table("ne_license").Where("ne_type = ? and ne_id = ?", ne.NeType, ne.NeId).
Pluck("capability", &capability).Error
if err != nil {
log.Errorf("Failed to query capability for ne_id %s: %v", ne.NeId, err)
capability = 0
}
// 为每个网元生成SmfFunction记录
smfFunction := smf.SmfFunction{
Id: fmt.Sprintf("%s-%s-SmfFunction-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
@@ -92,7 +100,7 @@ func (s *BarProcessor) SyncSmfNbiCM() error {
VnfInstanceId: "vnf-" + ne.NeType + "-" + ne.NeId,
Fqdn: fmt.Sprintf("%s%s.mnc000.mcc460.3gppnetwork.org", strings.ToLower(ne.NeType), ne.NeId),
SbiServiceList: "Nsmf_PDUSession,Nsmf_EventExposure",
MaxPduSessions: 1000000,
MaxPduSessions: capability,
MaxQfi: 64,
UpfList: "[\"UPF-001\",\"UPF-2\"]",
}

View File

@@ -120,6 +120,14 @@ func (s *BarProcessor) SyncUdmNbiCM() error {
continue
}
var capability int
err = dborm.DefaultDB().Table("ne_license").Where("ne_type = ? and ne_id = ?", ne.NeType, ne.NeId).
Pluck("capability", &capability).Error
if err != nil {
log.Errorf("Failed to query capability for ne_id %s: %v", ne.NeId, err)
capability = 0
}
// 为每个网元生成UdrFunction记录
udrFunction := udm.UdrFunction{
Id: fmt.Sprintf("%s-%s-UdrFunction-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
@@ -129,8 +137,8 @@ func (s *BarProcessor) SyncUdmNbiCM() error {
VnfInstanceId: "vnf-UDR-" + ne.NeId,
Fqdn: fmt.Sprintf("%s%s.mnc000.mcc460.3gppnetwork.org", strings.ToLower(ne.NeType), ne.NeId),
SbiServiceList: "Nudr_DataRepository",
MaxNumSupi: 800000,
MaxNumMsisdn: 800000,
MaxNumSupi: capability,
MaxNumMsisdn: capability,
}
// 序列化为JSON

View File

@@ -85,7 +85,7 @@ func (s *BarProcessor) SyncUpfNbiCM() error {
// 生成 InventoryUnitRack 记录
inventoryUnitRack := upf.InventoryUnitRack{
Id: fmt.Sprintf("%s-%s-InventoryUnitRack-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-Rack",
UserLabel: ne.NeName + "-InventoryUnitRack",
VendorUnitFamilyType: "5G-UPF",
VendorUnitTypeNumber: "UPF-" + ne.NeId,
VendorName: ne.VendorName,
@@ -122,7 +122,7 @@ func (s *BarProcessor) SyncUpfNbiCM() error {
// 生成 InventoryUnitShelf 记录
inventoryUnitShelf := upf.InventoryUnitShelf{
Id: fmt.Sprintf("%s-%s-InventoryUnitShelf-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-Shelf",
UserLabel: ne.NeName + "-InventoryUnitShelf",
VendorUnitFamilyType: "5G-UPF-SHELF",
VendorUnitTypeNumber: "UPF-SHELF-" + ne.NeId,
VendorName: ne.VendorName,
@@ -159,7 +159,7 @@ func (s *BarProcessor) SyncUpfNbiCM() error {
// 生成 InventoryUnitPack 记录
inventoryUnitPack := upf.InventoryUnitPack{
Id: fmt.Sprintf("%s-%s-InventoryUnitPack-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-Pack",
UserLabel: ne.NeName + "-InventoryUnitPack",
VendorUnitFamilyType: "5G-UPF-PACK",
VendorUnitTypeNumber: "UPF-PACK-" + ne.NeId,
VendorName: ne.VendorName,
@@ -196,7 +196,7 @@ func (s *BarProcessor) SyncUpfNbiCM() error {
// 生成 InventoryUnitHost 记录
inventoryUnitHost := upf.InventoryUnitHost{
Id: fmt.Sprintf("%s-%s-InventoryUnitHost-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-Host",
UserLabel: ne.NeName + "-InventoryUnitHost",
VendorUnitFamilyType: "5G-UPF-HOST",
VendorUnitTypeNumber: "UPF-HOST-" + ne.NeId,
VendorName: ne.VendorName,
@@ -236,7 +236,7 @@ func (s *BarProcessor) SyncUpfNbiCM() error {
// 生成 InventoryUnitAccessory 记录
inventoryUnitAccessory := upf.InventoryUnitAccessory{
Id: fmt.Sprintf("%s-%s-InventoryUnitAccessory-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-Accessory",
UserLabel: ne.NeName + "-InventoryUnitAccessory",
VendorUnitFamilyType: "5G-UPF-ACC",
VendorUnitTypeNumber: "UPF-ACC-" + ne.NeId,
VendorName: ne.VendorName,
@@ -272,6 +272,14 @@ func (s *BarProcessor) SyncUpfNbiCM() error {
}
}
var capability int
err = dborm.DefaultDB().Table("ne_license").Where("ne_type = ? and ne_id = ?", ne.NeType, ne.NeId).
Pluck("capability", &capability).Error
if err != nil {
log.Errorf("Failed to query capability for ne_id %s: %v", ne.NeId, err)
capability = 0
}
// 生成 UpfFunction 记录
upfFunction := upf.UpfFunction{
Id: fmt.Sprintf("%s-%s-UpfFunction-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
@@ -279,7 +287,7 @@ func (s *BarProcessor) SyncUpfNbiCM() error {
AdministrativeState: string(adminState),
OperationalState: string(operState),
VnfInstanceId: "vnf-" + ne.NeType + "-" + ne.NeId,
MaxQosFlows: "1000000",
MaxQosFlows: fmt.Sprintf("%d", capability),
MaxThroughput: "10Gbps",
}
@@ -308,7 +316,7 @@ func (s *BarProcessor) SyncUpfNbiCM() error {
// 创建 EpRpDynN3Upf 记录
epRpDynN3Upf := upf.EpRpDynN3Upf{
Id: fmt.Sprintf("%s-%s-EpRpDynN3Upf-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-N3",
UserLabel: ne.NeName + "-EpRpDynN3Upf",
LocIpAddrList: "[\"" + ne.Ip + "\"]",
FarIpSubnetworkList: "[\"10.13.0.0/16\"]",
}
@@ -338,7 +346,7 @@ func (s *BarProcessor) SyncUpfNbiCM() error {
// 创建 EpRpDynN9Upf 记录
epRpDynN9Upf := upf.EpRpDynN9Upf{
Id: fmt.Sprintf("%s-%s-EpRpDynN9Upf-%d", ne.NeType, ne.NeId, timestamp), // 生成唯一ID
UserLabel: ne.NeName + "-N9",
UserLabel: ne.NeName + "-EpRpDynN9Upf",
LocIpAddrList: "[\"" + ne.Ip + "\"]",
FarIpSubnetworkList: "[\"10.19.0.0/16\"]",
}