rajneeshaec / ncclient

Automatically exported from code.google.com/p/ncclient
Apache License 2.0
0 stars 1 forks source link

Juniper interoperability #11

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. connect to Juniper device
2. print device capabilities
3.

What is the expected output? What do you see instead?
Devices capabilites are expected but script hungs.

What version of the product are you using? On what operating system?
0.3.1 on Debian Sid (amd64), python 2.6.6

After debugging I've found that in HelloHandler callback tag isn't equal to 
qualify("hello"): hello != {urn:ietf:params:xml:ns:netconf:base:1.0}hello.

Device hello message:

<!-- No zombies were killed during the creation of this user interface -->
<!-- user remote, class j-super-user -->
<hello>
  <capabilities>
    <capability>urn:ietf:params:xml:ns:netconf:base:1.0</capability>
    <capability>urn:ietf:params:xml:ns:netconf:capability:candidate:1.0</capability>
    <capability>urn:ietf:params:xml:ns:netconf:capability:confirmed-commit:1.0</capability>
    <capability>urn:ietf:params:xml:ns:netconf:capability:validate:1.0</capability>
    <capability>urn:ietf:params:xml:ns:netconf:capability:url:1.0?protocol=http,ftp,file</capability>
    <capability>http://xml.juniper.net/netconf/junos/1.0</capability>
    <capability>http://xml.juniper.net/dmi/system/1.0</capability>
  </capabilities>
  <session-id>25188</session-id>
</hello>

Original issue reported on code.google.com by mar...@kucharczyk.im on 8 Apr 2011 at 8:41

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
While section 3.1 of RFC4741 states all protocol elements are to be defined in 
the urn:ietf:params:xml:ns:netconf:base:1.0 namespace.  Neither JUNOS or IOS 
include the xmlns in the hello element.  This appears to come down to RFC 
interpretation and the reason that tail-f is functional w/ ncclient lays in 
qualify when setting a base namespace.

-qualify = lambda tag, ns=BASE_NS_1_0: tag if ns is None else "{%s}%s" % (ns, 
tag)
+qualify = lambda tag, ns=BASE_NS_1_0: tag if ns is None else "%s" % (tag)

$ python nc01.py r1
http://xml.juniper.net/dmi/system/1.0
urn:ietf:params:xml:ns:netconf:capability:confirmed-commit:1.0
http://xml.juniper.net/netconf/junos/1.0
urn:ietf:params:xml:ns:netconf:capability:validate:1.0
urn:ietf:params:xml:ns:netconf:capability:candidate:1.0
urn:ietf:params:xml:ns:netconf:capability:url:1.0?protocol=http,ftp,file
urn:ietf:params:xml:ns:netconf:base:1.0

it is however included in further protocol elements (ie. <rpc-reply>)

<rpc><get-software-information/></rpc>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" 
xmlns:junos="http://xml.juniper.net/junos/10.4R2/junos">

Original comment by ebben.ar...@gmail.com on 11 May 2011 at 6:26

GoogleCodeExporter commented 8 years ago
Thanks, change in qualify method helped. Now I have another problem. I was 
trying to get device running config (example/nc02.py) and I got 2 errors:

ERROR:ncclient.transport.session:error parsing dispatch message: duplicate 
attribute: line 1, column 174

and after a while exception occurs:

DEBUG:ncclient.transport.ssh:Broke out of main loop, 
error=SessionCloseError('Unexpected session close\nIN_BUFFER: `\n<!-- session 
end at 2011-05-12 11:08:05 UTC -->\n`',)
DEBUG:ncclient.transport.ssh:EOF in transport thread
DEBUG:ncclient.transport.session:dispatching error to 
<ncclient.operations.rpc.RPCReplyListener object at 0x237f3d0>
Traceback (most recent call last):
  File "examples/nc02.py", line 19, in <module>
    demo(sys.argv[1], os.getenv("USER"))
  File "examples/nc02.py", line 16, in demo
    f.write(c)
  File "/usr/local/lib/python2.6/dist-packages/ncclient/manager.py", line 113, in __exit__
    self.close_session()
  File "/usr/local/lib/python2.6/dist-packages/ncclient/manager.py", line 76, in wrapper
    return self.execute(op_cls, *args, **kwds)
  File "/usr/local/lib/python2.6/dist-packages/ncclient/manager.py", line 130, in execute
    raise_mode=self._raise_mode).request(*args, **kwds)
  File "/usr/local/lib/python2.6/dist-packages/ncclient/operations/session.py", line 28, in request
    return self._request(new_ele("close-session"))
  File "/usr/local/lib/python2.6/dist-packages/ncclient/operations/rpc.py", line 284, in _request
    raise self._error
ncclient.transport.errors.SessionCloseError: Unexpected session close
IN_BUFFER: `
<!-- session end at 2011-05-12 11:08:05 UTC -->
`

I've atteched manualy downloaded config XML. I've removed some sensitive data, 
but file is still valid in XML sense.

Original comment by mar...@kucharczyk.im on 12 May 2011 at 11:09

Attachments:

GoogleCodeExporter commented 8 years ago
I show this same issue, ncclient hangs when connecting to Juniper devices.
I'll try with the modifications

Original comment by br...@brentrjones.com on 25 Jan 2012 at 7:33

GoogleCodeExporter commented 8 years ago
There is ncclient fork: https://github.com/leopoul/ncclient/tree/dev_junos 
which supports Juniper devices.

Original comment by mar...@kucharczyk.im on 25 Jan 2012 at 10:17

GoogleCodeExporter commented 8 years ago
Same issue here on JunOS 9.3R4.4.. would be nice to see official support for 
JunOS & IOS devices in ncclient.

Original comment by mde...@gmail.com on 5 Apr 2012 at 4:09

GoogleCodeExporter commented 8 years ago
Hi all,
I'm now the official maintainer of ncclient. I just pushed an experimental 
commit that gets rid of namespaces. I know it's not according to the RFC, but 
you can handle issues where the vendors namespaces' do not comply with the RFC.

https://github.com/leopoul/ncclient/tree/experimental

PS. In latest stable version (0.3.2) I have added support for Juniper devices

Original comment by leonida...@gmail.com on 27 Apr 2012 at 3:28

GoogleCodeExporter commented 8 years ago
Hi, I dont see a good documentation on playing with JUNOS devices, i can only 
run nc01.py and nc02.py in examples against a JUNOS device, can some one help 
with more examples how to get system uptime etc?

Original comment by shabbir1...@gmail.com on 28 Apr 2013 at 9:38

GoogleCodeExporter commented 8 years ago
see the following fork at https://github.com/earies/ncclient

It is forked from leopoul/ncclient with added Junos support + lxml for greater 
use of xpath parsing

Original comment by ebben.ar...@gmail.com on 10 May 2013 at 6:14