ExampleSolutionSymptom
>>> cli('show clock')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'cli' is not defined
>>> from cli import *
>>> cli('show clock')
'20:23:33.967 UTC Fri Nov 01 2013\n'
Import the cli
module into the
global
namespace.
The Python cli API throws a
NameError.
>>> clid('show clock')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/isan/python/scripts/cli.py", line
45, in clid
raise
structured_output_not_supported_error(cmd)
errors.structured_output_not_supported_error:
'show clock'
Use the cli or
clip API. The
clid API works
only with
commands that
support
structured data
output.
The Python clid API throws a
structured_output_not_supported_error.
>>> from cli import *
>>> cli('clear counters')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/isan/python/scripts/cli.py", line
20, in cli
raise cmd_exec_error(msg)
errors.cmd_exec_error: '% Permission denied
for the role\n\nCmd exec error.\n'
>>> from cisco.interface import *
>>> i=Interface('Ethernet3/2')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/isan/python/scripts/cisco/interface.py",
line 75, in __new__
cls._Interfaces[name].config(True)
File
"/isan/python/scripts/cisco/interface.py",
line 91, in config
s, o = nxcli('show runn interface %s' %
self.name)
File "/isan/python/scripts/cisco/nxcli.py",
line 46, in nxcli
raise SyntaxError, 'Error status %d\n%s'
% (status, output)
SyntaxError: Error status 30
% Permission denied for the role
Cmd exec error.
>>> import os
>>> os.system('whoami')
test
Make sure your
login ID has
sufficient
permissions to
access the
command or
resource. If
necessary, ask
your network
administrator for
additional
permissions.
The cli API and cisco objects
throw a Permission denied error.
Make sure you
are using the
correct virtual
routing context.
If not, switch to
the correct one.
The urllib2 or socket connection
is not processed.
Cisco Nexus 9000 Series NX-OS Troubleshooting Guide, Release 7.x
78
Troubleshooting the Python API
Receiving Python API Errors