feat: sync ne NRM
This commit is contained in:
@@ -34,14 +34,23 @@ func (s *BarProcessor) SyncUpfNbiCM() error {
|
||||
for _, ne := range upfNEs {
|
||||
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 := 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,
|
||||
VendorName: ne.VendorName,
|
||||
ManagedBy: ne.Dn,
|
||||
ManagementIpAddress: ne.Ip,
|
||||
SwVersion: "",
|
||||
SwVersion: version,
|
||||
PatchInfo: "-",
|
||||
AdministrativeState: string(adminState),
|
||||
OperationalState: string(operState),
|
||||
@@ -75,7 +84,7 @@ func (s *BarProcessor) SyncUpfNbiCM() error {
|
||||
|
||||
// 生成 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",
|
||||
VendorUnitFamilyType: "5G-UPF",
|
||||
VendorUnitTypeNumber: "UPF-" + ne.NeId,
|
||||
@@ -112,7 +121,7 @@ func (s *BarProcessor) SyncUpfNbiCM() error {
|
||||
|
||||
// 生成 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",
|
||||
VendorUnitFamilyType: "5G-UPF-SHELF",
|
||||
VendorUnitTypeNumber: "UPF-SHELF-" + ne.NeId,
|
||||
@@ -149,7 +158,7 @@ func (s *BarProcessor) SyncUpfNbiCM() error {
|
||||
|
||||
// 生成 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",
|
||||
VendorUnitFamilyType: "5G-UPF-PACK",
|
||||
VendorUnitTypeNumber: "UPF-PACK-" + ne.NeId,
|
||||
@@ -186,7 +195,7 @@ func (s *BarProcessor) SyncUpfNbiCM() error {
|
||||
|
||||
// 生成 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",
|
||||
VendorUnitFamilyType: "5G-UPF-HOST",
|
||||
VendorUnitTypeNumber: "UPF-HOST-" + ne.NeId,
|
||||
@@ -226,7 +235,7 @@ func (s *BarProcessor) SyncUpfNbiCM() error {
|
||||
|
||||
// 生成 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",
|
||||
VendorUnitFamilyType: "5G-UPF-ACC",
|
||||
VendorUnitTypeNumber: "UPF-ACC-" + ne.NeId,
|
||||
@@ -265,7 +274,7 @@ func (s *BarProcessor) SyncUpfNbiCM() error {
|
||||
|
||||
// 生成 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",
|
||||
AdministrativeState: string(adminState),
|
||||
OperationalState: string(operState),
|
||||
@@ -298,7 +307,7 @@ func (s *BarProcessor) SyncUpfNbiCM() error {
|
||||
|
||||
// 创建 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",
|
||||
LocIpAddrList: "[\"" + ne.Ip + "\"]",
|
||||
FarIpSubnetworkList: "[\"10.13.0.0/16\"]",
|
||||
@@ -328,7 +337,7 @@ func (s *BarProcessor) SyncUpfNbiCM() error {
|
||||
|
||||
// 创建 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",
|
||||
LocIpAddrList: "[\"" + ne.Ip + "\"]",
|
||||
FarIpSubnetworkList: "[\"10.19.0.0/16\"]",
|
||||
@@ -358,7 +367,7 @@ func (s *BarProcessor) SyncUpfNbiCM() error {
|
||||
|
||||
// 创建 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",
|
||||
InterfaceType: "{Mgt,N3,N4,N9}",
|
||||
LocIpV4AddrList: fmt.Sprintf("{%s,%s,%s,%s}", ne.Ip, ne.Ip, ne.Ip, ne.Ip),
|
||||
|
||||
Reference in New Issue
Block a user