[Python-modules-commits] [napalm-iosxr] 01/03: New upstream release.
Vincent Bernat
bernat at moszumanska.debian.org
Tue Nov 14 09:51:24 UTC 2017
This is an automated email from the git hooks/post-receive script.
bernat pushed a commit to annotated tag debian/0.5.6-1
in repository napalm-iosxr.
commit 72e1b9cf9238d22ac4ad4e827fc02efabe214239
Author: Vincent Bernat <bernat at debian.org>
Date: Tue Nov 14 10:49:48 2017 +0100
New upstream release.
---
PKG-INFO | 2 +-
napalm_iosxr.egg-info/PKG-INFO | 2 +-
napalm_iosxr.egg-info/SOURCES.txt | 9 +--
napalm_iosxr.egg-info/requires.txt | 6 +-
napalm_iosxr.egg-info/top_level.txt | 1 -
napalm_iosxr/iosxr.py | 143 ++++++++++++++++++++++++---------
napalm_iosxr/templates/delete_users.j2 | 13 +++
napalm_iosxr/templates/set_users.j2 | 16 ++++
napalm_iosxr/templates/snmp_config.j2 | 6 +-
requirements.txt | 6 +-
setup.cfg | 1 -
setup.py | 4 +-
test/__init__.py | 0
test/unit/TestIOSXRDriver.py | 94 ----------------------
test/unit/__init__.py | 0
test/unit/conftest.py | 77 ------------------
test/unit/test_getters.py | 13 ---
17 files changed, 151 insertions(+), 242 deletions(-)
diff --git a/PKG-INFO b/PKG-INFO
index ac85b3a..5425bc7 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: napalm-iosxr
-Version: 0.4.5
+Version: 0.5.6
Summary: Network Automation and Programmability Abstraction Layer with Multivendor support
Home-page: https://github.com/napalm-automation/napalm-iosxr
Author: David Barroso, Mircea Ulinic
diff --git a/napalm_iosxr.egg-info/PKG-INFO b/napalm_iosxr.egg-info/PKG-INFO
index ac85b3a..5425bc7 100644
--- a/napalm_iosxr.egg-info/PKG-INFO
+++ b/napalm_iosxr.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: napalm-iosxr
-Version: 0.4.5
+Version: 0.5.6
Summary: Network Automation and Programmability Abstraction Layer with Multivendor support
Home-page: https://github.com/napalm-automation/napalm-iosxr
Author: David Barroso, Mircea Ulinic
diff --git a/napalm_iosxr.egg-info/SOURCES.txt b/napalm_iosxr.egg-info/SOURCES.txt
index d0e02df..3605f76 100644
--- a/napalm_iosxr.egg-info/SOURCES.txt
+++ b/napalm_iosxr.egg-info/SOURCES.txt
@@ -14,14 +14,11 @@ napalm_iosxr/templates/delete_ntp_peers.j2
napalm_iosxr/templates/delete_ntp_servers.j2
napalm_iosxr/templates/delete_probes.j2
napalm_iosxr/templates/delete_snmp_config.j2
+napalm_iosxr/templates/delete_users.j2
napalm_iosxr/templates/schedule_probes.j2
napalm_iosxr/templates/set_hostname.j2
napalm_iosxr/templates/set_ntp_peers.j2
napalm_iosxr/templates/set_ntp_servers.j2
napalm_iosxr/templates/set_probes.j2
-napalm_iosxr/templates/snmp_config.j2
-test/__init__.py
-test/unit/TestIOSXRDriver.py
-test/unit/__init__.py
-test/unit/conftest.py
-test/unit/test_getters.py
\ No newline at end of file
+napalm_iosxr/templates/set_users.j2
+napalm_iosxr/templates/snmp_config.j2
\ No newline at end of file
diff --git a/napalm_iosxr.egg-info/requires.txt b/napalm_iosxr.egg-info/requires.txt
index 8361757..00e64c0 100644
--- a/napalm_iosxr.egg-info/requires.txt
+++ b/napalm_iosxr.egg-info/requires.txt
@@ -1,3 +1,3 @@
-napalm-base>=0.18.0
-pyIOSXR>=0.20
-netaddr
+napalm-base>=0.25.0
+pyIOSXR>=0.51
+netmiko>=1.4.3
diff --git a/napalm_iosxr.egg-info/top_level.txt b/napalm_iosxr.egg-info/top_level.txt
index 7d5acaf..c93dcbf 100644
--- a/napalm_iosxr.egg-info/top_level.txt
+++ b/napalm_iosxr.egg-info/top_level.txt
@@ -1,2 +1 @@
napalm_iosxr
-test
diff --git a/napalm_iosxr/iosxr.py b/napalm_iosxr/iosxr.py
index 83304ea..4145e0f 100644
--- a/napalm_iosxr/iosxr.py
+++ b/napalm_iosxr/iosxr.py
@@ -26,6 +26,8 @@ from lxml import etree as ETREE
from netaddr import IPAddress # needed for traceroute, to check IP version
from netaddr.core import AddrFormatError
+from netmiko import __version__ as netmiko_version
+
from pyIOSXR import IOSXR
from pyIOSXR.exceptions import ConnectError
from pyIOSXR.exceptions import TimeoutError
@@ -57,13 +59,41 @@ class IOSXRDriver(NetworkDriver):
if optional_args is None:
optional_args = {}
self.port = optional_args.get('port', 22)
- self.lock_on_connect = optional_args.get('config_lock', True)
+ self.lock_on_connect = optional_args.get('config_lock', False)
+ # Netmiko possible arguments
+ netmiko_argument_map = {
+ 'keepalive': 30,
+ 'verbose': False,
+ 'global_delay_factor': 1,
+ 'use_keys': False,
+ 'key_file': None,
+ 'ssh_strict': False,
+ 'system_host_keys': False,
+ 'alt_host_keys': False,
+ 'alt_key_file': '',
+ 'ssh_config_file': None
+ }
+ fields = netmiko_version.split('.')
+ fields = [int(x) for x in fields]
+ maj_ver, min_ver, bug_fix = fields
+ if maj_ver >= 2:
+ netmiko_argument_map['allow_agent'] = False
+ elif maj_ver == 1 and min_ver >= 1:
+ netmiko_argument_map['allow_agent'] = False
+ # Build dict of any optional Netmiko args
+ self.netmiko_optional_args = {}
+ for k, v in netmiko_argument_map.items():
+ try:
+ self.netmiko_optional_args[k] = optional_args[k]
+ except KeyError:
+ pass
self.device = IOSXR(hostname,
username,
password,
timeout=timeout,
port=self.port,
- lock=self.lock_on_connect)
+ lock=self.lock_on_connect,
+ **self.netmiko_optional_args)
def open(self):
try:
@@ -75,8 +105,10 @@ class IOSXRDriver(NetworkDriver):
self.device.close()
def is_alive(self):
+ """Returns a flag with the state of the connection."""
+ # Simply returns the flag from Netmiko
return {
- 'is_alive': self.device.device.remote_conn.transport.is_active()
+ 'is_alive': self.device.device.is_alive()
}
def load_replace_candidate(self, filename=None, config=None):
@@ -151,7 +183,10 @@ class IOSXRDriver(NetworkDriver):
system_time_xpath = './/SystemTime/Uptime'
platform_attr_xpath = './/RackTable/Rack/Attributes/BasicInfo'
system_time_tree = facts_rpc_reply.xpath(system_time_xpath)[0]
- platform_attr_tree = facts_rpc_reply.xpath(platform_attr_xpath)[0]
+ try:
+ platform_attr_tree = facts_rpc_reply.xpath(platform_attr_xpath)[0]
+ except IndexError:
+ platform_attr_tree = facts_rpc_reply.xpath(platform_attr_xpath)
hostname = napalm_base.helpers.convert(
text_type, napalm_base.helpers.find_txt(system_time_tree, 'Hostname'))
@@ -680,9 +715,9 @@ class IOSXRDriver(NetworkDriver):
inet = False
inet6 = False
preifx_type = 'inet'
- if 'IPV4' in af_table:
+ if 'ipv4' in af_table.lower():
inet = True
- if 'IPv6' in af_table:
+ if 'ipv6' in af_table.lower():
inet6 = True
preifx_type = 'inet6'
if inet or inet6:
@@ -775,8 +810,8 @@ class IOSXRDriver(NetworkDriver):
bgp_group, 'NeighborGroupAFTable/NeighborGroupAF/RoutePolicyIn')
export_policy = napalm_base.helpers.find_txt(
bgp_group, 'NeighborGroupAFTable/NeighborGroupAF/RoutePolicyOut')
- multipath = eval((napalm_base.helpers.find_txt(
- bgp_group, 'NeighborGroupAFTable/NeighborGroupAF/Multipath') or 'false').title())
+ multipath = napalm_base.helpers.find_txt(
+ bgp_group, 'NeighborGroupAFTable/NeighborGroupAF/Multipath') == 'true'
peer_as = napalm_base.helpers.convert(
int, napalm_base.helpers.find_txt(bgp_group, 'RemoteAS/AS_YY'), 0)
local_as = napalm_base.helpers.convert(
@@ -820,6 +855,22 @@ class IOSXRDriver(NetworkDriver):
}
if group and group == group_name:
break
+ if '' in bgp_group_neighbors.keys():
+ bgp_config['_'] = {
+ 'apply_groups': [],
+ 'description': '',
+ 'local_as': 0,
+ 'type': '',
+ 'import_policy': '',
+ 'export_policy': '',
+ 'local_address': '',
+ 'multipath': False,
+ 'multihop_ttl': 0,
+ 'remote_as': 0,
+ 'remove_private_as': False,
+ 'prefix_limit': {},
+ 'neighbors': bgp_group_neighbors.get('', {})
+ }
return bgp_config
@@ -890,8 +941,8 @@ class IOSXRDriver(NetworkDriver):
napalm_base.helpers.find_txt(neighbor, 'Naming/NeighborAddress/IPV4Address') or
napalm_base.helpers.find_txt(neighbor, 'Naming/NeighborAddress/IPV6Address')
)
- local_address_configured = eval(napalm_base.helpers.find_txt(
- neighbor, 'IsLocalAddressConfigured', 'false').title())
+ local_address_configured = napalm_base.helpers.find_txt(
+ neighbor, 'IsLocalAddressConfigured') == 'true'
local_address = napalm_base.helpers.ip(
napalm_base.helpers.find_txt(neighbor, 'ConnectionLocalAddress/IPV4Address') or
napalm_base.helpers.find_txt(neighbor, 'ConnectionLocalAddress/IPV6Address')
@@ -904,12 +955,12 @@ class IOSXRDriver(NetworkDriver):
)
remote_port = napalm_base.helpers.convert(
int, napalm_base.helpers.find_txt(neighbor, 'ConnectionRemotePort'))
- multihop = eval(napalm_base.helpers.find_txt(
- neighbor, 'IsExternalNeighborNotDirectlyConnected', 'false').title())
- remove_private_as = eval(napalm_base.helpers.find_txt(
- neighbor, 'AFData/Entry/RemovePrivateASFromUpdates', 'false').title())
- multipath = eval(napalm_base.helpers.find_txt(
- neighbor, 'AFData/Entry/SelectiveMultipathEligible', 'false').title())
+ multihop = napalm_base.helpers.find_txt(
+ neighbor, 'IsExternalNeighborNotDirectlyConnected') == 'true'
+ remove_private_as = napalm_base.helpers.find_txt(
+ neighbor, 'AFData/Entry/RemovePrivateASFromUpdates') == 'true'
+ multipath = napalm_base.helpers.find_txt(
+ neighbor, 'AFData/Entry/SelectiveMultipathEligible') == 'true'
import_policy = napalm_base.helpers.find_txt(
neighbor, 'AFData/Entry/RoutePolicyIn')
export_policy = napalm_base.helpers.find_txt(
@@ -941,10 +992,10 @@ class IOSXRDriver(NetworkDriver):
advertised_prefix_count = napalm_base.helpers.convert(
int, napalm_base.helpers.find_txt(
neighbor, 'AFData/Entry/PrefixesAdvertised'), 0)
- suppress_4byte_as = eval(napalm_base.helpers.find_txt(
- neighbor, 'Suppress4ByteAs', 'false').title())
- local_as_prepend = not eval(napalm_base.helpers.find_txt(
- neighbor, 'LocalASNoPrepend', 'false').title())
+ suppress_4byte_as = napalm_base.helpers.find_txt(
+ neighbor, 'Suppress4ByteAs') == 'true'
+ local_as_prepend = napalm_base.helpers.find_txt(
+ neighbor, 'LocalASNoPrepend') != 'true'
holdtime = napalm_base.helpers.convert(
int, napalm_base.helpers.find_txt(neighbor, 'HoldTime'), 0) or vrf_holdtime
configured_holdtime = napalm_base.helpers.convert(
@@ -996,7 +1047,7 @@ class IOSXRDriver(NetworkDriver):
'advertised_prefix_count': advertised_prefix_count,
'flap_count': flap_count
})
-
+ bgp_neighbors_detail['global'] = bgp_neighbors_detail.pop('default')
return bgp_neighbors_detail
def get_arp_table(self):
@@ -1083,7 +1134,7 @@ class IOSXRDriver(NetworkDriver):
xpath = './/NodeTable/Node/Associations/PeerSummaryInfo/Entry/PeerInfoCommon'
for node in result_tree.xpath(xpath):
- synchronized = eval(napalm_base.helpers.find_txt(node, 'IsSysPeer', 'false').title())
+ synchronized = napalm_base.helpers.find_txt(node, 'IsSysPeer') == 'true'
address = napalm_base.helpers.find_txt(node, 'Address')
if address == 'DLRSC node':
continue
@@ -1224,15 +1275,30 @@ class IOSXRDriver(NetworkDriver):
prefix_tag = '<PrefixLength>{prefix_length}</PrefixLength>'.format(
prefix_length=dest_split[1])
- route_info_rpc_command = '<Get><Operational><RIB><VRFTable><VRF><Naming><VRFName>default\
- </VRFName></Naming><AFTable><AF><Naming><AFName>IPv4</AFName></Naming><SAFTable><SAF>\
- <Naming><SAFName>Unicast</SAFName></Naming><IP_RIBRouteTable><IP_RIBRoute><Naming>\
- <RouteTableName>default</RouteTableName></Naming><RouteTable><Route><Naming><Address>\
- {network}</Address>{prefix}</Naming></Route></RouteTable></IP_RIBRoute></IP_RIBRouteTable>\
- </SAF></SAFTable></AF></AFTable></VRF></VRFTable></RIB></Operational></Get>'.format(
- network=network,
- prefix=prefix_tag
- )
+ ipv = 4
+ try:
+ ipv = IPAddress(network).version
+ except AddrFormatError:
+ raise TypeError('Wrong destination IP Address!')
+
+ if ipv == 6:
+ route_info_rpc_command = '<Get><Operational><IPV6_RIB><VRFTable><VRF><Naming><VRFName>\
+ default</VRFName></Naming><AFTable><AF><Naming><AFName>IPv6</AFName></Naming><SAFTable>\
+ <SAF><Naming><SAFName>Unicast</SAFName></Naming><IP_RIBRouteTable><IP_RIBRoute><Naming>\
+ <RouteTableName>default</RouteTableName></Naming><RouteTable><Route><Naming><Address>\
+ {network}</Address>{prefix}</Naming></Route></RouteTable></IP_RIBRoute>\
+ </IP_RIBRouteTable></SAF></SAFTable></AF></AFTable></VRF></VRFTable></IPV6_RIB>\
+ </Operational></Get>'.format(network=network, prefix=prefix_tag)
+ else:
+ route_info_rpc_command = '<Get><Operational><RIB><VRFTable><VRF><Naming><VRFName>default\
+ </VRFName></Naming><AFTable><AF><Naming><AFName>IPv4</AFName></Naming><SAFTable><SAF>\
+ <Naming><SAFName>Unicast</SAFName></Naming><IP_RIBRouteTable><IP_RIBRoute><Naming>\
+ <RouteTableName>default</RouteTableName></Naming><RouteTable><Route><Naming><Address>\
+ {network}</Address>{prefix}</Naming></Route></RouteTable></IP_RIBRoute></IP_RIBRouteTable>\
+ </SAF></SAFTable></AF></AFTable></VRF></VRFTable></RIB></Operational></Get>'.format(
+ network=network,
+ prefix=prefix_tag
+ )
routes_tree = ETREE.fromstring(self.device.make_rpc_call(route_info_rpc_command))
@@ -1291,8 +1357,8 @@ class IOSXRDriver(NetworkDriver):
for bgp_path in bgp_route_tree.xpath('.//Path'):
single_route_details = route_details.copy()
if 'NotFound' not in bgp_path.keys():
- best_path = eval(napalm_base.helpers.find_txt(
- bgp_path, 'PathInformation/IsBestPath', 'false').title())
+ best_path = napalm_base.helpers.find_txt(
+ bgp_path, 'PathInformation/IsBestPath') == 'true'
local_preference = napalm_base.helpers.convert(
int,
napalm_base.helpers.find_txt(
@@ -1558,7 +1624,8 @@ class IOSXRDriver(NetworkDriver):
destination,
source=C.TRACEROUTE_SOURCE,
ttl=C.TRACEROUTE_TTL,
- timeout=C.TRACEROUTE_TIMEOUT):
+ timeout=C.TRACEROUTE_TIMEOUT,
+ vrf=C.TRACEROUTE_VRF):
traceroute_result = {}
@@ -1571,20 +1638,22 @@ class IOSXRDriver(NetworkDriver):
source_tag = ''
ttl_tag = ''
timeout_tag = ''
+ vrf_tag = ''
if source:
source_tag = '<Source>{source}</Source>'.format(source=source)
if ttl:
ttl_tag = '<MaxTTL>{maxttl}</MaxTTL>'.format(maxttl=ttl)
if timeout:
timeout_tag = '<Timeout>{timeout}</Timeout>'.format(timeout=timeout)
- else:
- timeout = 5 # seconds
+ if vrf:
+ vrf_tag = '<VRFName>{vrf}</VRFName>'.format(vrf=vrf)
traceroute_rpc_command = '<Set><Action><TraceRoute><IPV{version}><Destination>{destination}\
- </Destination>{source_tag}{ttl_tag}{timeout_tag}</IPV{version}></TraceRoute></Action>\
+ </Destination>{vrf_tag}{source_tag}{ttl_tag}{timeout_tag}</IPV{version}></TraceRoute></Action>\
</Set>'.format(
version=ipv,
destination=destination,
+ vrf_tag=vrf_tag,
source_tag=source_tag,
ttl_tag=ttl_tag,
timeout_tag=timeout_tag
diff --git a/napalm_iosxr/templates/delete_users.j2 b/napalm_iosxr/templates/delete_users.j2
new file mode 100644
index 0000000..0dab7e1
--- /dev/null
+++ b/napalm_iosxr/templates/delete_users.j2
@@ -0,0 +1,13 @@
+{%- for user_name, user_details in users.iteritems() %}
+{%- if user_details %}
+username {{user_name}}
+{%- endif %}
+{%- if user_details.get('password') %}
+ no password
+{%- endif %}
+{%- if user_details.get('level') %}
+ no group
+{%- endif %}
+{%- else %}
+no username {{user_name}}
+{%- endfor %}
diff --git a/napalm_iosxr/templates/set_users.j2 b/napalm_iosxr/templates/set_users.j2
new file mode 100644
index 0000000..5cc43d1
--- /dev/null
+++ b/napalm_iosxr/templates/set_users.j2
@@ -0,0 +1,16 @@
+{%- for user_name, user_details in users.items() %}
+username {{user_name}}
+ {% set user_level = user_details.level|default(1) %}
+ {%- if user_level == 15 %}
+ group root-system
+ {%- elif user_level == 5 %}
+ group operator
+ {%- elif user_level == 2 %}
+ group serviceadmin
+ {%- elif user_level == 1 %}
+ group sysadmin
+ {% endif %}
+ {%- if user_details.get('password') %}
+ password {{user_details.password}}
+ {%- endif %}
+{%- endfor %}
diff --git a/napalm_iosxr/templates/snmp_config.j2 b/napalm_iosxr/templates/snmp_config.j2
index b75e5d1..4ea4d7d 100644
--- a/napalm_iosxr/templates/snmp_config.j2
+++ b/napalm_iosxr/templates/snmp_config.j2
@@ -11,12 +11,12 @@ snmp-server chassis-id "{{chassis_id}}"
{% for comm_name, comm_details in community.iteritems() %}
{% if (comm_details is defined) and comm_details %}
{% if (comm_details.get('mode') is defined) and comm_details.get('mode') == 'rw' %}
-community {{comm_name}} RW
+snmp-server community {{comm_name}} RW
{% else %}
-community {{comm_name}} RO
+snmp-server community {{comm_name}} RO
{% endif %}
{% else %}
-community {{comm_name}} RO
+snmp-server community {{comm_name}} RO
{% endif %}
{% endfor %}
{% endif %}
diff --git a/requirements.txt b/requirements.txt
index 01e0634..00e64c0 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,3 +1,3 @@
-napalm-base>=0.18.0
-pyIOSXR >= 0.20
-netaddr
+napalm-base>=0.25.0
+pyIOSXR>=0.51
+netmiko>=1.4.3
diff --git a/setup.cfg b/setup.cfg
index 7330df1..e27a6e4 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -18,5 +18,4 @@ include =
[egg_info]
tag_build =
tag_date = 0
-tag_svn_revision = 0
diff --git a/setup.py b/setup.py
index b8dc5d0..e1df675 100644
--- a/setup.py
+++ b/setup.py
@@ -12,8 +12,8 @@ reqs = [str(ir.req) for ir in install_reqs]
setup(
name="napalm-iosxr",
- version="0.4.5",
- packages=find_packages(),
+ version="0.5.6",
+ packages=find_packages(exclude=["test", "test.*"]),
author="David Barroso, Mircea Ulinic",
author_email="dbarrosop at dravetech.com, mircea at cloudflare.com",
description="Network Automation and Programmability Abstraction Layer with Multivendor support",
diff --git a/test/__init__.py b/test/__init__.py
deleted file mode 100644
index e69de29..0000000
diff --git a/test/unit/TestIOSXRDriver.py b/test/unit/TestIOSXRDriver.py
deleted file mode 100644
index bd6a842..0000000
--- a/test/unit/TestIOSXRDriver.py
+++ /dev/null
@@ -1,94 +0,0 @@
-# Copyright 2015 Spotify AB. All rights reserved.
-#
-# The contents of this file are licensed under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with the
-# License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations under
-# the License.
-
-import unittest
-import os
-
-from napalm_iosxr.iosxr import IOSXRDriver
-from napalm_base.test.base import TestConfigNetworkDriver, TestGettersNetworkDriver
-
-
-class TestConfigIOSXRDriver(unittest.TestCase, TestConfigNetworkDriver):
-
- @classmethod
- def setUpClass(cls):
- hostname = '127.0.0.1'
- username = 'vagrant'
- password = 'vagrant'
- cls.vendor = 'iosxr'
-
- optional_args = {'port': 12202}
- cls.device = IOSXRDriver(hostname,
- username,
- password,
- timeout=60,
- optional_args=optional_args)
- cls.device.open()
- cls.device.load_replace_candidate(filename='%s/initial.conf' % cls.vendor)
- cls.device.commit_config()
-
-
-class TestGetterIOSXRDriver(unittest.TestCase, TestGettersNetworkDriver):
-
- @classmethod
- def setUpClass(cls):
- cls.mock = True
-
- hostname = '192.168.56.202'
- username = 'vagrant'
- password = 'vagrant'
- cls.vendor = 'iosxr'
-
- cls.device = IOSXRDriver(hostname, username, password, timeout=60)
-
- if cls.mock:
- cls.device.device = FakeIOSXRDevice()
- else:
- cls.device.open()
-
-
-class FakeIOSXRDevice:
-
- @staticmethod
- def read_txt_file(filename):
- curr_dir = os.path.dirname(os.path.abspath(__file__))
- fullpath = os.path.join(curr_dir, filename)
- with open(fullpath) as data_file:
- return data_file.read()
-
- def _execute_config_show(self, show_command):
- rpc_request = '<CLI><Configuration>{show_command}</Configuration></CLI>'.format(
- show_command=show_command
- )
- return self.make_rpc_call(rpc_request)
-
- def show_version(self):
- return self.read_txt_file('iosxr/mock_data/show_version.txt')
-
- def show_interfaces(self):
- return self.read_txt_file('iosxr/mock_data/show_interfaces.txt')
-
- def show_interface_description(self):
- return self.read_txt_file('iosxr/mock_data/show_interface_description.txt')
-
- def show_lldp_neighbors(self):
- return self.read_txt_file('iosxr/mock_data/show_lldp_neighbors.txt')
-
- def make_rpc_call(self, rpc_call):
- rpc_call = rpc_call.replace('<', '_')\
- .replace('>', '_')\
- .replace('/', '_')\
- .replace('\n', '')\
- .replace(' ', '')
- return self.read_txt_file('iosxr/mock_data/{}.rpc'.format(rpc_call[0:150]))
diff --git a/test/unit/__init__.py b/test/unit/__init__.py
deleted file mode 100644
index e69de29..0000000
diff --git a/test/unit/conftest.py b/test/unit/conftest.py
deleted file mode 100644
index f3ca74f..0000000
--- a/test/unit/conftest.py
+++ /dev/null
@@ -1,77 +0,0 @@
-"""Test fixtures."""
-from __future__ import print_function
-from __future__ import unicode_literals
-
-from builtins import super
-
-import pytest
-from napalm_base.test import conftest as parent_conftest
-
-from napalm_base.test.double import BaseTestDouble
-
-from napalm_iosxr import iosxr
-
-
- at pytest.fixture(scope='class')
-def set_device_parameters(request):
- """Set up the class."""
- def fin():
- request.cls.device.close()
- request.addfinalizer(fin)
-
- request.cls.driver = iosxr.IOSXRDriver
- request.cls.patched_driver = PatchedIOSXRDriver
- request.cls.vendor = 'iosxr'
- parent_conftest.set_device_parameters(request)
-
-
-def pytest_generate_tests(metafunc):
- """Generate test cases dynamically."""
- parent_conftest.pytest_generate_tests(metafunc, __file__)
-
-
-class PatchedIOSXRDriver(iosxr.IOSXRDriver):
- """Patched IOS Driver."""
-
- def __init__(self, hostname, username, password, timeout=60, optional_args=None):
-
- super().__init__(hostname, username, password, timeout, optional_args)
-
- self.patched_attrs = ['device']
- self.device = FakeIOSXRDevice()
-
- def is_alive(self):
- return {
- 'is_alive': True # In testing everything works..
- }
-
- def open(self):
- pass
-
-
-class FakeIOSXRDevice(BaseTestDouble):
- """IOSXR device test double."""
-
- def close(self):
- pass
-
- def make_rpc_call(self, rpc_call, encoded=True):
- filename = '{}.txt'.format(self.sanitize_text(rpc_call))
- full_path = self.find_file(filename)
- result = self.read_txt_file(full_path)
- if encoded:
- return str.encode(result)
- else:
- return result
-
- def show_lldp_neighbors(self):
- filename = 'show_lldp_neighbors.txt'
- full_path = self.find_file(filename)
- result = self.read_txt_file(full_path)
- return result
-
- def _execute_config_show(self, show_command):
- rpc_request = '<CLI><Configuration>{show_command}</Configuration></CLI>'.format(
- show_command=show_command
- )
- return self.make_rpc_call(rpc_request, encoded=False)
diff --git a/test/unit/test_getters.py b/test/unit/test_getters.py
deleted file mode 100644
index 6156b91..0000000
--- a/test/unit/test_getters.py
+++ /dev/null
@@ -1,13 +0,0 @@
-"""Tests for getters."""
-from __future__ import print_function
-from __future__ import unicode_literals
-
-from napalm_base.test.getters import BaseTestGetters
-
-
-import pytest
-
-
- at pytest.mark.usefixtures("set_device_parameters")
-class TestGetter(BaseTestGetters):
- """Test get_* methods."""
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/napalm-iosxr.git
More information about the Python-modules-commits
mailing list