Skip to content

Commit

Permalink
cli: handle missing oper-status
Browse files Browse the repository at this point in the history
Use known data from .self to avoid crashing if the oper-status is
missing for a interface.

Signed-off-by: Richard Alpe <[email protected]>
  • Loading branch information
rical authored and troglobit committed Oct 12, 2023
1 parent fdcc6d3 commit 7d8b876
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions board/netconf/rootfs/lib/infix/cli-pretty
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ class Iface:

def pr_proto_eth(self):
row = f"{'ethernet':<{Pad.proto}}"
dec = Decore.green if self.data['oper-status'] == "up" else Decore.red
row += dec(f"{self.data['oper-status'].upper():<{Pad.state}}")
dec = Decore.green if self.oper_status == "up" else Decore.red
row += dec(f"{self.oper_status.upper():<{Pad.state}}")
row += f"{self.data['phys-address']:<{Pad.data}}"
print(row)

Expand Down
2 changes: 1 addition & 1 deletion test/case/cli_pretty/json/bloated.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,9 @@
}
},
{
"TEST-DESCR": "VLAN without operstatus",
"name": "vlan20",
"type": "infix-if-type:vlan",
"oper-status": "up",
"if-index": 4,
"phys-address": "02:00:00:00:00:00",
"statistics": {
Expand Down

0 comments on commit 7d8b876

Please sign in to comment.