From d00c062c0e7cde0f180373b0fc91b1602cf2e171 Mon Sep 17 00:00:00 2001 From: Richard Alpe Date: Tue, 19 Sep 2023 09:48:50 +0200 Subject: [PATCH] cli: print ip origin in detailed interfaces view Include ip origin when doing "show interfaces name NAME". Both IPv4 and IPv6. Signed-off-by: Richard Alpe --- board/netconf/rootfs/lib/infix/cli-pretty | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/board/netconf/rootfs/lib/infix/cli-pretty b/board/netconf/rootfs/lib/infix/cli-pretty index 764819b4..74210c23 100755 --- a/board/netconf/rootfs/lib/infix/cli-pretty +++ b/board/netconf/rootfs/lib/infix/cli-pretty @@ -157,9 +157,12 @@ class Iface: if self.ipv4_addr: first = True for addr in self.ipv4_addr: + origin = f"({addr['origin']})" if addr.get('origin') else "" key = 'ipv4 addresses' if first else '' colon = ':' if first else ' ' - print(f"{key:<{20}}{colon} {addr['ip']}/{addr['prefix-length']}") + row = f"{key:<{20}}{colon} " + row += f"{addr['ip']}/{addr['prefix-length']} {origin}" + print(row) first = False else: print(f"{'ipv4 addresses':<{20}}:") @@ -167,9 +170,12 @@ class Iface: if self.ipv6_addr: first = True for addr in self.ipv6_addr: + origin = f"({addr['origin']})" if addr.get('origin') else "" key = 'ipv6 addresses' if first else '' colon = ':' if first else ' ' - print(f"{key:<{20}}{colon} {addr['ip']}/{addr['prefix-length']}") + row = f"{key:<{20}}{colon} " + row += f"{addr['ip']}/{addr['prefix-length']} {origin}" + print(row) first = False else: print(f"{'ipv6 addresses':<{20}}:")