Skip to content

Commit

Permalink
Fix --list-devices and --version in Netmiko CLI tools (#3519)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktbyers authored Oct 31, 2024
1 parent 43da87b commit e34b895
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
8 changes: 6 additions & 2 deletions netmiko/cli_tools/argument_handling.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
import argparse
from getpass import getpass
from netmiko.utilities import load_devices, display_inventory
Expand Down Expand Up @@ -38,6 +39,7 @@ def show_args(parser):
help="Device or group to connect to",
action="store",
type=str,
nargs="?",
)


Expand All @@ -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")
Expand All @@ -64,6 +67,7 @@ def grep_args(parser):
help="Device or group to connect to",
action="store",
type=str,
nargs="?",
)


Expand Down Expand Up @@ -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
2 changes: 0 additions & 2 deletions netmiko/cli_tools/fix.txt

This file was deleted.

1 change: 1 addition & 0 deletions netmiko/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit e34b895

Please sign in to comment.