From 95bcc1d902bcc84defb94831052ca05d6a1f0fa7 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Tue, 12 Dec 2023 15:29:08 +0100 Subject: [PATCH] cli: for consistency with YANG model, rename METRIC --> PREF(ERENCE) In review discussions we have decided, for resonsons of consistency over correctness, to rename this column to match the YANG model node name rather than the Linux kernel name. Also, right align the values. Numbers should always be right-aligned. Signed-off-by: Joachim Wiberg --- board/netconf/rootfs/libexec/infix/cli-pretty | 8 +++---- doc/networking.md | 23 ++++++++++--------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/board/netconf/rootfs/libexec/infix/cli-pretty b/board/netconf/rootfs/libexec/infix/cli-pretty index 1e6cb8f9..f61160ba 100755 --- a/board/netconf/rootfs/libexec/infix/cli-pretty +++ b/board/netconf/rootfs/libexec/infix/cli-pretty @@ -18,7 +18,7 @@ class PadRoute: prefix = 30 protocol = 10 next_hop = 30 - metric = 10 + pref = 8 class PadSoftware: name = 10 @@ -59,7 +59,7 @@ class Route: self.data = data self.prefix = data.get(f'ietf-{ip}-unicast-routing:destination-prefix', '') self.protocol = data.get('source-protocol','')[14:] - self.metric = data.get('route-preference','') + self.pref = data.get('route-preference','') interface = get_json_data(None, self.data, 'next-hop', 'outgoing-interface') address = get_json_data(None, self.data, 'next-hop', f'ietf-{ip}-unicast-routing:next-hop-address') @@ -76,7 +76,7 @@ class Route: def print(self): row = f"{self.prefix:<{PadRoute.prefix}}" row += f"{self.next_hop:<{PadRoute.next_hop}}" - row += f"{self.metric:<{PadRoute.metric}}" + row += f"{self.pref:>{PadRoute.pref}} " row += f"{self.protocol:<{PadRoute.protocol}}" print(row) @@ -375,7 +375,7 @@ def ietf_routing(json, ip="ipv4"): sys.exit(1) hdr = (f"{'PREFIX':<{PadRoute.prefix}}" f"{'NEXT-HOP':<{PadRoute.next_hop}}" - f"{'METRIC':<{PadRoute.metric}}" + f"{'PREF':>{PadRoute.pref}} " f"{'PROTOCOL':<{PadRoute.protocol}}") print(Decore.invert(hdr)) diff --git a/doc/networking.md b/doc/networking.md index f0f7162a..d7ef675a 100644 --- a/doc/networking.md +++ b/doc/networking.md @@ -422,25 +422,26 @@ NETCONF or using the CLI: #### IPv4 routing table admin@example:/> show routes ipv4 - PREFIX NEXT-HOP METRIC PROTOCOL - 192.168.1.0/24 e0 kernel - 192.168.200.0/24 192.168.1.1 20 static + PREFIX NEXT-HOP PREF PROTOCOL + 192.168.1.0/24 e0 kernel + 192.168.200.0/24 192.168.1.1 20 static admin@example:/> #### IPv6 routing table admin@example:/> show routes ipv6 - PREFIX NEXT-HOP METRIC PROTOCOL - 2001:db8:3c4d:50::/64 eth4 256 kernel - fe80::/64 eth5 256 kernel - fe80::/64 eth3 256 kernel - fe80::/64 eth1 256 kernel - fe80::/64 eth0 256 kernel - fe80::/64 eth2 256 kernel - fe80::/64 eth4 256 kernel + PREFIX NEXT-HOP PREF PROTOCOL + 2001:db8:3c4d:50::/64 eth4 256 kernel + fe80::/64 eth5 256 kernel + fe80::/64 eth3 256 kernel + fe80::/64 eth1 256 kernel + fe80::/64 eth0 256 kernel + fe80::/64 eth2 256 kernel + fe80::/64 eth4 256 kernel admin@example:/> #### Source protocol + The source protocol describes the origin of the route. | **Protocol** | **Description** |