cli: handle missing oper-status

Use known data from .self to avoid crashing if the oper-status is
missing for a interface.

Signed-off-by: Richard Alpe <richard@bit42.se>
This commit is contained in:
Richard Alpe
2023-10-12 10:10:30 +02:00
committed by Joachim Wiberg
parent fdcc6d35a4
commit 7d8b876cc7
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -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)
+1 -1
View File
@@ -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": {