rollback configuration

181 views
Skip to first unread message

Noah Wallach

unread,
Aug 14, 2014, 3:35:37 AM8/14/14
to junos-p...@googlegroups.com
I am trying to rollback the configuration with the ncclient, and its failing and not sure why.  I am running JUNOS 10.4

here are the relevant lines of code:

--- snip ---

    if (exclusive):
            conn.lock()
        rpc = '''
<rpc>
   <load-configuration rollback="1"/>
</rpc>
'''
        result = conn.rpc(rpc)
        conn.commit()
        if (exclusive):
            conn.unlock()

    conn.close_session()

--- snip ---

here is the trace:

--- snip ---

Traceback (most recent call last):
  File "./push.py", line 191, in <module>
    connect(hostname, user, password)
  File "./push.py", line 183, in connect
    conn.commit()
  File "/usr/local/lib/python2.7/site-packages/ncclient/manager.py", line 107, in wrapper
    return self.execute(op_cls, *args, **kwds)
  File "/usr/local/lib/python2.7/site-packages/ncclient/manager.py", line 174, in execute
    raise_mode=self._raise_mode).request(*args, **kwds)
  File "/usr/local/lib/python2.7/site-packages/ncclient/operations/edit.py", line 145, in request
    return self._request(node)
  File "/usr/local/lib/python2.7/site-packages/ncclient/operations/rpc.py", line 291, in _request
    self._session.send(req)
  File "/usr/local/lib/python2.7/site-packages/ncclient/transport/session.py", line 146, in send
    raise TransportError('Not connected to NETCONF server')
ncclient.transport.errors.TransportError: Not connected to NETCONF server

--- snip ---

NitinKumar

unread,
Aug 14, 2014, 8:35:17 AM8/14/14
to Noah Wallach, junos-p...@googlegroups.com
Noah,

While using ncclient conn.rpc, we are not supposed to pass <rpc> tag.

Hence your rpc variable need to be:
rpc = """<load-configuration rollback="1"/>"""

Or 
rpc = "<load-configuration rollback='1'/>"

With this rpc your code will work perfectly fine. Hope that helps.

Thanks
Nitin Kr

--
You received this message because you are subscribed to the Google Groups "Junos Python EZ" group.
To unsubscribe from this group and stop receiving emails from it, send an email to junos-python-...@googlegroups.com.
Visit this group at http://groups.google.com/group/junos-python-ez.
To view this discussion on the web visit https://groups.google.com/d/msgid/junos-python-ez/fb8cb643-a104-4c39-9b8c-e7563512d611%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rick Sherman

unread,
Aug 14, 2014, 10:52:35 AM8/14/14
to junos-p...@googlegroups.com
Hi Noah,

This forum is for the support of Junos PyEZ, please keep ncclient questions related to extending PyEZ.

Our framework was specifically developed so that folks did not have to directly code for ncclient.

The way to do this in PyEZ is:

from jnpr.junos.utils.config import Config

cu = Config(dev)

cu.rollback()


Thanks,
-Rick

Noah Wallach

unread,
Aug 14, 2014, 2:31:06 PM8/14/14
to junos-p...@googlegroups.com
Hi Rick,

where is a good place to present my ncclient questions related to interfacing with JUNOS?

Cheers

Noah Wallach

unread,
Aug 14, 2014, 2:50:29 PM8/14/14
to junos-p...@googlegroups.com
Rick,

are there more coding examples than just what I am finding in the py-junos-eznc github repo?  The reason why I've been staying with the ncclient is because there is a larger variety of examples out there.  I am kinda lost on how to do certain things with the Junos PyEZ framework.  Let me put together the list.

Cheers

Noah Wallach

unread,
Aug 14, 2014, 4:02:07 PM8/14/14
to junos-p...@googlegroups.com
Hi there,

did netconf rollback functionality get added post 10.4?
rollback works with 12.1 but not the 10.4 version I am running.
weird.
 

Rick Sherman

unread,
Aug 20, 2014, 1:03:16 PM8/20/14
to junos-p...@googlegroups.com
Hi Noah,

It looks like you are hitting a known bug in 10.4 and was corrected in 11.4R1 and beyond.

I'd like to give another friendly reminder that 10.4 is End-of-Support.

The only workaround I can suggest is the following:

>>> cu.load(cmd,format='xml')
<Element load-configuration-results at 0x34f5d08>
>>>
>>> cu.pdiff()

[edit system scripts op]
+     file blah.slax;
-     file blah4.slax;

>>>
>>> dev.rpc.discard_changes()
<Element ok at 0x34fb2c8>
>>> cu.pdiff()
None


-Rick

Noah Garrett Wallach

unread,
Aug 20, 2014, 2:03:28 PM8/20/14
to junos-p...@googlegroups.com
Thanks Rick - I figured I was running into a limitation
and, yes, I know 10.4 is EOS
> --
> You received this message because you are subscribed to the Google
> Groups "Junos Python EZ" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to junos-python-...@googlegroups.com
> <mailto:junos-python-...@googlegroups.com>.
> Visit this group at http://groups.google.com/group/junos-python-ez.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/junos-python-ez/87c8068a-87b8-4e98-86a9-38232b95083e%40googlegroups.com
> <https://groups.google.com/d/msgid/junos-python-ez/87c8068a-87b8-4e98-86a9-38232b95083e%40googlegroups.com?utm_medium=email&utm_source=footer>.
Reply all
Reply to author
Forward
0 new messages