def common_setup_teardown(duthosts, rand_one_dut_hostname, is_dualtor, is_quagga, ptfhost, setup_interfaces): duthost = duthosts[rand_one_dut_hostname] mg_facts = duthost.minigraph_facts(host=duthost.hostname)["ansible_facts"] conn0, conn1 = setup_interfaces dut_asn = mg_facts["minigraph_bgp_asn"] dut_type = '' for k, v in mg_facts['minigraph_devices'].iteritems(): if k == duthost.hostname: dut_type = v['type'] if dut_type == 'ToRRouter': neigh_type = 'LeafRouter' else: neigh_type = 'ToRRouter' bgp_neighbors = ( BGPNeighbor( duthost, ptfhost, "pseudoswitch0", conn0["neighbor_addr"].split("/")[0], NEIGHBOR_ASN0, conn0["local_addr"].split("/")[0], dut_asn, NEIGHBOR_PORT0, neigh_type, is_multihop=is_quagga or is_dualtor ), BGPNeighbor( duthost, ptfhost, "pseudoswitch1", conn1["neighbor_addr"].split("/")[0], NEIGHBOR_ASN1, conn1["local_addr"].split("/")[0], dut_asn, NEIGHBOR_PORT1, neigh_type, is_multihop=is_quagga or is_dualtor ) ) return bgp_neighbors
def common_setup_teardown(duthosts, enum_rand_one_per_hwsku_frontend_hostname, is_dualtor, is_quagga, ptfhost, setup_interfaces, tbinfo): duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname] mg_facts = duthost.get_extended_minigraph_facts(tbinfo) conn0, conn1 = setup_interfaces dut_asn = mg_facts["minigraph_bgp_asn"] dut_type = '' for k, v in mg_facts['minigraph_devices'].iteritems(): if k == duthost.hostname: dut_type = v['type'] if 'ToRRouter' in dut_type: neigh_type = 'LeafRouter' else: neigh_type = 'ToRRouter' bgp_neighbors = (BGPNeighbor(duthost, ptfhost, "pseudoswitch0", conn0["neighbor_addr"].split("/")[0], NEIGHBOR_ASN0, conn0["local_addr"].split("/")[0], dut_asn, NEIGHBOR_PORT0, neigh_type, is_multihop=is_quagga or is_dualtor), BGPNeighbor(duthost, ptfhost, "pseudoswitch1", conn1["neighbor_addr"].split("/")[0], NEIGHBOR_ASN1, conn1["local_addr"].split("/")[0], dut_asn, NEIGHBOR_PORT1, neigh_type, is_multihop=is_quagga or is_dualtor)) return bgp_neighbors
def bgp_slb_neighbor(duthosts, rand_one_dut_hostname, setup_interfaces, ptfhost, slb_neighbor_asn): duthost = duthosts[rand_one_dut_hostname] mg_facts = duthost.minigraph_facts(host=duthost.hostname)["ansible_facts"] dut_asn = mg_facts["minigraph_bgp_asn"] conn = setup_interfaces[0] bgp_neighbor = BGPNeighbor(duthost, ptfhost, "pseudoswitch0", conn["neighbor_addr"].split("/")[0], slb_neighbor_asn, conn["local_addr"].split("/")[0], dut_asn, NEIGHBOR_EXABGP_PORT, "dynamic", is_passive=True) return bgp_neighbor