diff options
Diffstat (limited to 'tests/topotests/lib/common_config.py')
| -rw-r--r-- | tests/topotests/lib/common_config.py | 110 |
1 files changed, 46 insertions, 64 deletions
diff --git a/tests/topotests/lib/common_config.py b/tests/topotests/lib/common_config.py index ce35bdc0fe..a4c98924b6 100644 --- a/tests/topotests/lib/common_config.py +++ b/tests/topotests/lib/common_config.py @@ -336,16 +336,15 @@ def start_router_daemons(tgen, router, daemons): router_list = tgen.routers() # Start daemons - result = router_list[router].startDaemons(daemons) - return result + res = router_list[router].startDaemons(daemons) except Exception as e: errormsg = traceback.format_exc() logger.error(errormsg) - return errormsg + res = errormsg logger.debug("Exiting lib API: {}".format(sys._getframe().f_code.co_name)) - return True + return res def kill_mininet_routers_process(tgen): @@ -1374,14 +1373,16 @@ def generate_ips(network, no_of_ips): if start_ip == "0.0.0.0" and mask == 0 and no_of_ips == 1: ipaddress_list.append("{}/{}".format(start_ip, mask)) return ipaddress_list - start_ip = ipaddress.IPv4Address(unicode(start_ip)) + start_ip = ipaddress.IPv4Address(frr_unicode(start_ip)) step = 2 ** (32 - mask) - if addr_type == "ipv6": + elif addr_type == "ipv6": if start_ip == "0::0" and mask == 0 and no_of_ips == 1: ipaddress_list.append("{}/{}".format(start_ip, mask)) return ipaddress_list - start_ip = ipaddress.IPv6Address(unicode(start_ip)) + start_ip = ipaddress.IPv6Address(frr_unicode(start_ip)) step = 2 ** (128 - mask) + else: + return [] next_ip = start_ip count = 0 @@ -1479,10 +1480,6 @@ def interface_status(tgen, topo, input_dict): load_config_to_router(tgen, router) except Exception as e: - # handle any exception - logger.error("Error %s occured. Arguments %s.", e.message, e.args) - - # Traceback errormsg = traceback.format_exc() logger.error(errormsg) return errormsg @@ -2390,14 +2387,7 @@ def create_bgp_community_lists(tgen, input_dict, build=False): logger.error(errormsg) return False - try: - community_type = int(community_type) - cmd = "{} {} {} {}".format(cmd, community_type, action, value) - except ValueError: - - cmd = "{} {} {} {} {}".format( - cmd, community_type, name, action, value - ) + cmd = "{} {} {} {} {}".format(cmd, community_type, name, action, value) if del_action: cmd = "no {}".format(cmd) @@ -2448,51 +2438,6 @@ def shutdown_bringup_interface(tgen, dut, intf_name, ifaceaction=False): interface_set_status(router_list[dut], intf_name, ifaceaction) -def stop_router(tgen, router): - """ - Router's current config would be saved to /tmp/topotest/<suite>/<router> - for each daemon and router and its daemons would be stopped. - - * `tgen` : topogen object - * `router`: Device under test - """ - - router_list = tgen.routers() - - # Saving router config to /etc/frr, which will be loaded to router - # when it starts - router_list[router].vtysh_cmd("write memory") - - # Stop router - router_list[router].stop() - - -def start_router(tgen, router): - """ - Router will be started and config would be loaded from - /tmp/topotest/<suite>/<router> for each daemon - - * `tgen` : topogen object - * `router`: Device under test - """ - - logger.debug("Entering lib API: start_router") - - try: - router_list = tgen.routers() - - # Router and its daemons would be started and config would - # be loaded to router for each daemon from /etc/frr - router_list[router].start() - - except Exception as e: - errormsg = traceback.format_exc() - logger.error(errormsg) - return errormsg - - logger.debug("Exiting lib API: start_router()") - - def addKernelRoute( tgen, router, intf, group_addr_range, next_hop=None, src=None, del_action=None ): @@ -3760,6 +3705,43 @@ def verify_bgp_community(tgen, addr_type, router, network, input_dict=None): return True +def get_ipv6_linklocal_address(topo, node, intf): + """ + API to get the link local ipv6 address of a perticular interface + + Parameters + ---------- + * `node`: node on which link local ip to be fetched. + * `intf` : interface for which link local ip needs to be returned. + * `topo` : base topo + + Usage + ----- + result = get_ipv6_linklocal_address(topo, 'r1', 'r2') + + Returns link local ip of interface between r1 and r2. + + Returns + ------- + 1) link local ipv6 address from the interface + 2) errormsg - when link local ip not found + """ + tgen = get_topogen() + ext_nh = tgen.net[node].get_ipv6_linklocal() + req_nh = topo[node]['links'][intf]['interface'] + llip = None + for llips in ext_nh: + if llips[0] == req_nh: + llip = llips[1] + logger.info("Link local ip found = %s", llip) + return llip + + errormsg = "Failed: Link local ip not found on router {}, "\ + "interface {}".format(node, intf) + + return errormsg + + def verify_create_community_list(tgen, input_dict): """ API is to verify if large community list is created for any given DUT in |
