cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
765
Views
0
Helpful
2
Replies

NSO Maagic API add cmd 'ip http active-session-modules none'

jacurran
Cisco Employee
Cisco Employee

Hi,

 

I'm creating an automation to do automated healing of network device misconfigs.  One fix would be for an audit to be able to add back 'ip http active-session-modules none'.  I found one article that talked about using the .create() method but I end up with:

 

>>> with ncs.maapi.single_write_trans('XXXXX', 'python', groups=['XXXXXXXX']) as trans:
... root = ncs.maagic.get_root(t)
... device_cdb = root.devices.device["XXXXXXXXX"]
... device_cdb.config.ios__ip.http.active_session_modules.none.create()
... trans.apply()
...
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
File "/apps/nso/opt/ncs/current/src/ncs/pyapi/ncs/maagic.py", line 1017, in create
if not self._backend.exists(self._path):
File "/apps/nso/opt/ncs/current/src/ncs/pyapi/ncs/maapi.py", line 1175, in proxy
return real(self2.maapi, self2.th, *args, **kwargs)
File "/apps/nso/opt/ncs/current/src/ncs/pyapi/ncs/maapi.py", line 404, in exists
return True if _tm.maapi.exists(self.msock, th, path) else False
File "/usr/lib64/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
File "/usr/lib64/python2.7/socket.py", line 170, in _dummy
raise error(EBADF, 'Bad file descriptor')
socket.error: [Errno 9] Bad file descriptor
>>>

2 Replies 2

vleijon
Cisco Employee
Cisco Employee
You use “as trans” but then you attempt to get your root from t. You want to get_root(trans) I think.

Ah, yep, thank you.  I was cutting a pasting from a few different parts of my project.  Some parts I use "t", some "trans".  That solved the issue!