Skip to content

Commit b267565

Browse files
[NX-OS] Define OperSt enumeration for operational status of interfaces
This change introduces a `OperSt` enumeration in the cisco nx-os provider that corresponds to the `l1_operSt` enum of the Cisco NX-OS Device YANG model.
1 parent 159aa44 commit b267565

3 files changed

Lines changed: 16 additions & 6 deletions

File tree

internal/provider/cisco/nxos/admin.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,13 @@ const (
2626
AdminStOff AdminSt3 = "off"
2727
AdminStOn AdminSt3 = "on"
2828
)
29+
30+
// OperSt represents the operational state of a component.
31+
type OperSt string
32+
33+
const (
34+
OperStUp OperSt = "up"
35+
OperStDown OperSt = "down"
36+
OperStUnknown OperSt = "unknown"
37+
OperStLinkUp OperSt = "link-up"
38+
)

internal/provider/cisco/nxos/intf.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ func (l *Loopback) XPath() string {
4141
}
4242

4343
type LoopbackOperItems struct {
44-
ID string `json:"-"`
45-
OperSt AdminSt2 `json:"operSt"`
44+
ID string `json:"-"`
45+
OperSt OperSt `json:"operSt"`
4646
}
4747

4848
func (l *LoopbackOperItems) XPath() string {
@@ -97,8 +97,8 @@ func (p *PhysIf) Default() {
9797
}
9898

9999
type PhysIfOperItems struct {
100-
ID string `json:"-"`
101-
OperSt AdminSt2 `json:"operSt"`
100+
ID string `json:"-"`
101+
OperSt OperSt `json:"operSt"`
102102
}
103103

104104
func (p *PhysIfOperItems) XPath() string {

internal/provider/cisco/nxos/provider.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ func (p *Provider) DeleteInterface(ctx context.Context, req *provider.InterfaceR
671671
}
672672

673673
func (p *Provider) GetInterfaceStatus(ctx context.Context, req *provider.InterfaceRequest) (provider.InterfaceStatus, error) {
674-
var operSt AdminSt2
674+
var operSt OperSt
675675
switch req.Interface.Spec.Type {
676676
case v1alpha1.InterfaceTypePhysical:
677677
phys := new(PhysIfOperItems)
@@ -694,7 +694,7 @@ func (p *Provider) GetInterfaceStatus(ctx context.Context, req *provider.Interfa
694694
}
695695

696696
return provider.InterfaceStatus{
697-
OperStatus: operSt == AdminStUp,
697+
OperStatus: operSt == OperStUp,
698698
}, nil
699699
}
700700

0 commit comments

Comments
 (0)