I'm using the Netmiko library to connect to devices and send new config commands via the "send_config_set" method. Currently, I am doing this on Cisco IOS devices only. But I am making something that will allow a user to enter any commands (with some exceptions) and so I am trying to understand how to interpret the output I get.
As I understand, Netmiko currently only returns the raw output. But what would be useful for me is to determine if something went wrong during the execution of those commands - maybe like a boolean flag?
For example, lets say I do this:
send_config_set(['abcd'])
The response I would get is:
config term
Enter configuration commands, one per line. End with CNTL/Z.
switch(config)#abcd
^
% Invalid input detected at '^' marker.
switch(config)#end
switch#
Clearly, in this case there was an error since the command was invalid. But Netmiko has no way to tell me that, it just gives the output and I guess wants me to decide.
I'm not a network engineer so I don't really know what the possible error outputs could be (i.e. what to look for in the response), I also don't know all the commands the user will try so can't account for everything.
What I did notice is when Cisco IOS appears to have some errors, they always seem to be starting with a % Invalid
or % Access
or something like that beginning with a % - so I wonder if that is enough for me to search the output for those and then set a flag myself to show an error was encountered? Maybe I can build a list of strings to look for in the output?
Although, I'm not convinced this is all that reliable and am keen to hear others opinions on the best way to do this.