From a25aadcb95f9b53c5876b6cd12cd668114523dad Mon Sep 17 00:00:00 2001 From: ajenkins Date: Thu, 13 Mar 2025 09:50:57 +0100 Subject: [PATCH 1/2] Fixed table display issue --- samples/json/ip/ipblockcreate.json | 5 +-- samples/json/networks/bgppeergroupcreate.json | 2 +- samples/yaml/ip/ipblockcreate.yaml | 2 ++ samples/yaml/networks/bgppeergroupcreate.yaml | 2 +- src/common/models/tables/bgppeergrouptable.go | 32 +++++++++---------- src/common/models/tablestrings.go | 4 +-- 6 files changed, 25 insertions(+), 22 deletions(-) diff --git a/samples/json/ip/ipblockcreate.json b/samples/json/ip/ipblockcreate.json index 8787847c..9d1bbf24 100644 --- a/samples/json/ip/ipblockcreate.json +++ b/samples/json/ip/ipblockcreate.json @@ -1,5 +1,6 @@ { - "cidrBlockSize": "/28", + "cidrBlockSize": "/64", + "ipVersion": "V6", "location": "PHX", - "description": "Created from PNAPCTL" + "description": "Created V6 from PNAPCTL" } \ No newline at end of file diff --git a/samples/json/networks/bgppeergroupcreate.json b/samples/json/networks/bgppeergroupcreate.json index 0bc39e50..e90486c9 100644 --- a/samples/json/networks/bgppeergroupcreate.json +++ b/samples/json/networks/bgppeergroupcreate.json @@ -1,6 +1,6 @@ { "location": "PHX", - "asn": 98239, + "asn": 64000, "password": "password", "advertisedRoutes": "DEFAULT" } \ No newline at end of file diff --git a/samples/yaml/ip/ipblockcreate.yaml b/samples/yaml/ip/ipblockcreate.yaml index 01bf7f33..481f88a6 100644 --- a/samples/yaml/ip/ipblockcreate.yaml +++ b/samples/yaml/ip/ipblockcreate.yaml @@ -1,2 +1,4 @@ cidrBlockSize: /28 +ipVersion: V4 location: PHX +description: "Created V6 from PNAPCTL" \ No newline at end of file diff --git a/samples/yaml/networks/bgppeergroupcreate.yaml b/samples/yaml/networks/bgppeergroupcreate.yaml index b542dcb8..6d431168 100644 --- a/samples/yaml/networks/bgppeergroupcreate.yaml +++ b/samples/yaml/networks/bgppeergroupcreate.yaml @@ -1,4 +1,4 @@ location: "PHX" -asn: 98239 +asn: 64000 password: "password" advertisedRoutes: "DEFAULT" \ No newline at end of file diff --git a/src/common/models/tables/bgppeergrouptable.go b/src/common/models/tables/bgppeergrouptable.go index e6b04443..e899260d 100644 --- a/src/common/models/tables/bgppeergrouptable.go +++ b/src/common/models/tables/bgppeergrouptable.go @@ -7,21 +7,21 @@ import ( ) type BgpPeerGroupTable struct { - Id string `header: "ID"` - Status string `header: "Status"` - Location string `header: "Location"` - Ipv4Prefixes []string `header: "Ipv4 Prefixes"` - TargetAsnDetails string `header: "Target Asn Details"` - ActiveAsnDetails string `header: "Active Asn Details"` - Password string `header: "Password"` - AdvertisedRoutes string `header: "Advertised Routes"` - RpkiRoaOriginAsn int64 `header: "RPKI ROA Origin ASN"` - EBgpMultiHop int32 `header: "EBGP Multi Hop"` - PeeringLoopbacksV4 []string `header: "Peering Loopbacks V4"` - KeepAliveTimerSeconds int32 `header: "Keep Alive Timer Seconds"` - HoldTimerSeconds int32 `header: "Hold Timer Seconds"` - CreatedOn string `header: "Created On"` - LastUpdatedOn string `header: "Last Updated On"` + Id string `header:"ID"` + Status string `header:"Status"` + Location string `header:"Location"` + Ipv4Prefixes []string `header:"Ipv4 Prefixes"` + TargetAsnDetails string `header:"Target Asn Details"` + ActiveAsnDetails string `header:"Active Asn Details"` + Password string `header:"Password"` + AdvertisedRoutes string `header:"Advertised Routes"` + RpkiRoaOriginAsn int32 `header:"RPKI ROA Origin ASN"` + EBgpMultiHop int32 `header:"EBGP Multi Hop"` + PeeringLoopbacksV4 []string `header:"Peering Loopbacks V4"` + KeepAliveTimerSeconds int32 `header:"Keep Alive Timer Seconds"` + HoldTimerSeconds int32 `header:"Hold Timer Seconds"` + CreatedOn string `header:"Created On"` + LastUpdatedOn string `header:"Last Updated On"` } func BgpPeerGroupFromSdk(sdk networkapi.BgpPeerGroup) BgpPeerGroupTable { @@ -34,7 +34,7 @@ func BgpPeerGroupFromSdk(sdk networkapi.BgpPeerGroup) BgpPeerGroupTable { ActiveAsnDetails: models.AsnDetailsToTableString(sdk.ActiveAsnDetails), Password: sdk.Password, AdvertisedRoutes: sdk.AdvertisedRoutes, - RpkiRoaOriginAsn: sdk.RpkiRoaOriginAsn, + RpkiRoaOriginAsn: int32(sdk.RpkiRoaOriginAsn), EBgpMultiHop: sdk.EBgpMultiHop, PeeringLoopbacksV4: sdk.PeeringLoopbacksV4, KeepAliveTimerSeconds: sdk.KeepAliveTimerSeconds, diff --git a/src/common/models/tablestrings.go b/src/common/models/tablestrings.go index 08a2bff3..612fb92a 100644 --- a/src/common/models/tablestrings.go +++ b/src/common/models/tablestrings.go @@ -105,11 +105,11 @@ var PrivateNetworkServerToTableString = toTableString(func(sdk networkapi.Privat }) var BgpIpv4PrefixToTableString = toTableString(func(sdk networkapi.BgpIPv4Prefix) string { - return fmt.Sprintf("IPv4 Allocation Id: %s\nCidr: %s\nStatus: %s\nIn Use: %s", sdk.Ipv4AllocationId, sdk.Cidr, sdk.Status, sdk.InUse) + return fmt.Sprintf("IPv4 Allocation Id: %s\nCidr: %s\nStatus: %s\nIn Use: %v", sdk.Ipv4AllocationId, sdk.Cidr, sdk.Status, sdk.InUse) }) var AsnDetailsToTableString = toTableString(func(sdk networkapi.AsnDetails) string { - return fmt.Sprintf("Asn: %s\n, Verification Status: %s\nVerification Reason: %s", sdk.Asn, sdk.VerificationStatus, processNil(sdk.VerificationReason)) + return fmt.Sprintf("Asn: %v\nVerification Status: %s\nVerification Reason: %s", sdk.Asn, sdk.VerificationStatus, processNil(sdk.VerificationReason)) }) // ranchersolutionapi From 1d840f20092fac2baf7ba7c065a4b6d4d2f2ea92 Mon Sep 17 00:00:00 2001 From: ajenkins Date: Thu, 13 Mar 2025 09:56:12 +0100 Subject: [PATCH 2/2] Fixed tests --- src/common/models/tables/bgppeergrouptable_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/models/tables/bgppeergrouptable_test.go b/src/common/models/tables/bgppeergrouptable_test.go index ba9d71b4..88d05b29 100644 --- a/src/common/models/tables/bgppeergrouptable_test.go +++ b/src/common/models/tables/bgppeergrouptable_test.go @@ -26,7 +26,7 @@ func assertBgpPeerGroupsEqual(test_framework *testing.T, bgpPeerGroup networkapi assert.Equal(test_framework, models.AsnDetailsToTableString(bgpPeerGroup.ActiveAsnDetails), table.ActiveAsnDetails) assert.Equal(test_framework, bgpPeerGroup.Password, table.Password) assert.Equal(test_framework, bgpPeerGroup.AdvertisedRoutes, table.AdvertisedRoutes) - assert.Equal(test_framework, bgpPeerGroup.RpkiRoaOriginAsn, table.RpkiRoaOriginAsn) + assert.Equal(test_framework, int32(bgpPeerGroup.RpkiRoaOriginAsn), table.RpkiRoaOriginAsn) assert.Equal(test_framework, bgpPeerGroup.EBgpMultiHop, table.EBgpMultiHop) assert.Equal(test_framework, bgpPeerGroup.PeeringLoopbacksV4, table.PeeringLoopbacksV4) assert.Equal(test_framework, bgpPeerGroup.KeepAliveTimerSeconds, table.KeepAliveTimerSeconds)