diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 5c1a26dbf..da92bb139 100755 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -1,8 +1,13 @@ -## Release 2.7.1.dev0 - 12 JAN 2024 +## Release 2.7.2 - 12 APR 2024 ## Features Added ## Bugs Fixed +## Release 2.7.1 - 12 APR 2024 +## Features Added +- Added customer juniper paramiko module as a dependency which supported aes128 and aes257 cipher #1299 +## Bugs Fixed + ## Release 2.7.0 - 12 JAN 2024 ## Features Added - Support added for Python 3.10 and above version diff --git a/development.txt b/development.txt index f47e21ca4..24a995026 100644 --- a/development.txt +++ b/development.txt @@ -1,10 +1,9 @@ -r requirements.txt coverage # http://nedbatchelder.com/code/coverage/ -mock # http://www.voidspace.org.uk/python/mock/ nose2 # https://docs.nose2.io/en/latest/ pep8 # https://github.com/jcrocholl/pep8 pyflakes # https://launchpad.net/pyflakes coveralls # https://coveralls.io/ ntc_templates # user needs to explicitly install this -cryptography==3.2 \ No newline at end of file +cryptography==3.2 diff --git a/lib/jnpr/junos/cfg/phyport/base.py b/lib/jnpr/junos/cfg/phyport/base.py index b87ea7538..e018d8f65 100644 --- a/lib/jnpr/junos/cfg/phyport/base.py +++ b/lib/jnpr/junos/cfg/phyport/base.py @@ -6,7 +6,6 @@ class PhyPortBase(Resource): - """ [edit interfaces ] diff --git a/lib/jnpr/junos/cfg/user.py b/lib/jnpr/junos/cfg/user.py index 549b92ebf..7763d4aef 100644 --- a/lib/jnpr/junos/cfg/user.py +++ b/lib/jnpr/junos/cfg/user.py @@ -8,7 +8,6 @@ class User(Resource): - """ [edit system login user ] diff --git a/lib/jnpr/junos/cfg/user_ssh_key.py b/lib/jnpr/junos/cfg/user_ssh_key.py index bb3208c7c..f4010f34e 100644 --- a/lib/jnpr/junos/cfg/user_ssh_key.py +++ b/lib/jnpr/junos/cfg/user_ssh_key.py @@ -7,7 +7,6 @@ class UserSSHKey(Resource): - """ [edit system login user authentication ] diff --git a/lib/jnpr/junos/device.py b/lib/jnpr/junos/device.py index 8fec872c3..641806803 100644 --- a/lib/jnpr/junos/device.py +++ b/lib/jnpr/junos/device.py @@ -54,7 +54,6 @@ class _MyTemplateLoader(jinja2.BaseLoader): - """ Create a jinja2 template loader class that can be used to load templates from all over the filesystem, but defaults @@ -1023,7 +1022,6 @@ def __repr__(self): class DeviceSessionListener(SessionListener): - """ Listens to Session class of Netconf Transport and detects errors in the transport. @@ -1045,7 +1043,6 @@ def errback(self, ex): class Device(_Connection): - """ Junos Device class. diff --git a/lib/jnpr/junos/exception.py b/lib/jnpr/junos/exception.py index 3393d860d..b62b3d871 100644 --- a/lib/jnpr/junos/exception.py +++ b/lib/jnpr/junos/exception.py @@ -14,7 +14,6 @@ class FactLoopError(RuntimeError): class RpcError(Exception): - """ Parent class for all junos-pyez RPC Exceptions """ @@ -87,7 +86,6 @@ def __repr__(self): class CommitError(RpcError): - """ Generated in response to a commit-check or a commit action. """ @@ -107,7 +105,6 @@ def __repr__(self): class ConfigLoadError(RpcError): - """ Generated in response to a failure when loading a configuration. """ @@ -127,7 +124,6 @@ def __repr__(self): class LockError(RpcError): - """ Generated in response to attempting to take an exclusive lock on the configuration database. @@ -138,7 +134,6 @@ def __init__(self, rsp): class UnlockError(RpcError): - """ Generated in response to attempting to unlock the configuration database. @@ -149,7 +144,6 @@ def __init__(self, rsp): class PermissionError(RpcError): - """ Generated in response to invoking an RPC for which the auth user does not have user-class permissions. @@ -164,7 +158,6 @@ def __init__(self, rsp, cmd=None, errs=None): class RpcTimeoutError(RpcError): - """ Generated in response to a RPC execution timeout. """ @@ -181,7 +174,6 @@ def __repr__(self): class SwRollbackError(RpcError): - """ Generated in response to a SW rollback error. """ @@ -208,7 +200,6 @@ def __repr__(self): class ConnectError(Exception): - """ Parent class for all connection related exceptions """ @@ -249,7 +240,6 @@ def __repr__(self): class ProbeError(ConnectError): - """ Generated if auto_probe is enabled and the probe action fails """ @@ -258,7 +248,6 @@ class ProbeError(ConnectError): class ConnectAuthError(ConnectError): - """ Generated if the user-name, password is invalid """ @@ -267,7 +256,6 @@ class ConnectAuthError(ConnectError): class ConnectTimeoutError(ConnectError): - """ Generated if the NETCONF session fails to connect, could be due to the fact the device is not ip reachable; bad @@ -278,7 +266,6 @@ class ConnectTimeoutError(ConnectError): class ConnectUnknownHostError(ConnectError): - """ Generated if the specific hostname does not DNS resolve """ @@ -287,7 +274,6 @@ class ConnectUnknownHostError(ConnectError): class ConnectRefusedError(ConnectError): - """ Generated if the specified host denies the NETCONF; could be that the services is not enabled, or the host has @@ -298,7 +284,6 @@ class ConnectRefusedError(ConnectError): class ConnectNotMasterError(ConnectError): - """ Generated if the connection is made to a non-master routing-engine. This could be a backup RE on an MX @@ -309,7 +294,6 @@ class ConnectNotMasterError(ConnectError): class ConnectClosedError(ConnectError): - """ Generated if connection unexpectedly closed """ @@ -320,7 +304,6 @@ def __init__(self, dev): class JSONLoadError(Exception): - """ Generated if json content of rpc reply fails to load """ diff --git a/lib/jnpr/junos/factory/cmdview.py b/lib/jnpr/junos/factory/cmdview.py index b03cff8de..5ae8f3060 100644 --- a/lib/jnpr/junos/factory/cmdview.py +++ b/lib/jnpr/junos/factory/cmdview.py @@ -1,5 +1,4 @@ class CMDView(object): - """ View is the base-class that makes extracting values from XML data appear as objects with attributes. diff --git a/lib/jnpr/junos/factory/factory_loader.py b/lib/jnpr/junos/factory/factory_loader.py index a030a05eb..9e1d641cb 100644 --- a/lib/jnpr/junos/factory/factory_loader.py +++ b/lib/jnpr/junos/factory/factory_loader.py @@ -4,6 +4,7 @@ originate from any kind of source: YAML, JSON, program. For examples of YAML refer to the .yml files in this jnpr.junos.op directory. """ + # stdlib from copy import deepcopy import re @@ -29,7 +30,6 @@ class FactoryLoader(object): - """ Used to load a of data that contains Table and View definitions. diff --git a/lib/jnpr/junos/factory/state_machine.py b/lib/jnpr/junos/factory/state_machine.py index 7053b76dd..f49ffcec3 100644 --- a/lib/jnpr/junos/factory/state_machine.py +++ b/lib/jnpr/junos/factory/state_machine.py @@ -810,9 +810,9 @@ def parse_using_regex(self, event): val, result[list(self._view.REGEX.keys()).index(key)], re.I ) if obj and len(obj.groups()) >= 1: - result[ - list(self._view.REGEX.keys()).index(key) - ] = obj.groups()[0] + result[list(self._view.REGEX.keys()).index(key)] = ( + obj.groups()[0] + ) items = convert_to_data_type(result) tmp_dict = dict(zip(self._view.REGEX.keys(), items)) if len(tmp_dict) > 0: diff --git a/lib/jnpr/junos/factory/view.py b/lib/jnpr/junos/factory/view.py index 9e80309d9..e19d0a06d 100644 --- a/lib/jnpr/junos/factory/view.py +++ b/lib/jnpr/junos/factory/view.py @@ -11,7 +11,6 @@ class View(object): - """ View is the base-class that makes extracting values from XML data appear as objects with attributes. diff --git a/lib/jnpr/junos/factory/viewfields.py b/lib/jnpr/junos/factory/viewfields.py index f774fbea9..c61d9e0b8 100644 --- a/lib/jnpr/junos/factory/viewfields.py +++ b/lib/jnpr/junos/factory/viewfields.py @@ -1,5 +1,4 @@ class ViewFields(object): - """ Used to dynamically create a field dictionary used with the RunstatView class diff --git a/lib/jnpr/junos/facts/__init__.py b/lib/jnpr/junos/facts/__init__.py index 821a7b595..7ac4317ae 100644 --- a/lib/jnpr/junos/facts/__init__.py +++ b/lib/jnpr/junos/facts/__init__.py @@ -31,6 +31,7 @@ The following dictionary keys represent the available facts and their meaning: """ + import sys import jnpr.junos.facts.current_re diff --git a/lib/jnpr/junos/ofacts/session.py b/lib/jnpr/junos/ofacts/session.py index 278f5f26b..f857021af 100644 --- a/lib/jnpr/junos/ofacts/session.py +++ b/lib/jnpr/junos/ofacts/session.py @@ -1,6 +1,7 @@ """ facts['HOME'] = login home directory """ + from lxml.builder import E diff --git a/lib/jnpr/junos/resources/autosys.py b/lib/jnpr/junos/resources/autosys.py index 7605c828d..4911ad530 100644 --- a/lib/jnpr/junos/resources/autosys.py +++ b/lib/jnpr/junos/resources/autosys.py @@ -1,6 +1,7 @@ """ Pythonifier for AutoSys Table/View """ + from jnpr.junos.factory import loadyaml from os.path import splitext diff --git a/lib/jnpr/junos/resources/bgp.py b/lib/jnpr/junos/resources/bgp.py index 1e4969f55..c8b3474bf 100644 --- a/lib/jnpr/junos/resources/bgp.py +++ b/lib/jnpr/junos/resources/bgp.py @@ -1,6 +1,7 @@ """ Pythonifier for BGP Table/View """ + from jnpr.junos.factory import loadyaml from os.path import splitext diff --git a/lib/jnpr/junos/resources/interface.py b/lib/jnpr/junos/resources/interface.py index 60ef76fe0..6b58a2541 100644 --- a/lib/jnpr/junos/resources/interface.py +++ b/lib/jnpr/junos/resources/interface.py @@ -1,6 +1,7 @@ """ Pythonifier for interface table/view """ + from jnpr.junos.factory import loadyaml from os.path import splitext diff --git a/lib/jnpr/junos/resources/staticroutes.py b/lib/jnpr/junos/resources/staticroutes.py index 5f4efc4a4..fdd0d650b 100644 --- a/lib/jnpr/junos/resources/staticroutes.py +++ b/lib/jnpr/junos/resources/staticroutes.py @@ -1,6 +1,7 @@ """ Pythonifier for Static route Table/View """ + from jnpr.junos.factory import loadyaml from os.path import splitext diff --git a/lib/jnpr/junos/resources/syslog.py b/lib/jnpr/junos/resources/syslog.py index f886efe77..76601d167 100644 --- a/lib/jnpr/junos/resources/syslog.py +++ b/lib/jnpr/junos/resources/syslog.py @@ -1,6 +1,7 @@ """ Pythonifier for Syslog Table/View """ + from jnpr.junos.factory import loadyaml from os.path import splitext diff --git a/lib/jnpr/junos/resources/user.py b/lib/jnpr/junos/resources/user.py index 78568e722..8532b40c2 100644 --- a/lib/jnpr/junos/resources/user.py +++ b/lib/jnpr/junos/resources/user.py @@ -1,6 +1,7 @@ """ Pythonifier for User Table/View """ + from jnpr.junos.factory import loadyaml from os.path import splitext diff --git a/lib/jnpr/junos/transport/tty.py b/lib/jnpr/junos/transport/tty.py index 9fce52f0a..5d080aab8 100644 --- a/lib/jnpr/junos/transport/tty.py +++ b/lib/jnpr/junos/transport/tty.py @@ -14,7 +14,6 @@ class Terminal(object): - """ Terminal is used to bootstrap Junos New Out of the Box (NOOB) device over the CONSOLE port. The general use-case is to setup the minimal diff --git a/lib/jnpr/junos/transport/tty_netconf.py b/lib/jnpr/junos/transport/tty_netconf.py index ceac91be5..1d5133de4 100644 --- a/lib/jnpr/junos/transport/tty_netconf.py +++ b/lib/jnpr/junos/transport/tty_netconf.py @@ -38,7 +38,6 @@ class PY6: class tty_netconf(object): - """ Basic Junos XML API for bootstraping through the TTY """ diff --git a/lib/jnpr/junos/utils/fs.py b/lib/jnpr/junos/utils/fs.py index 6d56bb5b6..fd31ec887 100644 --- a/lib/jnpr/junos/utils/fs.py +++ b/lib/jnpr/junos/utils/fs.py @@ -7,7 +7,6 @@ class FS(Util): - """ Filesystem (FS) utilities: diff --git a/lib/jnpr/junos/utils/start_shell.py b/lib/jnpr/junos/utils/start_shell.py index cef26eddc..f6ac93565 100644 --- a/lib/jnpr/junos/utils/start_shell.py +++ b/lib/jnpr/junos/utils/start_shell.py @@ -14,7 +14,6 @@ class StartShell(object): - """ Junos shell execution utility. This utility is written to support the "context manager" design pattern. For example:: diff --git a/lib/jnpr/junos/utils/sw.py b/lib/jnpr/junos/utils/sw.py index 43a76c436..c9e42f58e 100644 --- a/lib/jnpr/junos/utils/sw.py +++ b/lib/jnpr/junos/utils/sw.py @@ -1208,6 +1208,16 @@ def reboot( :returns: * reboot message (string) if command successful """ + + if self._multi_VC_nsync is True or self._multi_VC is True: + vc_members = [ + re.search(r"(\d+)", x).group(1) + for x in self._RE_list + if re.search(r"(\d+)", x) + ] + vc_members.remove(self.dev.facts["vc_master"]) + vc_members.insert(len(vc_members), self.dev.facts["vc_master"]) + if self._dev.facts["_is_linux"]: if on_node is None: cmd = E("request-shutdown-reboot") @@ -1220,9 +1230,14 @@ def reboot( cmd = E("request-reboot") try: - return self._system_operation( - cmd, in_min, at, all_re, other_re, vmhost, member_id - ) + if member_id is not None: + for m_id in member_id: + if m_id in vc_members: + return self._system_operation( + cmd, in_min, at, all_re, other_re, vmhost, member_id=m_id + ) + else: + return self._system_operation(cmd, in_min, at, all_re, other_re, vmhost) except RpcTimeoutError as err: raise err except Exception as err: diff --git a/lib/jnpr/junos/version.py b/lib/jnpr/junos/version.py index 098dac23c..6492f3d25 100644 --- a/lib/jnpr/junos/version.py +++ b/lib/jnpr/junos/version.py @@ -1,5 +1,5 @@ -VERSION = "2.7.1.dev0" -DATE = "2024-Jan-12" +VERSION = "2.7.2.dev0" +DATE = "2024-Apr-12" # Augment with the internal version if present try: diff --git a/requirements.txt b/requirements.txt index c18bc21d0..c318527ec 100755 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,6 @@ lxml>=3.2.4 # ncclient version 0.6.10 has issues with PyEZ(junos-eznc) and needs to be avoided ncclient>=0.6.15 -paramiko>=1.15.2 scp>=0.7.0 jinja2>=2.7.1 PyYAML>=5.1 diff --git a/setup.py b/setup.py index 9971110f7..981a023d1 100755 --- a/setup.py +++ b/setup.py @@ -1,6 +1,9 @@ from setuptools import setup, find_packages import versioneer +import os +# Install customer paramiko +os.system("pip install git+https://github.com/Juniper/paramiko.git@v3.4.0-JNPR") # parse requirements req_lines = [line.strip() for line in open("requirements.txt").readlines()] install_reqs = list(filter(None, req_lines)) diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py index dd3388c69..1f868a92a 100644 --- a/tests/unit/__init__.py +++ b/tests/unit/__init__.py @@ -2,7 +2,7 @@ import sys import nose2 -from mock import patch +from unittest.mock import patch __author__ = "Nitin Kumar" __credits__ = "Jeremy Schulman" diff --git a/tests/unit/factory/test_cfgtable.py b/tests/unit/factory/test_cfgtable.py index 0ff618fde..9f15b4f45 100644 --- a/tests/unit/factory/test_cfgtable.py +++ b/tests/unit/factory/test_cfgtable.py @@ -13,7 +13,7 @@ from ncclient.manager import Manager, make_device_handler from ncclient.transport import SSHSession from lxml import etree -from mock import MagicMock, patch +from unittest.mock import MagicMock, patch from jnpr.junos.factory import loadyaml from jnpr.junos.factory.factory_loader import FactoryLoader diff --git a/tests/unit/factory/test_cmdtable.py b/tests/unit/factory/test_cmdtable.py index 177c6e6a0..76ca90829 100644 --- a/tests/unit/factory/test_cmdtable.py +++ b/tests/unit/factory/test_cmdtable.py @@ -10,7 +10,7 @@ from ncclient.manager import Manager, make_device_handler from ncclient.transport import SSHSession -from mock import MagicMock, patch +from unittest.mock import MagicMock, patch import yamlordereddictloader from jnpr.junos.factory.factory_loader import FactoryLoader import yaml diff --git a/tests/unit/factory/test_factory_loader.py b/tests/unit/factory/test_factory_loader.py index 4a9ac1624..a13f0f0ad 100644 --- a/tests/unit/factory/test_factory_loader.py +++ b/tests/unit/factory/test_factory_loader.py @@ -4,7 +4,7 @@ import unittest import nose2 from jnpr.junos.factory import FactoryLoader -from mock import patch +from unittest.mock import patch class TestFactoryLoader(unittest.TestCase): diff --git a/tests/unit/factory/test_optable.py b/tests/unit/factory/test_optable.py index 0c516a7d7..d699ada1b 100644 --- a/tests/unit/factory/test_optable.py +++ b/tests/unit/factory/test_optable.py @@ -19,7 +19,7 @@ from lxml import etree -from mock import patch +from unittest.mock import patch class TestFactoryOpTable(unittest.TestCase): diff --git a/tests/unit/factory/test_table.py b/tests/unit/factory/test_table.py index 3bcb5c1a7..0b1ff4c16 100644 --- a/tests/unit/factory/test_table.py +++ b/tests/unit/factory/test_table.py @@ -8,7 +8,7 @@ from jnpr.junos import Device from jnpr.junos.factory.table import Table -from mock import patch +from unittest.mock import patch from lxml import etree from jnpr.junos.op.phyport import PhyPortTable diff --git a/tests/unit/factory/test_to_json.py b/tests/unit/factory/test_to_json.py index 8d9204c05..95a9db18b 100644 --- a/tests/unit/factory/test_to_json.py +++ b/tests/unit/factory/test_to_json.py @@ -5,7 +5,7 @@ except ImportError: import unittest import nose2 -from mock import patch +from unittest.mock import patch import os import json diff --git a/tests/unit/factory/test_view.py b/tests/unit/factory/test_view.py index 455e3171a..30d48a588 100644 --- a/tests/unit/factory/test_view.py +++ b/tests/unit/factory/test_view.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import MagicMock, patch +from unittest.mock import MagicMock, patch from jnpr.junos import Device from jnpr.junos.factory.view import View from jnpr.junos.op.phyport import PhyPortStatsTable, PhyPortStatsView diff --git a/tests/unit/facts/test_current_re.py b/tests/unit/facts/test_current_re.py index 3cc06eac9..085dc24f2 100644 --- a/tests/unit/facts/test_current_re.py +++ b/tests/unit/facts/test_current_re.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import patch, MagicMock +from unittest.mock import patch, MagicMock import os from lxml import etree diff --git a/tests/unit/facts/test_domain.py b/tests/unit/facts/test_domain.py index 4e46e1438..201d0fca0 100644 --- a/tests/unit/facts/test_domain.py +++ b/tests/unit/facts/test_domain.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import patch, MagicMock +from unittest.mock import patch, MagicMock import os from lxml import etree diff --git a/tests/unit/facts/test_ethernet_mac_table.py b/tests/unit/facts/test_ethernet_mac_table.py index 5e7be1e76..2dda45468 100644 --- a/tests/unit/facts/test_ethernet_mac_table.py +++ b/tests/unit/facts/test_ethernet_mac_table.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import patch, MagicMock +from unittest.mock import patch, MagicMock import os from lxml import etree diff --git a/tests/unit/facts/test_file_list.py b/tests/unit/facts/test_file_list.py index 7ed58f5cf..89d16c01b 100644 --- a/tests/unit/facts/test_file_list.py +++ b/tests/unit/facts/test_file_list.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import patch, MagicMock +from unittest.mock import patch, MagicMock import os from jnpr.junos import Device diff --git a/tests/unit/facts/test_get_chassis_cluster_status.py b/tests/unit/facts/test_get_chassis_cluster_status.py index 932c239c6..bebe589e3 100644 --- a/tests/unit/facts/test_get_chassis_cluster_status.py +++ b/tests/unit/facts/test_get_chassis_cluster_status.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import patch, MagicMock +from unittest.mock import patch, MagicMock import os from lxml import etree diff --git a/tests/unit/facts/test_get_chassis_inventory.py b/tests/unit/facts/test_get_chassis_inventory.py index 3c3dba240..81b981e07 100644 --- a/tests/unit/facts/test_get_chassis_inventory.py +++ b/tests/unit/facts/test_get_chassis_inventory.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import patch, MagicMock +from unittest.mock import patch, MagicMock import os from jnpr.junos import Device diff --git a/tests/unit/facts/test_get_route_engine_information.py b/tests/unit/facts/test_get_route_engine_information.py index 51c292559..2b607fa6c 100644 --- a/tests/unit/facts/test_get_route_engine_information.py +++ b/tests/unit/facts/test_get_route_engine_information.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import patch, MagicMock +from unittest.mock import patch, MagicMock import os from lxml import etree diff --git a/tests/unit/facts/test_get_software_information.py b/tests/unit/facts/test_get_software_information.py index 6e455da2b..12b69ce28 100644 --- a/tests/unit/facts/test_get_software_information.py +++ b/tests/unit/facts/test_get_software_information.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import patch, MagicMock +from unittest.mock import patch, MagicMock import os from lxml import etree diff --git a/tests/unit/facts/test_get_virtual_chassis_information.py b/tests/unit/facts/test_get_virtual_chassis_information.py index 2f13ccab1..e615c7a67 100644 --- a/tests/unit/facts/test_get_virtual_chassis_information.py +++ b/tests/unit/facts/test_get_virtual_chassis_information.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import patch, MagicMock +from unittest.mock import patch, MagicMock import os import sys from lxml import etree diff --git a/tests/unit/facts/test_ifd_style.py b/tests/unit/facts/test_ifd_style.py index ddcfe48de..4fab144e0 100644 --- a/tests/unit/facts/test_ifd_style.py +++ b/tests/unit/facts/test_ifd_style.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import patch, MagicMock +from unittest.mock import patch, MagicMock import os from lxml import etree diff --git a/tests/unit/facts/test_iri_mapping.py b/tests/unit/facts/test_iri_mapping.py index 66ba6ca44..d496db608 100644 --- a/tests/unit/facts/test_iri_mapping.py +++ b/tests/unit/facts/test_iri_mapping.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import patch, MagicMock +from unittest.mock import patch, MagicMock import os from jnpr.junos import Device diff --git a/tests/unit/facts/test_personality.py b/tests/unit/facts/test_personality.py index e152777d2..9e4df83f8 100644 --- a/tests/unit/facts/test_personality.py +++ b/tests/unit/facts/test_personality.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import patch, MagicMock +from unittest.mock import patch, MagicMock import os from jnpr.junos.exception import RpcError diff --git a/tests/unit/ofacts/test_chassis.py b/tests/unit/ofacts/test_chassis.py index d3f9beb62..351a23f93 100644 --- a/tests/unit/ofacts/test_chassis.py +++ b/tests/unit/ofacts/test_chassis.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import patch, MagicMock +from unittest.mock import patch, MagicMock from lxml import etree import os diff --git a/tests/unit/ofacts/test_domain.py b/tests/unit/ofacts/test_domain.py index 87c303432..21f91d516 100644 --- a/tests/unit/ofacts/test_domain.py +++ b/tests/unit/ofacts/test_domain.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import patch, MagicMock +from unittest.mock import patch, MagicMock from lxml import etree from jnpr.junos.ofacts.domain import facts_domain diff --git a/tests/unit/ofacts/test_ifd_style.py b/tests/unit/ofacts/test_ifd_style.py index d9ca28387..c664c803b 100644 --- a/tests/unit/ofacts/test_ifd_style.py +++ b/tests/unit/ofacts/test_ifd_style.py @@ -2,7 +2,7 @@ __credits__ = "Jeremy Schulman" import unittest -from mock import patch +from unittest.mock import patch import nose2 from jnpr.junos import Device diff --git a/tests/unit/ofacts/test_personality.py b/tests/unit/ofacts/test_personality.py index c37ee504c..85da1637e 100644 --- a/tests/unit/ofacts/test_personality.py +++ b/tests/unit/ofacts/test_personality.py @@ -2,7 +2,7 @@ __credits__ = "Jeremy Schulman" import unittest -from mock import patch +from unittest.mock import patch import nose2 from jnpr.junos import Device diff --git a/tests/unit/ofacts/test_routing_engines.py b/tests/unit/ofacts/test_routing_engines.py index a7f068205..a5d3bd488 100644 --- a/tests/unit/ofacts/test_routing_engines.py +++ b/tests/unit/ofacts/test_routing_engines.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import patch, MagicMock +from unittest.mock import patch, MagicMock import os import sys diff --git a/tests/unit/ofacts/test_srx_cluster.py b/tests/unit/ofacts/test_srx_cluster.py index ce07983b4..6832c9366 100644 --- a/tests/unit/ofacts/test_srx_cluster.py +++ b/tests/unit/ofacts/test_srx_cluster.py @@ -3,7 +3,7 @@ import unittest import nose2 -from mock import patch +from unittest.mock import patch import os from jnpr.junos import Device diff --git a/tests/unit/ofacts/test_switch_style.py b/tests/unit/ofacts/test_switch_style.py index 83dfcb5a8..4e4add378 100644 --- a/tests/unit/ofacts/test_switch_style.py +++ b/tests/unit/ofacts/test_switch_style.py @@ -2,7 +2,7 @@ __credits__ = "Jeremy Schulman" import unittest -from mock import patch +from unittest.mock import patch import nose2 from jnpr.junos import Device diff --git a/tests/unit/ofacts/test_swver.py b/tests/unit/ofacts/test_swver.py index 59e52fa07..65b36659b 100644 --- a/tests/unit/ofacts/test_swver.py +++ b/tests/unit/ofacts/test_swver.py @@ -6,7 +6,7 @@ except ImportError: import unittest import nose2 -from mock import patch, MagicMock +from unittest.mock import patch, MagicMock import os from jnpr.junos import Device diff --git a/tests/unit/test_console.py b/tests/unit/test_console.py index 3b8769715..de28e8cb3 100644 --- a/tests/unit/test_console.py +++ b/tests/unit/test_console.py @@ -4,7 +4,7 @@ import unittest from jnpr.junos.utils.config import Config import nose2 -from mock import patch, MagicMock, call +from unittest.mock import patch, MagicMock, call import re import sys import os diff --git a/tests/unit/test_decorators.py b/tests/unit/test_decorators.py index aefde05e4..aa9a0bb6a 100644 --- a/tests/unit/test_decorators.py +++ b/tests/unit/test_decorators.py @@ -12,7 +12,7 @@ from jnpr.junos.decorators import timeoutDecorator, normalizeDecorator from jnpr.junos.decorators import ignoreWarnDecorator -from mock import patch, MagicMock, PropertyMock, call +from unittest.mock import patch, MagicMock, PropertyMock, call from ncclient.operations.rpc import RPCError from ncclient.manager import Manager, make_device_handler diff --git a/tests/unit/test_device.py b/tests/unit/test_device.py index 3c8c6604f..1f8a97ebc 100644 --- a/tests/unit/test_device.py +++ b/tests/unit/test_device.py @@ -3,7 +3,7 @@ except ImportError: import unittest import nose2 -from mock import MagicMock, patch, mock_open, call +from unittest.mock import MagicMock, patch, mock_open, call import os from lxml import etree import sys diff --git a/tests/unit/test_factcache.py b/tests/unit/test_factcache.py index b173c39dd..7f63fed45 100644 --- a/tests/unit/test_factcache.py +++ b/tests/unit/test_factcache.py @@ -3,7 +3,7 @@ except ImportError: import unittest import nose2 -from mock import patch, MagicMock, call +from unittest.mock import patch, MagicMock, call from jnpr.junos.exception import FactLoopError from jnpr.junos import Device diff --git a/tests/unit/test_junos.py b/tests/unit/test_junos.py index ca1bde283..e72c6a5c8 100644 --- a/tests/unit/test_junos.py +++ b/tests/unit/test_junos.py @@ -4,7 +4,7 @@ import sys import nose2 -from mock import patch +from unittest.mock import patch __author__ = "Nitin Kumar" __credits__ = "Jeremy Schulman" diff --git a/tests/unit/test_jxml.py b/tests/unit/test_jxml.py index de4b893e4..26268f025 100644 --- a/tests/unit/test_jxml.py +++ b/tests/unit/test_jxml.py @@ -2,7 +2,7 @@ import unittest from io import StringIO import nose2 -from mock import patch +from unittest.mock import patch from jnpr.junos.jxml import ( NAME, INSERT, diff --git a/tests/unit/test_rpcmeta.py b/tests/unit/test_rpcmeta.py index 7b4f0579e..be91cee2c 100644 --- a/tests/unit/test_rpcmeta.py +++ b/tests/unit/test_rpcmeta.py @@ -10,7 +10,7 @@ from ncclient.transport import SSHSession from jnpr.junos.exception import JSONLoadError -from mock import patch, MagicMock, call +from unittest.mock import patch, MagicMock, call from lxml import etree __author__ = "Nitin Kumar, Rick Sherman" diff --git a/tests/unit/transport/test_serial.py b/tests/unit/transport/test_serial.py index 570213baf..310205737 100644 --- a/tests/unit/transport/test_serial.py +++ b/tests/unit/transport/test_serial.py @@ -3,7 +3,7 @@ except ImportError: import unittest import nose2 -from mock import MagicMock, patch +from unittest.mock import MagicMock, patch import sys import six diff --git a/tests/unit/transport/test_tty.py b/tests/unit/transport/test_tty.py index 520556e55..cf9bb6e42 100644 --- a/tests/unit/transport/test_tty.py +++ b/tests/unit/transport/test_tty.py @@ -6,7 +6,7 @@ import unittest import nose2 -from mock import MagicMock, patch +from unittest.mock import MagicMock, patch from jnpr.junos.transport.tty import Terminal from jnpr.junos import exception as EzErrors diff --git a/tests/unit/transport/test_tty_netconf.py b/tests/unit/transport/test_tty_netconf.py index 612d0164a..ba10bfa69 100644 --- a/tests/unit/transport/test_tty_netconf.py +++ b/tests/unit/transport/test_tty_netconf.py @@ -3,7 +3,7 @@ except ImportError: import unittest import nose2 -from mock import MagicMock, patch +from unittest.mock import MagicMock, patch from jnpr.junos.transport.tty_netconf import tty_netconf diff --git a/tests/unit/transport/test_tty_ssh.py b/tests/unit/transport/test_tty_ssh.py index 62729c7ac..8170081b4 100644 --- a/tests/unit/transport/test_tty_ssh.py +++ b/tests/unit/transport/test_tty_ssh.py @@ -6,7 +6,7 @@ except ImportError: import unittest import nose2 -from mock import MagicMock, patch +from unittest.mock import MagicMock, patch from jnpr.junos.transport.tty_ssh import SSH diff --git a/tests/unit/transport/test_tty_telnet.py b/tests/unit/transport/test_tty_telnet.py index 2030a61ff..1f7949325 100644 --- a/tests/unit/transport/test_tty_telnet.py +++ b/tests/unit/transport/test_tty_telnet.py @@ -5,7 +5,7 @@ except ImportError: import unittest import nose2 -from mock import MagicMock, patch +from unittest.mock import MagicMock, patch from jnpr.junos.transport.tty_telnet import Telnet import six diff --git a/tests/unit/utils/test_config.py b/tests/unit/utils/test_config.py index 2dbd69101..0ff7f2c7f 100644 --- a/tests/unit/utils/test_config.py +++ b/tests/unit/utils/test_config.py @@ -19,7 +19,7 @@ from ncclient.transport import SSHSession from ncclient.operations import RPCError, RPCReply -from mock import MagicMock, patch +from unittest.mock import MagicMock, patch from lxml import etree import os diff --git a/tests/unit/utils/test_fs.py b/tests/unit/utils/test_fs.py index bc03e623b..c6591f470 100644 --- a/tests/unit/utils/test_fs.py +++ b/tests/unit/utils/test_fs.py @@ -9,7 +9,7 @@ from jnpr.junos.utils.fs import FS from jnpr.junos.exception import RpcError -from mock import patch, MagicMock, call +from unittest.mock import patch, MagicMock, call from lxml import etree __author__ = "Nitin Kumar, Rick Sherman" diff --git a/tests/unit/utils/test_ftp.py b/tests/unit/utils/test_ftp.py index fcc0606e5..6623dbcc6 100644 --- a/tests/unit/utils/test_ftp.py +++ b/tests/unit/utils/test_ftp.py @@ -7,7 +7,7 @@ from jnpr.junos import Device import jnpr.junos.utils.ftp -from mock import patch +from unittest.mock import patch if sys.version < "3": builtin_string = "__builtin__" diff --git a/tests/unit/utils/test_scp.py b/tests/unit/utils/test_scp.py index 517e802ca..de8a3836c 100644 --- a/tests/unit/utils/test_scp.py +++ b/tests/unit/utils/test_scp.py @@ -8,7 +8,7 @@ from jnpr.junos import Device from jnpr.junos.utils.scp import SCP -from mock import patch +from unittest.mock import patch __author__ = "Rick Sherman, Nitin Kumar" __credits__ = "Jeremy Schulman" diff --git a/tests/unit/utils/test_start_shell.py b/tests/unit/utils/test_start_shell.py index 0034f2b3e..4f3ecd9e8 100644 --- a/tests/unit/utils/test_start_shell.py +++ b/tests/unit/utils/test_start_shell.py @@ -4,7 +4,7 @@ from jnpr.junos import Device from jnpr.junos.utils.start_shell import StartShell -from mock import patch, MagicMock, call +from unittest.mock import patch, MagicMock, call __author__ = "Rick Sherman" __credits__ = "Jeremy Schulman, Nitin Kumar" diff --git a/tests/unit/utils/test_sw.py b/tests/unit/utils/test_sw.py index 1f669b078..ad6cc773b 100644 --- a/tests/unit/utils/test_sw.py +++ b/tests/unit/utils/test_sw.py @@ -16,7 +16,7 @@ from ncclient.manager import Manager, make_device_handler from ncclient.transport import SSHSession from lxml import etree -from mock import patch, MagicMock, call, mock_open +from unittest.mock import patch, MagicMock, call, mock_open if sys.version < "3": builtin_string = "__builtin__" diff --git a/tests/unit/utils/test_util.py b/tests/unit/utils/test_util.py index 86f5cb644..0c5385a93 100644 --- a/tests/unit/utils/test_util.py +++ b/tests/unit/utils/test_util.py @@ -7,7 +7,7 @@ from jnpr.junos import Device from jnpr.junos.utils.util import Util -from mock import patch +from unittest.mock import patch class TestUtil(unittest.TestCase):