fixes for python3
This commit is contained in:
parent
7e2a8ba420
commit
be5f80a427
|
|
@ -13,7 +13,7 @@
|
||||||
# the License.
|
# the License.
|
||||||
|
|
||||||
"""napalm_vyos package."""
|
"""napalm_vyos package."""
|
||||||
from vyos import VyOSDriver
|
from napalm_vyos.vyos import VyOSDriver
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ from netmiko import ConnectHandler
|
||||||
from netmiko import SCPConn
|
from netmiko import SCPConn
|
||||||
|
|
||||||
# NAPALM base
|
# NAPALM base
|
||||||
|
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, \
|
from napalm_base.exceptions import ConnectionException, \
|
||||||
MergeConfigException, ReplaceConfigException
|
MergeConfigException, ReplaceConfigException
|
||||||
|
|
@ -314,10 +315,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": unicode(description),
|
"description": py23_compat.text_type(description),
|
||||||
"last_flapped": float(-1),
|
"last_flapped": float(-1),
|
||||||
"speed": int(speed),
|
"speed": int(speed),
|
||||||
"mac_address": unicode(hw_id)
|
"mac_address": py23_compat.text_type(hw_id)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -356,15 +357,15 @@ 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 = unicode("00:00:00:00:00:00")
|
macaddr = py23_compat.text_type("00:00:00:00:00:00")
|
||||||
else:
|
else:
|
||||||
macaddr = unicode(line[2])
|
macaddr = py23_compat.text_type(line[2])
|
||||||
|
|
||||||
arp_table.append(
|
arp_table.append(
|
||||||
{
|
{
|
||||||
'interface': unicode(line[-1]),
|
'interface': py23_compat.text_type(line[-1]),
|
||||||
'mac': macaddr,
|
'mac': macaddr,
|
||||||
'ip': unicode(line[0]),
|
'ip': py23_compat.text_type(line[0]),
|
||||||
'age': 0.0
|
'age': 0.0
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
@ -399,12 +400,12 @@ class VyOSDriver(NetworkDriver):
|
||||||
when = when if when != '-' else 0
|
when = when if when != '-' else 0
|
||||||
|
|
||||||
ntp_stats.append({
|
ntp_stats.append({
|
||||||
"remote": unicode(ip),
|
"remote": py23_compat.text_type(ip),
|
||||||
"referenceid": unicode(refid),
|
"referenceid": py23_compat.text_type(refid),
|
||||||
"synchronized": bool(synchronized),
|
"synchronized": bool(synchronized),
|
||||||
"stratum": int(st),
|
"stratum": int(st),
|
||||||
"type": unicode(t),
|
"type": py23_compat.text_type(t),
|
||||||
"when": unicode(when),
|
"when": py23_compat.text_type(when),
|
||||||
"hostpoll": int(hostpoll),
|
"hostpoll": int(hostpoll),
|
||||||
"reachability": int(reachability),
|
"reachability": int(reachability),
|
||||||
"delay": float(delay),
|
"delay": float(delay),
|
||||||
|
|
@ -423,7 +424,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({
|
||||||
unicode(match.group(1)): {}
|
py23_compat.text_type(match.group(1)): {}
|
||||||
})
|
})
|
||||||
|
|
||||||
return ntp_peers
|
return ntp_peers
|
||||||
|
|
@ -451,7 +452,7 @@ class VyOSDriver(NetworkDriver):
|
||||||
output[0])
|
output[0])
|
||||||
if not match:
|
if not match:
|
||||||
return {}
|
return {}
|
||||||
router_id = unicode(match.group(1))
|
router_id = py23_compat.text_type(match.group(1))
|
||||||
local_as = int(match.group(2))
|
local_as = int(match.group(2))
|
||||||
|
|
||||||
bgp_neighbor_data = dict()
|
bgp_neighbor_data = dict()
|
||||||
|
|
@ -505,11 +506,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": unicode(""),
|
"description": py23_compat.text_type(""),
|
||||||
"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": unicode(remote_rid),
|
"remote_id": py23_compat.text_type(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)
|
||||||
}
|
}
|
||||||
|
|
@ -589,7 +590,7 @@ class VyOSDriver(NetworkDriver):
|
||||||
rx_broadcast_packets = -1
|
rx_broadcast_packets = -1
|
||||||
else:
|
else:
|
||||||
counters.update({
|
counters.update({
|
||||||
interfaces[j / 2]: {
|
interfaces[j // 2]: {
|
||||||
"tx_errors": int(i[2]),
|
"tx_errors": int(i[2]),
|
||||||
"tx_discards": int(i[3]),
|
"tx_discards": int(i[3]),
|
||||||
"tx_octets": int(i[0]),
|
"tx_octets": int(i[0]),
|
||||||
|
|
@ -622,15 +623,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": unicode(""),
|
"acl": py23_compat.text_type(""),
|
||||||
"mode": unicode(config["service"]["snmp"]["community"][i]["authorization"])
|
"mode": py23_compat.text_type(config["service"]["snmp"]["community"][i]["authorization"])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
snmp.update({
|
snmp.update({
|
||||||
"chassis_id": unicode(""),
|
"chassis_id": py23_compat.text_type(""),
|
||||||
"contact": unicode(config["service"]["snmp"]["contact"]),
|
"contact": py23_compat.text_type(config["service"]["snmp"]["contact"]),
|
||||||
"location": unicode(config["service"]["snmp"]["location"])
|
"location": py23_compat.text_type(config["service"]["snmp"]["location"])
|
||||||
})
|
})
|
||||||
|
|
||||||
return snmp
|
return snmp
|
||||||
|
|
@ -672,12 +673,12 @@ class VyOSDriver(NetworkDriver):
|
||||||
|
|
||||||
facts = {
|
facts = {
|
||||||
"uptime": int(uptime),
|
"uptime": int(uptime),
|
||||||
"vendor": unicode("VyOS"),
|
"vendor": py23_compat.text_type("VyOS"),
|
||||||
"os_version": unicode(version),
|
"os_version": py23_compat.text_type(version),
|
||||||
"serial_number": unicode(snumber),
|
"serial_number": py23_compat.text_type(snumber),
|
||||||
"model": unicode(hwmodel),
|
"model": py23_compat.text_type(hwmodel),
|
||||||
"hostname": unicode(hostname),
|
"hostname": py23_compat.text_type(hostname),
|
||||||
"fqdn": unicode(fqdn),
|
"fqdn": py23_compat.text_type(fqdn),
|
||||||
"interface_list": iface_list
|
"interface_list": iface_list
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue