From c40d95b97f583ef8914bd3f7e29ba6483decdbc5 Mon Sep 17 00:00:00 2001 From: Sonic Build Admin Date: Mon, 3 Mar 2025 08:00:22 +0000 Subject: [PATCH] Add namespace support for show interface neighbor expected #### What I did Adding namespace support for `show interface neighbor expected`. So that we can use ``` show interface neighbor expected -n asic0 ``` #### How I did it #### How to verify it Verified on T2 testbed #### Previous command output (if the output of a command-line utility has changed) ``` admin@somehost:/var/log$ show interfaces neighbor expected -n asic1 Usage: show interfaces neighbor expected [OPTIONS] [INTERFACENAME] Try "show interfaces neighbor expected -h" for help. Error: no such option: -n ``` #### New command output (if the output of a command-line utility has changed) ``` admin@somehost:/var/log$ show interfaces neighbor expected -n asic1 LocalPort Neighbor NeighborPort NeighborLoopback NeighborMgmt NeighborType ----------- ---------- -------------- ------------------ -------------- -------------- Ethernet96 ARISTAXXTX Ethernet1 None XXX.XX.XXX.XX someHub Ethernet104 ARISTAXXTX Ethernet1 None XXX.XX.XXX.XX otherHub ... ``` --- doc/Command-Reference.md | 2 +- show/interfaces/__init__.py | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/doc/Command-Reference.md b/doc/Command-Reference.md index 4dad474cb1..ce2544a435 100644 --- a/doc/Command-Reference.md +++ b/doc/Command-Reference.md @@ -5236,7 +5236,7 @@ This command is used to display the list of expected neighbors for all interface - Usage: ``` - show interfaces neighbor expected [] + show interfaces neighbor expected [] -n [] ``` - Example: diff --git a/show/interfaces/__init__.py b/show/interfaces/__init__.py index 2c7081fa81..0c27ba79a4 100644 --- a/show/interfaces/__init__.py +++ b/show/interfaces/__init__.py @@ -281,16 +281,20 @@ def neighbor(): # 'expected' subcommand ("show interface neighbor expected") @neighbor.command() @click.argument('interfacename', required=False) +@multi_asic_util.multi_asic_click_option_namespace @clicommon.pass_db -def expected(db, interfacename): +def expected(db, interfacename, namespace): """Show expected neighbor information by interfaces""" - neighbor_dict = db.cfgdb.get_table("DEVICE_NEIGHBOR") + if not namespace: + namespace = multi_asic_util.constants.DEFAULT_NAMESPACE + + neighbor_dict = db.cfgdb_clients[namespace].get_table("DEVICE_NEIGHBOR") if neighbor_dict is None: click.echo("DEVICE_NEIGHBOR information is not present.") return - neighbor_metadata_dict = db.cfgdb.get_table("DEVICE_NEIGHBOR_METADATA") + neighbor_metadata_dict = db.cfgdb_clients[namespace].get_table("DEVICE_NEIGHBOR_METADATA") if neighbor_metadata_dict is None: click.echo("DEVICE_NEIGHBOR_METADATA information is not present.") return