From e34b8958e1e83f175b9f642516ae4497b6d5f648 Mon Sep 17 00:00:00 2001 From: Kirk Byers Date: Thu, 31 Oct 2024 14:41:09 -0700 Subject: [PATCH] Fix --list-devices and --version in Netmiko CLI tools (#3519) --- netmiko/cli_tools/argument_handling.py | 8 ++++++-- netmiko/cli_tools/fix.txt | 2 -- netmiko/utilities.py | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) delete mode 100644 netmiko/cli_tools/fix.txt diff --git a/netmiko/cli_tools/argument_handling.py b/netmiko/cli_tools/argument_handling.py index 60a9ca911..1c7854648 100644 --- a/netmiko/cli_tools/argument_handling.py +++ b/netmiko/cli_tools/argument_handling.py @@ -1,3 +1,4 @@ +import sys import argparse from getpass import getpass from netmiko.utilities import load_devices, display_inventory @@ -38,6 +39,7 @@ def show_args(parser): help="Device or group to connect to", action="store", type=str, + nargs="?", ) @@ -48,6 +50,7 @@ def cfg_args(parser): help="Device or group to connect to", action="store", type=str, + nargs="?", ) parser.add_argument( "--infile", help="Read commands from file", type=argparse.FileType("r") @@ -64,6 +67,7 @@ def grep_args(parser): help="Device or group to connect to", action="store", type=str, + nargs="?", ) @@ -109,11 +113,11 @@ def extract_cli_vars(cli_args, command, __version__): version = cli_args.version if version: print(f"{command} v{__version__}") - return 0 + sys.exit(0) list_devices = cli_args.list_devices if list_devices: my_devices = load_devices() display_inventory(my_devices) - return 0 + sys.exit(0) return return_vars diff --git a/netmiko/cli_tools/fix.txt b/netmiko/cli_tools/fix.txt deleted file mode 100644 index 50697ed8b..000000000 --- a/netmiko/cli_tools/fix.txt +++ /dev/null @@ -1,2 +0,0 @@ -management api http-commands - no protocol https ssl profile diff --git a/netmiko/utilities.py b/netmiko/utilities.py index a7196fff2..c5009f4e0 100644 --- a/netmiko/utilities.py +++ b/netmiko/utilities.py @@ -167,6 +167,7 @@ def find_cfg_file( def display_inventory(my_devices: Dict[str, Union[List[str], Dict[str, Any]]]) -> None: """Print out inventory devices and groups.""" + config_params = my_devices.pop("__meta__", {}) # noqa inventory_groups = ["all"] inventory_devices = [] for k, v in my_devices.items():