fix: cm data follow spec of CM doc

This commit is contained in:
simon
2025-07-26 14:35:55 +08:00
parent 3e7c60ecd0
commit 1a5b2cd15a
8 changed files with 77 additions and 58 deletions

View File

@@ -19,7 +19,7 @@ func SyncNbiCM() error {
// 从ne_info表获取AMF类型的网元 // 从ne_info表获取AMF类型的网元
var amfNEs []common.NeInfo var amfNEs []common.NeInfo
err := dborm.DefaultDB().Table("ne_info").Where("ne_type = ?", "AMF"). err := dborm.DefaultDB().Table("ne_info").Where("ne_type = ? and status <> 0", "AMF").
Find(&amfNEs).Error Find(&amfNEs).Error
if err != nil { if err != nil {
log.Errorf("Failed to query AMF network elements: %v", err) log.Errorf("Failed to query AMF network elements: %v", err)
@@ -47,7 +47,7 @@ func SyncNbiCM() error {
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: version, SwVersion: version,
PatchInfo: "-", PatchInfo: "-",
AdministrativeState: adminState, AdministrativeState: adminState,
@@ -91,7 +91,7 @@ func SyncNbiCM() error {
// ========== AmfFunction ========== // ========== AmfFunction ==========
var capability int var capability int
err = dborm.DefaultDB().Table("ne_license").Where("ne_type = ? and ne_id = ?", ne.NeType, ne.NeId). err = dborm.DefaultDB().Table("ne_license").Where("ne_type = ? and ne_id = ? and status = 1", ne.NeType, ne.NeId).
Pluck("capability", &capability).Error Pluck("capability", &capability).Error
if err != nil { if err != nil {
log.Errorf("Failed to query capability for ne_id %s: %v", ne.NeId, err) log.Errorf("Failed to query capability for ne_id %s: %v", ne.NeId, err)
@@ -104,9 +104,9 @@ func SyncNbiCM() error {
OperationalState: operState, OperationalState: operState,
VnfInstanceId: "vnf-" + ne.NeType + "-" + ne.NeId, VnfInstanceId: "vnf-" + ne.NeType + "-" + ne.NeId,
Fqdn: fmt.Sprintf("%s%s.mnc000.mcc460.3gppnetwork.org", strings.ToLower(ne.NeType), ne.NeId), Fqdn: fmt.Sprintf("%s%s.mnc000.mcc460.3gppnetwork.org", strings.ToLower(ne.NeType), ne.NeId),
SbiServiceList: "Namf_Communication,Namf_EventExposure,Namf_MT,Namf_Location", SbiServiceList: "{Namf_Communication,Namf_EventExposure,Namf_MT,Namf_Location}",
AmfGuamiList: "[{\"mcc\":\"460\",\"mnc\":\"000\",\"amfId\":\"" + ne.NeId + "\"}]", AmfGuamiList: "{{\"mcc\":\"460\",\"mnc\":\"000\",\"amfId\":\"" + ne.NeId + "\"}}",
SnssaiList: "[{\"sst\":1,\"sd\":\"000001\"}]", SnssaiList: "{{\"sst\":1,\"sd\":\"000001\"}}",
MaxUser: capability, MaxUser: capability,
RelativeCapacity: 30, RelativeCapacity: 30,
MaxGnbNum: 100, MaxGnbNum: 100,

View File

@@ -125,6 +125,8 @@ type NeInfo struct {
NeName string `db:"ne_name"` NeName string `db:"ne_name"`
Ip string `db:"ip"` Ip string `db:"ip"`
Port string `db:"port"` Port string `db:"port"`
PVFlag string `db:"pv_flag"`
Province string `db:"province"`
Dn string `db:"dn"` Dn string `db:"dn"`
Status NeStatus `db:"status"` Status NeStatus `db:"status"`
} }

View File

@@ -18,7 +18,7 @@ func SyncNbiCM() error {
// 从ne_info表获取PCF类型的网元 // 从ne_info表获取PCF类型的网元
var pcfNEs []common.NeInfo var pcfNEs []common.NeInfo
err := dborm.DefaultDB().Table("ne_info").Where("ne_type = ?", "PCF"). err := dborm.DefaultDB().Table("ne_info").Where("ne_type = ? and status <> 0", "PCF").
Find(&pcfNEs).Error Find(&pcfNEs).Error
if err != nil { if err != nil {
log.Errorf("Failed to query PCF network elements: %v", err) log.Errorf("Failed to query PCF network elements: %v", err)
@@ -45,7 +45,7 @@ func SyncNbiCM() error {
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: version, SwVersion: version,
PatchInfo: "-", PatchInfo: "-",
AdministrativeState: adminState, AdministrativeState: adminState,
@@ -95,7 +95,7 @@ func SyncNbiCM() error {
OperationalState: operState, OperationalState: operState,
VnfInstanceId: "vnf-" + ne.NeType + "-" + ne.NeId, VnfInstanceId: "vnf-" + ne.NeType + "-" + ne.NeId,
Fqdn: fmt.Sprintf("%s%s.mnc000.mcc460.3gppnetwork.org", strings.ToLower(ne.NeType), ne.NeId), Fqdn: fmt.Sprintf("%s%s.mnc000.mcc460.3gppnetwork.org", strings.ToLower(ne.NeType), ne.NeId),
SbiServiceList: "Npcf_AMPolicyControl,Npcf_PolicyAuthorization,Npcf_SMPolicyControl,Npcf_BDTPolicyControl", SbiServiceList: "{Npcf_AMPolicyControl,Npcf_PolicyAuthorization,Npcf_SMPolicyControl,Npcf_BDTPolicyControl}",
} }
pcfJSON, err := json.Marshal(pcfFunction) pcfJSON, err := json.Marshal(pcfFunction)
if err != nil { if err != nil {
@@ -135,7 +135,7 @@ func SyncNbiCM() error {
// ========== UdrFunction ========== // ========== UdrFunction ==========
var capability int var capability int
err = dborm.DefaultDB().Table("ne_license").Where("ne_type = ? and ne_id = ?", ne.NeType, ne.NeId). err = dborm.DefaultDB().Table("ne_license").Where("ne_type = ? and ne_id = ? and status = 1", ne.NeType, ne.NeId).
Pluck("capability", &capability).Error Pluck("capability", &capability).Error
if err != nil { if err != nil {
log.Errorf("Failed to query capability for ne_id %s: %v", ne.NeId, err) log.Errorf("Failed to query capability for ne_id %s: %v", ne.NeId, err)

View File

@@ -26,8 +26,8 @@ type SmfFunction struct {
VnfInstanceId string `json:"vnfInstanceId"` VnfInstanceId string `json:"vnfInstanceId"`
Fqdn string `json:"fqdn"` Fqdn string `json:"fqdn"`
SbiServiceList string `json:"sbiServiceList"` SbiServiceList string `json:"sbiServiceList"`
MaxPduSessions int `json:"maxPduSessions"` MaxPduSessions int32 `json:"maxPduSessions"`
MaxQfi int `json:"maxQfi"` MaxQfi int32 `json:"maxQfi"`
UpfList string `json:"upfList"` UpfList string `json:"upfList"`
} }

View File

@@ -18,7 +18,7 @@ func SyncNbiCM() error {
// 从ne_info表获取SMF类型的网元 // 从ne_info表获取SMF类型的网元
var smfNEs []common.NeInfo var smfNEs []common.NeInfo
err := dborm.DefaultDB().Table("ne_info").Where("ne_type = ?", "SMF"). err := dborm.DefaultDB().Table("ne_info").Where("ne_type = ? and status <> 0", "SMF").
Find(&smfNEs).Error Find(&smfNEs).Error
if err != nil { if err != nil {
log.Errorf("Failed to query SMF network elements: %v", err) log.Errorf("Failed to query SMF network elements: %v", err)
@@ -45,7 +45,7 @@ func SyncNbiCM() error {
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: version, SwVersion: version,
PatchInfo: "-", PatchInfo: "-",
AdministrativeState: adminState, AdministrativeState: adminState,
@@ -88,13 +88,19 @@ func SyncNbiCM() error {
} }
// ========== SmfFunction ========== // ========== SmfFunction ==========
var capability int var capability int32
err = dborm.DefaultDB().Table("ne_license").Where("ne_type = ? and ne_id = ?", ne.NeType, ne.NeId). err = dborm.DefaultDB().Table("ne_license").Where("ne_type = ? and ne_id = ? and status = 1", ne.NeType, ne.NeId).
Pluck("capability", &capability).Error Pluck("capability", &capability).Error
if err != nil { if err != nil {
log.Errorf("Failed to query capability for ne_id %s: %v", ne.NeId, err) log.Errorf("Failed to query capability for ne_id %s: %v", ne.NeId, err)
capability = 0 capability = 0
} }
upfNames := []string{}
err = dborm.DefaultDB().Table("ne_info").Where("ne_type = ? and status <> 0", "UPF").
Select("ne_name").Find(&upfNames).Error
if err != nil {
log.Errorf("Failed to query UPF list for ne_id %s: %v", ne.NeId, err)
}
smfFunction := SmfFunction{ smfFunction := SmfFunction{
Id: fmt.Sprintf("%s-%s-SmfFunction", ne.NeType, ne.NeId), Id: fmt.Sprintf("%s-%s-SmfFunction", ne.NeType, ne.NeId),
UserLabel: ne.NeName + "-SmfFunction", UserLabel: ne.NeName + "-SmfFunction",
@@ -102,10 +108,10 @@ func SyncNbiCM() error {
OperationalState: operState, OperationalState: operState,
VnfInstanceId: "vnf-" + ne.NeType + "-" + ne.NeId, VnfInstanceId: "vnf-" + ne.NeType + "-" + ne.NeId,
Fqdn: fmt.Sprintf("%s%s.mnc000.mcc460.3gppnetwork.org", strings.ToLower(ne.NeType), ne.NeId), Fqdn: fmt.Sprintf("%s%s.mnc000.mcc460.3gppnetwork.org", strings.ToLower(ne.NeType), ne.NeId),
SbiServiceList: "Nsmf_PDUSession,Nsmf_EventExposure", SbiServiceList: "{Nsmf_PDUSession,Nsmf_EventExposure}",
MaxPduSessions: capability, MaxPduSessions: capability,
MaxQfi: 64, MaxQfi: 64,
UpfList: "[\"UPF-001\",\"UPF-2\"]", UpfList: "{" + strings.Join(upfNames, ",") + "}",
} }
smfJSON, err := json.Marshal(smfFunction) smfJSON, err := json.Marshal(smfFunction)
if err != nil { if err != nil {

View File

@@ -18,7 +18,7 @@ func SyncNbiCM() error {
// 从ne_info表获取UDM类型的网元 // 从ne_info表获取UDM类型的网元
var udmNEs []common.NeInfo var udmNEs []common.NeInfo
err := dborm.DefaultDB().Table("ne_info").Where("ne_type = ?", "UDM"). err := dborm.DefaultDB().Table("ne_info").Where("ne_type = ? and status <> 0", "UDM").
Find(&udmNEs).Error Find(&udmNEs).Error
if err != nil { if err != nil {
log.Errorf("Failed to query UDM network elements: %v", err) log.Errorf("Failed to query UDM network elements: %v", err)
@@ -45,7 +45,7 @@ func SyncNbiCM() error {
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: version, SwVersion: version,
PatchInfo: "-", PatchInfo: "-",
AdministrativeState: adminState, AdministrativeState: adminState,
@@ -95,7 +95,7 @@ func SyncNbiCM() error {
OperationalState: operState, OperationalState: operState,
VnfInstanceId: "vnf-" + ne.NeType + "-" + ne.NeId, VnfInstanceId: "vnf-" + ne.NeType + "-" + ne.NeId,
Fqdn: fmt.Sprintf("%s%s.mnc000.mcc460.3gppnetwork.org", strings.ToLower(ne.NeType), ne.NeId), Fqdn: fmt.Sprintf("%s%s.mnc000.mcc460.3gppnetwork.org", strings.ToLower(ne.NeType), ne.NeId),
SbiServiceList: "Nudm_UEAuthentication,Nudm_SubscriberDataManagement,Nudm_UEContextManagement", SbiServiceList: "{Nudm_UEAuthentication,Nudm_SubscriberDataManagement,Nudm_UEContextManagement}",
} }
udmJSON, err := json.Marshal(udmFunction) udmJSON, err := json.Marshal(udmFunction)
if err != nil { if err != nil {
@@ -135,7 +135,7 @@ func SyncNbiCM() error {
// ========== UdrFunction ========== // ========== UdrFunction ==========
var capability int var capability int
err = dborm.DefaultDB().Table("ne_license").Where("ne_type = ? and ne_id = ?", ne.NeType, ne.NeId). err = dborm.DefaultDB().Table("ne_license").Where("ne_type = ? and ne_id = ? and status = 1", ne.NeType, ne.NeId).
Pluck("capability", &capability).Error Pluck("capability", &capability).Error
if err != nil { if err != nil {
log.Errorf("Failed to query capability for ne_id %s: %v", ne.NeId, err) log.Errorf("Failed to query capability for ne_id %s: %v", ne.NeId, err)
@@ -148,7 +148,7 @@ func SyncNbiCM() error {
OperationalState: operState, OperationalState: operState,
VnfInstanceId: "vnf-UDR-" + ne.NeId, VnfInstanceId: "vnf-UDR-" + ne.NeId,
Fqdn: fmt.Sprintf("%s%s.mnc000.mcc460.3gppnetwork.org", strings.ToLower(ne.NeType), ne.NeId), Fqdn: fmt.Sprintf("%s%s.mnc000.mcc460.3gppnetwork.org", strings.ToLower(ne.NeType), ne.NeId),
SbiServiceList: "Nudr_DataRepository", SbiServiceList: "{Nudr_DataRepository}",
MaxNumSupi: capability, MaxNumSupi: capability,
MaxNumMsisdn: capability, MaxNumMsisdn: capability,
} }
@@ -196,7 +196,7 @@ func SyncNbiCM() error {
OperationalState: operState, OperationalState: operState,
VnfInstanceId: "vnf-AUSF-" + ne.NeId, VnfInstanceId: "vnf-AUSF-" + ne.NeId,
Fqdn: fmt.Sprintf("ausf%s.mnc000.mcc460.3gppnetwork.org", ne.NeId), Fqdn: fmt.Sprintf("ausf%s.mnc000.mcc460.3gppnetwork.org", ne.NeId),
SbiServiceList: "Nausf_UEAuthentication,Nausf_SoRProtection", SbiServiceList: "{Nausf_UEAuthentication,Nausf_SoRProtection}",
} }
ausfJSON, err := json.Marshal(ausfFunction) ausfJSON, err := json.Marshal(ausfFunction)
if err != nil { if err != nil {

View File

@@ -12,6 +12,8 @@ type ManagedElement struct {
PatchInfo string `json:"patchInfo"` PatchInfo string `json:"patchInfo"`
AdministrativeState common.AdministrativeState `json:"administrativeState"` AdministrativeState common.AdministrativeState `json:"administrativeState"`
OperationalState common.OperationalState `json:"operationalState"` OperationalState common.OperationalState `json:"operationalState"`
LocationName string `json:"locationName"`
HardwarePlatform string `json:"hardwarePlatform"`
} }
type InventoryUnitRack struct { type InventoryUnitRack struct {
@@ -39,6 +41,7 @@ type InventoryUnitShelf struct {
DateOfManufacture string `json:"dateOfManufacture"` DateOfManufacture string `json:"dateOfManufacture"`
DateOfLastService string `json:"dateOfLastService"` DateOfLastService string `json:"dateOfLastService"`
ManufacturerData string `json:"manufacturerData"` ManufacturerData string `json:"manufacturerData"`
SlotsInformation string `json:"slotsInformation"`
ShelfPosition string `json:"shelfPosition"` ShelfPosition string `json:"shelfPosition"`
} }
@@ -53,6 +56,8 @@ type InventoryUnitPack struct {
DateOfManufacture string `json:"dateOfManufacture"` DateOfManufacture string `json:"dateOfManufacture"`
DateOfLastService string `json:"dateOfLastService"` DateOfLastService string `json:"dateOfLastService"`
ManufacturerData string `json:"manufacturerData"` ManufacturerData string `json:"manufacturerData"`
PortsInformation string `json:"portsInformation"`
PackPosition string `json:"packPosition"`
SlotsOccupied string `json:"slotsOccupied"` SlotsOccupied string `json:"slotsOccupied"`
} }
@@ -68,9 +73,9 @@ type InventoryUnitHost struct {
DateOfLastService string `json:"dateOfLastService"` DateOfLastService string `json:"dateOfLastService"`
ManufacturerData string `json:"manufacturerData"` ManufacturerData string `json:"manufacturerData"`
HostPosition string `json:"hostPosition"` HostPosition string `json:"hostPosition"`
NumberOfCpu string `json:"numberOfCpu"` NumberOfCpu int32 `json:"numberOfCpu"`
MemSize string `json:"memSize"` MemSize float32 `json:"memSize"`
HardDiskSize string `json:"hardDiskSize"` HardDiskSize float32 `json:"hardDiskSize"`
} }
type InventoryUnitAccessory struct { type InventoryUnitAccessory struct {
@@ -95,8 +100,8 @@ type UpfFunction struct {
AdministrativeState common.AdministrativeState `json:"administrativeState"` AdministrativeState common.AdministrativeState `json:"administrativeState"`
OperationalState common.OperationalState `json:"operationalState"` OperationalState common.OperationalState `json:"operationalState"`
VnfInstanceId string `json:"vnfInstanceId"` VnfInstanceId string `json:"vnfInstanceId"`
MaxQosFlows string `json:"maxQosFlows"` MaxQosFlows int32 `json:"maxQosFlows"`
MaxThroughput string `json:"maxThroughput"` MaxThroughput float32 `json:"maxThroughput"`
} }
type EpRpDynN9Upf struct { type EpRpDynN9Upf struct {

View File

@@ -18,7 +18,7 @@ func SyncNbiCM() error {
// 从ne_info表获取UPF类型的网元 // 从ne_info表获取UPF类型的网元
var upfNEs []common.NeInfo var upfNEs []common.NeInfo
err := dborm.DefaultDB().Table("ne_info").Where("ne_type = ?", "UPF"). err := dborm.DefaultDB().Table("ne_info").Where("ne_type = ? and status <> 0", "UPF").
Find(&upfNEs).Error Find(&upfNEs).Error
if err != nil { if err != nil {
log.Errorf("Failed to query UPF network elements: %v", err) log.Errorf("Failed to query UPF network elements: %v", err)
@@ -29,7 +29,7 @@ func SyncNbiCM() error {
now := time.Now() now := time.Now()
for _, ne := range upfNEs { for i, ne := range upfNEs {
adminState, operState := common.ParseStateFromStatus(ne.Status) adminState, operState := common.ParseStateFromStatus(ne.Status)
var version string = "-" var version string = "-"
@@ -47,11 +47,13 @@ func SyncNbiCM() error {
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: version, SwVersion: version,
PatchInfo: "-", PatchInfo: "-",
AdministrativeState: adminState, AdministrativeState: adminState,
OperationalState: operState, OperationalState: operState,
LocationName: ne.Province,
HardwarePlatform: "x86_64",
} }
meJSON, err := json.Marshal(managedElement) meJSON, err := json.Marshal(managedElement)
if err != nil { if err != nil {
@@ -97,11 +99,11 @@ func SyncNbiCM() error {
VendorUnitTypeNumber: "UPF-" + ne.NeId, VendorUnitTypeNumber: "UPF-" + ne.NeId,
VendorName: ne.VendorName, VendorName: ne.VendorName,
SerialNumber: "SN-UPF-" + ne.NeId, SerialNumber: "SN-UPF-" + ne.NeId,
VersionNumber: "1.0.0", VersionNumber: "1.2.16",
DateOfManufacture: "2023-01-01", DateOfManufacture: "2023-01-01",
DateOfLastService: now.Format("2006-01-02"), DateOfLastService: now.AddDate(0, 0, 360).Format("2006-01-02"),
ManufacturerData: "{}", ManufacturerData: "{}",
RackPosition: "1", RackPosition: "1-2",
} }
rackJSON, err := json.Marshal(inventoryUnitRack) rackJSON, err := json.Marshal(inventoryUnitRack)
if err != nil { if err != nil {
@@ -140,6 +142,7 @@ func SyncNbiCM() error {
} }
// ========== InventoryUnitShelf ========== // ========== InventoryUnitShelf ==========
var slotsInfo string = fmt.Sprintf(`{{"slot-%d","-",Unused}}`, i+1)
inventoryUnitShelf := InventoryUnitShelf{ inventoryUnitShelf := InventoryUnitShelf{
Id: fmt.Sprintf("%s-%s-InventoryUnitShelf", ne.NeType, ne.NeId), Id: fmt.Sprintf("%s-%s-InventoryUnitShelf", ne.NeType, ne.NeId),
UserLabel: ne.NeName + "-InventoryUnitShelf", UserLabel: ne.NeName + "-InventoryUnitShelf",
@@ -149,8 +152,9 @@ func SyncNbiCM() error {
SerialNumber: "SN-UPF-SHELF-" + ne.NeId, SerialNumber: "SN-UPF-SHELF-" + ne.NeId,
VersionNumber: "1.0.0", VersionNumber: "1.0.0",
DateOfManufacture: "2023-01-01", DateOfManufacture: "2023-01-01",
DateOfLastService: now.Format("2006-01-02"), DateOfLastService: now.AddDate(0, 0, 360).Format("2006-01-02"),
ManufacturerData: "{}", ManufacturerData: "{}",
SlotsInformation: slotsInfo,
ShelfPosition: "1", ShelfPosition: "1",
} }
shelfJSON, err := json.Marshal(inventoryUnitShelf) shelfJSON, err := json.Marshal(inventoryUnitShelf)
@@ -199,9 +203,11 @@ func SyncNbiCM() error {
SerialNumber: "SN-UPF-PACK-" + ne.NeId, SerialNumber: "SN-UPF-PACK-" + ne.NeId,
VersionNumber: "1.0.0", VersionNumber: "1.0.0",
DateOfManufacture: "2023-01-01", DateOfManufacture: "2023-01-01",
DateOfLastService: now.Format("2006-01-02"), DateOfLastService: now.AddDate(0, 0, 360).Format("2006-01-02"),
ManufacturerData: "{}", ManufacturerData: "{}",
SlotsOccupied: "1,2", PortsInformation: `{{"port-1","Ethernet 10Gbs",Used},{"port-2","Ethernet 10Gbps",Used}, {"port-3","optical 50Gbps",Used}, {"port-4","optical 50Gbps",Unused}}`,
PackPosition: "2-2",
SlotsOccupied: "2",
} }
packJSON, err := json.Marshal(inventoryUnitPack) packJSON, err := json.Marshal(inventoryUnitPack)
if err != nil { if err != nil {
@@ -249,12 +255,12 @@ func SyncNbiCM() error {
SerialNumber: "SN-UPF-HOST-" + ne.NeId, SerialNumber: "SN-UPF-HOST-" + ne.NeId,
VersionNumber: "1.0.0", VersionNumber: "1.0.0",
DateOfManufacture: "2023-01-01", DateOfManufacture: "2023-01-01",
DateOfLastService: now.Format("2006-01-02"), DateOfLastService: now.AddDate(0, 0, 360).Format("2006-01-02"),
ManufacturerData: "{}", ManufacturerData: "{}",
HostPosition: "1", HostPosition: "1",
NumberOfCpu: "16", NumberOfCpu: 16,
MemSize: "64GB", MemSize: 64,
HardDiskSize: "1TB", HardDiskSize: 1024,
} }
hostJSON, err := json.Marshal(inventoryUnitHost) hostJSON, err := json.Marshal(inventoryUnitHost)
if err != nil { if err != nil {
@@ -302,7 +308,7 @@ func SyncNbiCM() error {
SerialNumber: "SN-UPF-ACC-" + ne.NeId, SerialNumber: "SN-UPF-ACC-" + ne.NeId,
VersionNumber: "1.0.0", VersionNumber: "1.0.0",
DateOfManufacture: "2023-01-01", DateOfManufacture: "2023-01-01",
DateOfLastService: now.Format("2006-01-02"), DateOfLastService: now.AddDate(0, 0, 360).Format("2006-01-02"),
ManufacturerData: "{}", ManufacturerData: "{}",
AccessoryPosition: "1", AccessoryPosition: "1",
AccessoryType: "FAN", AccessoryType: "FAN",
@@ -344,8 +350,8 @@ func SyncNbiCM() error {
} }
} }
var capability int var capability int32
err = dborm.DefaultDB().Table("ne_license").Where("ne_type = ? and ne_id = ?", ne.NeType, ne.NeId). err = dborm.DefaultDB().Table("ne_license").Where("ne_type = ? and ne_id = ? and status = 1", ne.NeType, ne.NeId).
Pluck("capability", &capability).Error Pluck("capability", &capability).Error
if err != nil { if err != nil {
log.Errorf("Failed to query capability for ne_id %s: %v", ne.NeId, err) log.Errorf("Failed to query capability for ne_id %s: %v", ne.NeId, err)
@@ -359,8 +365,8 @@ func SyncNbiCM() error {
AdministrativeState: adminState, AdministrativeState: adminState,
OperationalState: operState, OperationalState: operState,
VnfInstanceId: "vnf-" + ne.NeType + "-" + ne.NeId, VnfInstanceId: "vnf-" + ne.NeType + "-" + ne.NeId,
MaxQosFlows: fmt.Sprintf("%d", capability), MaxQosFlows: capability,
MaxThroughput: "10Gbps", MaxThroughput: 10.0,
} }
upfJSON, err := json.Marshal(upfFunction) upfJSON, err := json.Marshal(upfFunction)
if err != nil { if err != nil {