from lib.topolog import logger
from lib.topogen import TopoRouter, get_topogen
+from lib.topotest import frr_unicode
# Import common_config to use commomnly used APIs
from lib.common_config import (
# Generating IPs for verification
network_list = generate_ips(network, no_of_network)
for ip in network_list:
- ip = str(ipaddress.ip_network(unicode(ip)))
+ ip = str(ipaddress.ip_network(frr_unicode(ip)))
cmd = "network {}".format(ip)
if del_action:
logger.info("Checking router %s router-id", router)
show_bgp_json = run_frr_cmd(rnode, "show bgp summary json", isjson=True)
router_id_out = show_bgp_json["ipv4Unicast"]["routerId"]
- router_id_out = ipaddress.IPv4Address(unicode(router_id_out))
+ router_id_out = ipaddress.IPv4Address(frr_unicode(router_id_out))
# Once router-id is deleted, highest interface ip should become
# router-id
router_id = find_interface_with_greater_ip(topo, router)
else:
router_id = input_dict[router]["bgp"]["router_id"]
- router_id = ipaddress.IPv4Address(unicode(router_id))
+ router_id = ipaddress.IPv4Address(frr_unicode(router_id))
if router_id == router_id_out:
logger.info("Found expected router-id %s for router %s", router_id, router)
routes = generate_ips(_network, no_of_ip)
for route in routes:
- route = str(ipaddress.ip_network(unicode(route)))
+ route = str(ipaddress.ip_network(frr_unicode(route)))
if route in sh_ip_bgp_json["routes"]:
route_attributes = sh_ip_bgp_json["routes"][route]
ip_list = generate_ips(network, no_of_ip)
for st_rt in ip_list:
- st_rt = str(ipaddress.ip_network(unicode(st_rt)))
+ st_rt = str(ipaddress.ip_network(frr_unicode(st_rt)))
_addr_type = validate_ip_address(st_rt)
if _addr_type != addr_type:
ip_list = generate_ips(network, no_of_network)
for st_rt in ip_list:
- st_rt = str(ipaddress.ip_network(unicode(st_rt)))
+ st_rt = str(ipaddress.ip_network(frr_unicode(st_rt)))
_addr_type = validate_ip_address(st_rt)
if _addr_type != addr_type:
from lib.topolog import logger, logger_config
from lib.topogen import TopoRouter, get_topogen
-from lib.topotest import interface_set_status, version_cmp
+from lib.topotest import interface_set_status, version_cmp, frr_unicode
FRRCFG_FILE = "frr_json.conf"
FRRCFG_BKUP_FILE = "frr_json_initial.conf"
addr_type = validate_ip_address(start_ip)
if addr_type == "ipv4":
- start_ip = ipaddress.IPv4Address(unicode(start_ip))
+ start_ip = ipaddress.IPv4Address(frr_unicode(start_ip))
step = 2 ** (32 - mask)
if addr_type == "ipv6":
- start_ip = ipaddress.IPv6Address(unicode(start_ip))
+ start_ip = ipaddress.IPv6Address(frr_unicode(start_ip))
step = 2 ** (128 - mask)
next_ip = start_ip
nh_found = False
for st_rt in ip_list:
- st_rt = str(ipaddress.ip_network(unicode(st_rt)))
+ st_rt = str(ipaddress.ip_network(frr_unicode(st_rt)))
_addr_type = validate_ip_address(st_rt)
if _addr_type != addr_type:
nh_found = False
for st_rt in ip_list:
- st_rt = str(ipaddress.ip_network(unicode(st_rt)))
+ st_rt = str(ipaddress.ip_network(frr_unicode(st_rt)))
_addr_type = validate_ip_address(st_rt)
if _addr_type != addr_type:
nh_found = False
for st_rt in ip_list:
- st_rt = str(ipaddress.ip_network(unicode(st_rt)))
+ st_rt = str(ipaddress.ip_network(frr_unicode(st_rt)))
#st_rt = str(ipaddr.IPNetwork(unicode(st_rt)))
_addr_type = validate_ip_address(st_rt)
for st_rt in ip_list:
#st_rt = str(ipaddr.IPNetwork(unicode(st_rt)))
- st_rt = str(ipaddress.ip_network(unicode(st_rt)))
+ st_rt = str(ipaddress.ip_network(frr_unicode(st_rt)))
_addr_type = validate_ip_address(st_rt)
if _addr_type != addr_type:
nh_found = False
for st_rt in ip_list:
- st_rt = str(ipaddress.ip_network(unicode(st_rt)))
+ st_rt = str(ipaddress.ip_network(frr_unicode(st_rt)))
_addr_type = validate_ip_address(st_rt)
if _addr_type != addr_type:
nh_found = False
for st_rt in ip_list:
- st_rt = str(ipaddress.ip_network(unicode(st_rt)))
+ st_rt = str(ipaddress.ip_network(frr_unicode(st_rt)))
_addr_type = validate_ip_address(st_rt)
if _addr_type != addr_type:
from time import sleep
from lib.topolog import logger
import ipaddr
-
+from lib.topotest import frr_unicode
# Import common_config to use commomnly used APIs
from lib.common_config import (create_common_configuration,
nh_found = False
for st_rt in ip_list:
- st_rt = str(ipaddr.IPNetwork(unicode(st_rt)))
+ st_rt = str(ipaddr.IPNetwork(frr_unicode(st_rt)))
_addr_type = validate_ip_address(st_rt)
if _addr_type != 'ipv4':
def __init__(self, name, **params):
OVSSwitch.__init__(self, name, failMode="standalone", **params)
self.switchIP = None
+
+def frr_unicode(s):
+ '''Convert string to unicode, depending on python version'''
+ if sys.version_info[0] > 2:
+ return s
+ else:
+ return unicode(s)