Skip to content

Commit 6291bf4

Browse files
Sort device port speeds and correctly calculate GBs on Cisco NX-OS (#137)
1 parent ee09021 commit 6291bf4

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

internal/controller/core/device_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ func (r *DeviceReconciler) reconcile(ctx context.Context, device *v1alpha1.Devic
266266
Trasceiver: p.Transceiver,
267267
InterfaceRef: ref,
268268
}
269+
slices.Sort(device.Status.Ports[i].SupportedSpeedsGbps)
269270
}
270271

271272
device.Status.PostSummary = PortSummary(device.Status.Ports)

internal/provider/cisco/nxos/provider.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ func (p *Provider) ListPorts(ctx context.Context) ([]provider.DevicePort, error)
103103
var speeds []int32
104104
for s := range strings.SplitSeq(p.PhysItems.PortcapItems.Speed, ",") {
105105
if n, err := strconv.ParseInt(s, 10, 32); err == nil {
106-
speeds = append(speeds, int32(n))
106+
if gbps := int32(n) / 1000; gbps > 0 && !slices.Contains(speeds, gbps) {
107+
speeds = append(speeds, gbps)
108+
}
107109
}
108110
}
109111
dp[i] = provider.DevicePort{

0 commit comments

Comments
 (0)