Skip to content

Commit

Permalink
Added ability to specify an alternate inventory file. Addresses issue k…
Browse files Browse the repository at this point in the history
…tbyers#7 in upstream netmiko_tools.
  • Loading branch information
rwwelford authored and Warren Welford committed Mar 16, 2017
1 parent 0c181af commit a9d7be4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
9 changes: 7 additions & 2 deletions netmiko_tools/netmiko-cfg
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ def parse_arguments(args):
parser.add_argument("--infile", help="Read commands from file", type=argparse.FileType('r'))
parser.add_argument("--cmd", help="Config command to execute",
action="store", default=None, type=str)
parser.add_argument("--invfile", help="Inventory File to use for processing",
action="store", default=None, type=str)
parser.add_argument("--list-devices", help="List devices from inventory", action="store_true")
parser.add_argument("--display-runtime", help="Display program runtime", action="store_true")
parser.add_argument("--hide-failed", help="Hide failed devices", action="store_true")
Expand All @@ -102,9 +104,12 @@ def main(args):
if version:
print("netmiko-cfg v{}".format(__version__))
return 0

cli_inv_filename = cli_args.invfile

list_devices = cli_args.list_devices
if list_devices:
my_devices = load_devices()
my_devices = load_devices(cli_inv_filename)
display_inventory(my_devices)
return 0

Expand All @@ -127,7 +132,7 @@ def main(args):
hide_failed = cli_args.hide_failed

output_q = Queue()
my_devices = load_devices()
my_devices = load_devices(cli_inv_filename)
if device_or_group == 'all':
device_group = obtain_all_devices(my_devices)
else:
Expand Down
9 changes: 7 additions & 2 deletions netmiko_tools/netmiko-grep
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ def parse_arguments(args):
action="store", type=str)
parser.add_argument("--cmd", help="Remote command to execute",
action="store", default=None, type=str)
parser.add_argument("--invfile", help="Inventory File to use for processing",
action="store", default=None, type=str)
# parser.add_argument("--username", help="Username", action="store", type=str)
# parser.add_argument("--password", help="Password", action="store", type=str)
parser.add_argument("--use-cache", help="Use cached files", action="store_true")
Expand All @@ -92,9 +94,12 @@ def main(args):
if version:
print("netmiko-grep v{}".format(__version__))
return 0

cli_inv_filename = cli_args.invfile

list_devices = cli_args.list_devices
if list_devices:
my_devices = load_devices()
my_devices = load_devices(cli_inv_filename)
display_inventory(my_devices)
return 0

Expand All @@ -108,7 +113,7 @@ def main(args):
hide_failed = cli_args.hide_failed

output_q = Queue()
my_devices = load_devices()
my_devices = load_devices(cli_inv_filename)
if device_or_group == 'all':
device_group = obtain_all_devices(my_devices)
else:
Expand Down
9 changes: 7 additions & 2 deletions netmiko_tools/netmiko-show
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ def parse_arguments(args):
action="store", type=str)
parser.add_argument("--cmd", help="Remote command to execute",
action="store", default=None, type=str)
parser.add_argument("--invfile", help="Inventory File to use for processing",
action="store", default=None, type=str)
parser.add_argument("--use-cache", help="Use cached files", action="store_true")
parser.add_argument("--list-devices", help="List devices from inventory", action="store_true")
parser.add_argument("--display-runtime", help="Display program runtime", action="store_true")
Expand All @@ -88,9 +90,12 @@ def main(args):
if version:
print("netmiko-show v{}".format(__version__))
return 0

cli_inv_filename = cli_args.invfile

list_devices = cli_args.list_devices
if list_devices:
my_devices = load_devices()
my_devices = load_devices(cli_inv_filename)
display_inventory(my_devices)
return 0

Expand All @@ -104,7 +109,7 @@ def main(args):
hide_failed = cli_args.hide_failed

output_q = Queue()
my_devices = load_devices()
my_devices = load_devices(cli_inv_filename)
if device_or_group == 'all':
device_group = obtain_all_devices(my_devices)
else:
Expand Down

0 comments on commit a9d7be4

Please sign in to comment.