Cisco Nexus 9000 Series Troubleshooting Manual page 90

Nx-os release 7.x
Hide thumbs Also See for Nexus 9000 Series:
Table of Contents

Advertisement

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

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents