cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements

Community Helping Community

414
Views
5
Helpful
5
Replies

guestshell C9500 cli module NameError: global name 'log' is not defined

Hi all,

 

first time using iox guestshell and I've just gone into python and tried to use the cli module and am being returned the error below: I'm using 16.10.1 on a catalyst 9500 has anyone come across this before and know the fix?

 

[guestshell@guestshell ~]$ python
Python 2.7.5 (default, Apr 11 2018, 07:36:10)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from cli import *
>>> ios_version = cli("show version")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/cli/__init__.py", line 253, in cli
    response = pnp.listener.cli_exec_request(command)
  File "/usr/lib/python2.7/site-packages/pnp/_pnp.py", line 511, in cli_exec_request
    log(PNP_LOG_LEVEL_ERROR)
NameError: global name 'log' is not defined
>>>
Everyone's tags (2)
1 ACCEPTED SOLUTION

Accepted Solutions

Re: guestshell C9500 cli module NameError: global name 'log' is not defined

Anyone coming across this issue, it was resolved by enabling http server on the switch

 

 

conf t
ip http server

 

View solution in original post

5 REPLIES 5

Re: guestshell C9500 cli module NameError: global name 'log' is not defined

Anyone coming across this issue, it was resolved by enabling http server on the switch

 

 

conf t
ip http server

 

View solution in original post

Beginner

Re: guestshell C9500 cli module NameError: global name 'log' is not defined

Hi,

 

Just a doubt, instead http can i have https?

I mean just for security policies.

 

 

Highlighted
Cisco Employee

Re: guestshell C9500 cli module NameError: global name 'log' is not defined

Carlosormon,

If you want to use https, I recommend using "ip http secure-server" and it might be worth looking into "ip http authentication local" or something similar before secure-server command. Here is a link to a guide for more information.

https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/https/command/nm-https-cr-book/nm-https-cr-cl-sh.html

Regards,
Kyle

Beginner

Re: guestshell C9500 cli module NameError: global name 'log' is not defined

Hi ktuffent ,

 

Thank you so much for your help!!

 

I tried using this configuration. 

 

ip http authentication local

ip http secure-server

 

But it doesn't work. 

#  guestshell run python /flash/BACKUPS.py
Traceback (most recent call last):
  File "/flash/BACKUPS.py", line 13, in <module>
    print cli ('write')
  File "/usr/lib/python2.7/site-packages/cli/__init__.py", line 253, in cli
    response = pnp.listener.cli_exec_request(command)
  File "/usr/lib/python2.7/site-packages/pnp/_pnp.py", line 502, in cli_exec_request
    raise PnPParseError(str(perr))
pnp._pnp.PnPParseError: ParseError: Response is not xml parsable. mismatched tag: line 6, column 2

 

 

I mean when i use ip http server, it works.!! but we need to be secure and use https instead http.

 

Thank you very much!

 

Cisco Employee

Re: guestshell C9500 cli module NameError: global name 'log' is not defined

Guestshell needs the http server to be configured to communicate with IOS and execute the cli commands. Thats is why the error is seen when http server is not configured.

Currently https is not supported for communication

CreatePlease to create content
Content for Community-Ad
FusionCharts will render here