Open pierky opened 6 years ago
Interesting... Could you send a PR, please?
Done #310
Just in case anyone else hits this error while running the napalm cli. There is a simple fix - optional args that are of a string value must be quoted:
This will throw an exception:
napalm --user vagrant --password vagrant --vendor junos --optional_args "ssh_config_file=spine_ssh_config" spine1 call get_bgp_neighbors
This will work:
napalm --user vagrant --password vagrant --vendor junos --optional_args "ssh_config_file='spine_ssh_config'" spine1 call get_bgp_neighbors
Notice that spine_ssh_config
is quoted.
As @pierky pointed out, this is related to ast.literal_eval()
. Specifically, the literal_eval
function is expecting a string that only consist of the following Python literal structures: strings, numbers, tuples, lists, dicts, booleans, and None.
See doc here.
So, in the case of the cli --optional_args
flag, it's looking for a string inside a string -- or an int
, depending on the arg you are dealing with.
Example:
--optional_args "ssh_config_file='spine_ssh_config'"
--optional_args "port=1234"
@ctopher78 FYI, this repository is deprecated. If you have issues or updates, you should make those against the main napalm repository.
Thanks @ktbyers. I'll see if this issue exists in that repo and submit a PR.
Hello,
I'm getting "ValueError: malformed string" when using
--optional_args
to connect to a device via telnet. I'm using the develop branches of both napalm-base (e21f10f5f26b02d15ed0e73fe4e6476638d991e7) and napalm-ios.I can make it work by removing the
ast.literal_eval()
call here: https://github.com/napalm-automation/napalm-base/blob/e21f10f5f26b02d15ed0e73fe4e6476638d991e7/napalm_base/clitools/helpers.py#L124-L125Python 2.7.6:
Python 3.4.0: