Skip to content

Commit

Permalink
Merge 4f85781 into fc5debc
Browse files Browse the repository at this point in the history
  • Loading branch information
rahkumar651991 committed Apr 22, 2021
2 parents fc5debc + 4f85781 commit 9bbafc3
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 13 deletions.
7 changes: 1 addition & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
language: python
matrix:
include:
- python: 2.7
dist: trusty
- python: 3.5
dist: trusty
- python: 3.6
dist: trusty
- python: 3.7
dist: xenial
- python: 3.8
Expand All @@ -21,6 +15,7 @@ matrix:
env:
- PATH=/c/Python37:/c/Python37/Scripts:$PATH
- TRAVIS_PYTHON_VERSION=3.7
- CRYPTOGRAPHY_DONT_BUILD_RUST=1
addons:
apt:
packages:
Expand Down
2 changes: 2 additions & 0 deletions lib/jnpr/junos/transport/tty.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ def login(self):
# now start NETCONF XML
logger.info("TTY: OK.....starting NETCONF")
self.nc.open(at_shell=self.at_shell)
self.session_id = self.nc._session_id

return True

def logout(self):
Expand Down
3 changes: 3 additions & 0 deletions lib/jnpr/junos/transport/tty_netconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from ncclient.operations.rpc import RPCReply, RPCError
from ncclient.xml_ import to_ele
import six
from ncclient.transport.session import HelloHandler


class PY6:
Expand Down Expand Up @@ -45,6 +46,7 @@ class tty_netconf(object):
def __init__(self, tty):
self._tty = tty
self.hello = None
self._session_id = -1

# -------------------------------------------------------------------------
# NETCONF session open and close
Expand All @@ -67,6 +69,7 @@ def open(self, at_shell):
raise RuntimeError("Error: netconf not responding")

self.hello = self._receive()
self._session_id, _ = HelloHandler.parse(self.hello.decode("utf-8"))

def close(self, force=False):
""" issue the XML API to close the session """
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
lxml>=3.2.4
ncclient>=0.6.3
# ncclient version 0.6.10 has issues with PyEZ(junos-eznc) and needs to be avoided
ncclient==0.6.9
paramiko>=1.15.2
scp>=0.7.0
jinja2>=2.7.1
Expand Down
6 changes: 1 addition & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"jnpr.junos.cfgro": ["*.yml"],
"jnpr.junos.resources": ["*.yml"],
},
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*",
python_requires=">=3.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*",
install_requires=install_reqs,
classifiers=[
"Development Status :: 5 - Production/Stable",
Expand All @@ -36,11 +36,7 @@
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Topic :: Software Development :: Libraries",
Expand Down
16 changes: 15 additions & 1 deletion tests/unit/transport/test_tty_netconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,21 @@ def setUp(self):

@patch("jnpr.junos.transport.tty_netconf.tty_netconf._receive")
def test_open_at_shell_true(self, mock_rcv):
mock_rcv.return_value = "]]>]]>"
mock_rcv.return_value = (
b""
b"<!-- user lab, class j-superuser -->"
b'<hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">'
b"<capabilities>"
b"<capability>urn:ietf:params:netconf:base:1.0</capability>"
b"<capability>urn:ietf:params:xml:ns:netconf:capability:validate:1.0</capability>"
b"<capability>urn:ietf:params:xml:ns:netconf:capability:url:1.0?scheme=http,ftp,file</capability>"
b"<capability>urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring</capability>"
b"<capability>http://xml.juniper.net/netconf/junos/1.0</capability>"
b"<capability>http://xml.juniper.net/dmi/system/1.0</capability>"
b"</capabilities>"
b"<session-id>82697</session-id>"
b"</hello>"
)
self.tty_net.open(True)
self.tty_net._tty.write.assert_called_with("xml-mode netconf need-trailer")

Expand Down

0 comments on commit 9bbafc3

Please sign in to comment.