Skip to content

Commit

Permalink
Merge pull request #9 from timeforplanb123/update_error_messages
Browse files Browse the repository at this point in the history
Update error messages
  • Loading branch information
timeforplanb123 authored Dec 11, 2023
2 parents 2af4c09 + 98c619c commit 7f7376b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 5 deletions.
12 changes: 9 additions & 3 deletions nornir_cli/common_commands/cmd_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,22 @@
"Filter optiions. There should be something like...\n\n"
"Simple filtering:\n"
" nornir_cli nornir-netmiko <init> filter site=cmh role=spine\n\n"
"Or:\n"
' nornir_cli nornir-netmiko <init> filter \'{"name":"spine_1"}\'\n\n'
"Simple filtering with json:\n"
" nornir_cli nornir-netmiko <init> filter --hosts "
'\'primary_ip={"address": "10.1.129.71/32", "family": 4, "id": 4482, '
'\'primary_ip={"address": "10.1.10.10/32", "family": 4, "id": 4482, '
'"url": "http://netbox-domain/api/ipam/ip-addresses/4482/"} name=spine_1\'\n\n'
"The same:\n"
" nornir_cli nornir-netmiko <init> filter --hosts "
'\'{"primary_ip":{"address": "10.1.10.10/32", "family": 4, "id": 4482, '
'"url": "http://netbox-domain/api/ipam/ip-addresses/4482/"}, "name":"spine_1"}\'\n\n'
"Advanced filtering:\n"
" nornir_cli nornir-netmiko <init> filter -a "
"'name__contains=cmh device_role__name__contains=access'\n"
"'name__contains=cmh device_role__name__contains=access'\n\n"
"The same:\n"
" nornir_cli nornir-netmiko <init> filter -a "
"'name__contains=cmh & device_role__name__contains=access'\n"
"'name__contains=cmh & device_role__name__contains=access'\n\n"
"Or:\n"
" nornir_cli nornir-netmiko <init> filter -a "
"'name__contains=cmh | name__contains=access'\n\n"
Expand Down
12 changes: 11 additions & 1 deletion nornir_cli/common_commands/cmd_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,20 @@
'"/home/user/inventory/hosts.yaml", "group_file": '
'"/home/user/inventory/groups.yaml", '
'"defaults_file": "/home/user/inventory/defaults.yaml"}}\'\n\n'
"The same:\n"
' nornir_cli nornir-scrapli init -c "" -f '
'\'{"inventory":{"plugin":"SimpleInventory",options": {"host_file": '
'"/home/user/inventory/hosts.yaml", "group_file": '
'"/home/user/inventory/groups.yaml", '
'"defaults_file": "/home/user/inventory/defaults.yaml"}}}\'\n\n'
"With combination of both methods:\n"
' nornir_cli nornir-napalm init -f \'logging={"enabled": true, "level":'
'"DEBUG",'
'"to_console": false}'
'"to_console": false}\'\n\n'
"The same:\n"
' nornir_cli nornir-napalm init -f \'{"logging":{"enabled": true, "level":'
'"DEBUG",'
'"to_console": false}}\''
)


Expand Down
22 changes: 21 additions & 1 deletion nornir_cli/plugin_commands/cmd_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,27 @@
from tqdm import tqdm


ERROR_MESSAGE = "error"
ERROR_MESSAGE = (
"Nornir plugin options and arguments.\n"
"Check the required options and the command format"
"(use json syntax for arguments).\n"
"There should be something like...\n\n"
"Only with required options:\n"
' nornir_cli nornir-netmiko netmiko_send_command --command_string "disp clock"\n\n'
"Only with required options as an arguments(json-string):\n"
" nornir_cli nornir-netmiko netmiko_send_command "
'\'{"command_string":"disp clock"}\'\n\n'
"With required options and arguments(json-string). The priority of options will be "
'higher, the command "disp ver" will be executed:\n'
" nornir_cli nornir-netmiko netmiko_send_command "
'--command_string "disp ver" '
'\'{"command_string":"disp clock"}\'\n\n'
'With required options and arguments(json-string). The command "disp ver" '
'will be executed with the "read_timeout" argument:\n'
" nornir_cli nornir-netmiko netmiko_send_command "
'--command_string "disp ver" '
"'{\"read_timeout\":11.0}'"
)


@click.pass_context
Expand Down

0 comments on commit 7f7376b

Please sign in to comment.