Remove py23_compat.text_type usage

This commit is contained in:
Brad Walker 2020-05-16 10:26:39 -06:00
parent df1d827038
commit b287f3d6c7
2 changed files with 30 additions and 33 deletions

View File

@ -32,7 +32,6 @@ from netmiko import SCPConn
# NAPALM base # NAPALM base
import napalm.base.constants as C import napalm.base.constants as C
from napalm.base.utils import py23_compat
from napalm.base.base import NetworkDriver from napalm.base.base import NetworkDriver
from napalm.base.exceptions import ConnectionException, MergeConfigException, \ from napalm.base.exceptions import ConnectionException, MergeConfigException, \
ReplaceConfigException, CommitError, \ ReplaceConfigException, CommitError, \
@ -347,10 +346,10 @@ class VyOSDriver(NetworkDriver):
iface_name: { iface_name: {
"is_up": bool(is_up), "is_up": bool(is_up),
"is_enabled": bool(is_enabled), "is_enabled": bool(is_enabled),
"description": py23_compat.text_type(description), "description": description,
"last_flapped": float(-1), "last_flapped": float(-1),
"speed": int(speed), "speed": int(speed),
"mac_address": py23_compat.text_type(hw_id) "mac_address": hw_id,
} }
}) })
@ -376,7 +375,7 @@ class VyOSDriver(NetworkDriver):
192.168.1.3 ether 00:50:56:86:7b:06 C eth1 192.168.1.3 ether 00:50:56:86:7b:06 C eth1
""" """
if vrf: if vrf:
raise NotImplementedError( raise NotImplementedError(
"VRF support has not been added for this getter on this platform." "VRF support has not been added for this getter on this platform."
) )
@ -395,16 +394,16 @@ class VyOSDriver(NetworkDriver):
# ["10.129.2.254", "ether", "00:50:56:97:af:b1", "C", "eth0"] # ["10.129.2.254", "ether", "00:50:56:97:af:b1", "C", "eth0"]
# [u'10.0.12.33', u'(incomplete)', u'eth1'] # [u'10.0.12.33', u'(incomplete)', u'eth1']
if "incomplete" in line[1]: if "incomplete" in line[1]:
macaddr = py23_compat.text_type("00:00:00:00:00:00") macaddr = "00:00:00:00:00:00"
else: else:
macaddr = py23_compat.text_type(line[2]) macaddr = line[2]
arp_table.append( arp_table.append(
{ {
'interface': py23_compat.text_type(line[-1]), 'interface': line[-1],
'mac': macaddr, 'mac': macaddr,
'ip': py23_compat.text_type(line[0]), 'ip': line[0],
'age': 0.0 'age': 0.0,
} }
) )
@ -438,17 +437,17 @@ class VyOSDriver(NetworkDriver):
when = when if when != '-' else 0 when = when if when != '-' else 0
ntp_stats.append({ ntp_stats.append({
"remote": py23_compat.text_type(ip), "remote": ip,
"referenceid": py23_compat.text_type(refid), "referenceid": refid,
"synchronized": bool(synchronized), "synchronized": bool(synchronized),
"stratum": int(st), "stratum": int(st),
"type": py23_compat.text_type(t), "type": t,
"when": py23_compat.text_type(when), "when": when,
"hostpoll": int(hostpoll), "hostpoll": int(hostpoll),
"reachability": int(reachability), "reachability": int(reachability),
"delay": float(delay), "delay": float(delay),
"offset": float(offset), "offset": float(offset),
"jitter": float(jitter) "jitter": float(jitter),
}) })
return ntp_stats return ntp_stats
@ -462,7 +461,7 @@ class VyOSDriver(NetworkDriver):
if len(line) > 0: if len(line) > 0:
match = re.search("(\d+\.\d+\.\d+\.\d+)\s+", line) match = re.search("(\d+\.\d+\.\d+\.\d+)\s+", line)
ntp_peers.update({ ntp_peers.update({
py23_compat.text_type(match.group(1)): {} match.group(1): {}
}) })
return ntp_peers return ntp_peers
@ -490,7 +489,7 @@ class VyOSDriver(NetworkDriver):
output[0]) output[0])
if not match: if not match:
return {} return {}
router_id = py23_compat.text_type(match.group(1)) router_id = match.group(1)
local_as = int(match.group(2)) local_as = int(match.group(2))
bgp_neighbor_data = dict() bgp_neighbor_data = dict()
@ -546,11 +545,11 @@ class VyOSDriver(NetworkDriver):
bgp_neighbor_data["global"]["peers"].setdefault(peer_id, {}) bgp_neighbor_data["global"]["peers"].setdefault(peer_id, {})
peer_dict = { peer_dict = {
"description": py23_compat.text_type(""), "description": "",
"is_enabled": bool(is_enabled), "is_enabled": bool(is_enabled),
"local_as": int(local_as), "local_as": int(local_as),
"is_up": bool(is_up), "is_up": bool(is_up),
"remote_id": py23_compat.text_type(remote_rid), "remote_id": remote_rid,
"uptime": int(self._bgp_time_conversion(up_time)), "uptime": int(self._bgp_time_conversion(up_time)),
"remote_as": int(remote_as) "remote_as": int(remote_as)
} }
@ -663,15 +662,15 @@ class VyOSDriver(NetworkDriver):
for i in config["service"]["snmp"]["community"]: for i in config["service"]["snmp"]["community"]:
snmp["community"].update({ snmp["community"].update({
i: { i: {
"acl": py23_compat.text_type(""), "acl": "",
"mode": py23_compat.text_type(config["service"]["snmp"]["community"][i]["authorization"]) "mode": config["service"]["snmp"]["community"][i]["authorization"],
} }
}) })
snmp.update({ snmp.update({
"chassis_id": py23_compat.text_type(""), "chassis_id": "",
"contact": py23_compat.text_type(config["service"]["snmp"]["contact"]), "contact": config["service"]["snmp"]["contact"],
"location": py23_compat.text_type(config["service"]["snmp"]["location"]) "location": config["service"]["snmp"]["location"],
}) })
return snmp return snmp
@ -713,13 +712,13 @@ class VyOSDriver(NetworkDriver):
facts = { facts = {
"uptime": int(uptime), "uptime": int(uptime),
"vendor": py23_compat.text_type("VyOS"), "vendor": "VyOS",
"os_version": py23_compat.text_type(version), "os_version": version,
"serial_number": py23_compat.text_type(snumber), "serial_number": snumber,
"model": py23_compat.text_type(hwmodel), "model": hwmodel,
"hostname": py23_compat.text_type(hostname), "hostname": hostname,
"fqdn": py23_compat.text_type(fqdn), "fqdn": fqdn,
"interface_list": iface_list "interface_list": iface_list,
} }
return facts return facts

View File

@ -5,7 +5,6 @@ import pytest
from napalm.base.test import conftest as parent_conftest from napalm.base.test import conftest as parent_conftest
from napalm.base.test.double import BaseTestDouble from napalm.base.test.double import BaseTestDouble
from napalm.base.utils import py23_compat
from napalm_vyos import vyos from napalm_vyos import vyos
@ -55,5 +54,4 @@ class FakeVyOSDevice(BaseTestDouble):
def send_command(self, command, **kwargs): def send_command(self, command, **kwargs):
filename = '{}.text'.format(self.sanitize_text(command)) filename = '{}.text'.format(self.sanitize_text(command))
full_path = self.find_file(filename) full_path = self.find_file(filename)
result = self.read_txt_file(full_path) return self.read_txt_file(full_path)
return py23_compat.text_type(result)