Return "Request contains invalid special characters" while using commands with "|"
z-8-d opened this issue · 2 comments
Hi guys, hope everything finds you good.
I'm trying to use nornir
to run show running-config | grep -v ^!
to get the running configs without annotations. My code is more like:
nr = InitNornir(runner=runner, inventory=inventory, logging=nornir_logging)
cmds = ['show running-config | grep -v ^!']
nr.run(
name=f'Running commands of {cmds}.',
task=napalm_cli,
commands=cmds,
)
But got: "Request contains invalid special characters"
. I've checked and found this:
This situation occurs because the Sandbox parses each command in a JSON RPC request as individual items and assigns an ID to each. When using JSON RPC requests, you cannot use internal punctuation to separate multiple commands on the same line. Instead, enter each command on a separate line and the request completes sucessfully.
Would you please help me that how could I use json
requests in nornir_napalm
? Or is there any other way that I could get what show running-config | grep -v ^!
get without using any invalid syntax?
Thanks a lot!
Which napalm
platform are you using?
You probably would need to use nxos_ssh
for the NAPALM platform.
My guess is you are trying to use nxos
for the NAPALM platform (which under the hood uses nx-api
and nx-api
does not allow that).
Also it is very likely better for you to just do the string processing in Python and not at the network OS CLI level.
In other words, in the long run you will probably run into fewer issues if you just execution show running-config
(or better yet NAPALM's get_config()
method and then do any additional string processing after the fact in Python.
Thanks for your explanation!
Which napalm platform are you using?
You probably would need to use nxos_ssh for the NAPALM platform.
My guess is you are trying to use nxos for the NAPALM platform (which under the hood uses nx-api and nx-api does not allow that).
Yes, I'm using nx-api
. Then seems the string processing in Python would be a better choice.
Closing due to problem solved.