python-ncclient/nexus-support.patch
2013-10-01 06:32:57 +00:00

111 lines
3.6 KiB
Diff

From cc429a1b83b65b4ab39d917774d34603473afcba Mon Sep 17 00:00:00 2001
From: envydd <ddutta@gmail.com>
Date: Mon, 8 Aug 2011 22:15:13 -0700
Subject: [PATCH 1/2] This commit has the changes required for ncclient to work
with the Nexus family of devices from Cisco
Conflicts:
ncclient/operations/rpc.py
ncclient/xml_.py
---
ncclient/operations/rpc.py | 9 ++++++++-
ncclient/xml_.py | 10 +++++++++-
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/ncclient/operations/rpc.py b/ncclient/operations/rpc.py
index a476e18..d30907b 100644
--- a/ncclient/operations/rpc.py
+++ b/ncclient/operations/rpc.py
@@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+# Debojyoti Dutta added some code for interoperability with Cisco's
+# Nexus family of switches. Tested with Nexus 7000 series.
+
from threading import Event, Lock
from uuid import uuid1
@@ -256,7 +259,11 @@ class RPC(object):
def _wrap(self, subele):
# internal use
- ele = new_ele("rpc", {"message-id": self._id})
+ ele = new_ele("rpc", {"message-id": self._id},
+ **{"xmlns":BASE_NS_1_0,
+ "xmlns:nxos":"http://www.cisco.com/nxos:1.0",
+ "xmlns:if":"http://www.cisco.com/nxos:1.0:if_manager"
+ })
ele.append(subele)
return to_xml(ele)
diff --git a/ncclient/xml_.py b/ncclient/xml_.py
index 9e94ef0..c22b0f1 100644
--- a/ncclient/xml_.py
+++ b/ncclient/xml_.py
@@ -13,6 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+# Debojyoti Dutta added some code for interoperability with Cisco's
+# Nexus family of switches. Tested with Nexus 7000 series.
+
"Methods for creating, parsing, and dealing with XML and ElementTree objects."
from cStringIO import StringIO
@@ -29,6 +32,10 @@ class XMLError(NCClientError): pass
#: Base NETCONF namespace
BASE_NS_1_0 = "urn:ietf:params:xml:ns:netconf:base:1.0"
+# NXOS_1_0
+NXOS_1_0 = "http://www.cisco.com/nxos:1.0"
+# NXOS_IF
+NXOS_IF = "http://www.cisco.com/nxos:1.0:if_manager"
#: Namespace for Tail-f core data model
TAILF_AAA_1_1 = "http://tail-f.com/ns/aaa/1.1"
#: Namespace for Tail-f execd data model
@@ -51,6 +58,8 @@ register_namespace.func_doc = "ElementTree's namespace map determines the prefix
for (ns, pre) in {
BASE_NS_1_0: 'nc',
+ NXOS_1_0: 'nxos',
+ NXOS_IF: 'if',
TAILF_AAA_1_1: 'aaa',
TAILF_EXECD_1_1: 'execd',
CISCO_CPI_1_0: 'cpi',
@@ -105,4 +114,3 @@ def validated_element(x, tags=None, attrs=None):
new_ele = lambda tag, attrs={}, **extra: ET.Element(qualify(tag), attrs, **extra)
sub_ele = lambda parent, tag, attrs={}, **extra: ET.SubElement(parent, qualify(tag), attrs, **extra)
-
--
1.8.1.4
From 71aa03550d34ec45983ec2ceab821a73f7b8278e Mon Sep 17 00:00:00 2001
From: Edgar Magana <emagana@gmail.com>
Date: Thu, 24 May 2012 14:56:53 -0700
Subject: [PATCH 2/2] Changing the subsystem from netconf to xmlagent
---
ncclient/transport/ssh.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ncclient/transport/ssh.py b/ncclient/transport/ssh.py
index 14082da..886ac91 100644
--- a/ncclient/transport/ssh.py
+++ b/ncclient/transport/ssh.py
@@ -204,8 +204,8 @@ class SSHSession(Session):
self._connected = True # there was no error authenticating
c = self._channel = self._transport.open_session()
- c.set_name("netconf")
- c.invoke_subsystem("netconf")
+ c.set_name("xmlagent")
+ c.invoke_subsystem("xmlagent")
self._post_connect()
--
1.8.1.4