From 7d8b876cc781668fa3aba4bb9a6a8e98aaf200f7 Mon Sep 17 00:00:00 2001 From: Richard Alpe Date: Thu, 12 Oct 2023 08:48:32 +0200 Subject: [PATCH] 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 --- board/netconf/rootfs/lib/infix/cli-pretty | 4 ++-- test/case/cli_pretty/json/bloated.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/board/netconf/rootfs/lib/infix/cli-pretty b/board/netconf/rootfs/lib/infix/cli-pretty index f792b6d6a..2f8b249e9 100755 --- a/board/netconf/rootfs/lib/infix/cli-pretty +++ b/board/netconf/rootfs/lib/infix/cli-pretty @@ -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) diff --git a/test/case/cli_pretty/json/bloated.json b/test/case/cli_pretty/json/bloated.json index 347fb6098..1c425a5b1 100644 --- a/test/case/cli_pretty/json/bloated.json +++ b/test/case/cli_pretty/json/bloated.json @@ -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": {