def test_dm_instance(self): FakeDeviceConnect.reset() kill_device_manager(TestInfraDM._dm_greenlet) self.check_dm_instance() TestInfraDM._dm_greenlet = gevent.spawn(launch_device_manager, self._cluster_id, TestInfraDM._api_server_ip, TestInfraDM._api_server_port) wait_for_device_manager_up()
def check_lacp_config(self, ae_name, esi, pi_list): config = FakeDeviceConnect.get_xml_config() interfaces = self.get_interfaces(config, ae_name) if not interfaces: raise Exception("No AE Config generated") found = False for intf in interfaces: if not intf.get_aggregated_ether_options() or not \ intf.get_aggregated_ether_options().get_lacp(): continue lacp = intf.get_aggregated_ether_options().get_lacp() if lacp.get_active() is not None and lacp.get_admin_key() and \ lacp.get_system_id() and lacp.get_system_priority(): if esi[-17:] == lacp.get_system_id(): found = True break if not found: raise Exception("AE interface config is not correct: " + esi) for pi in pi_list or []: interfaces = self.get_interfaces(config, pi) found = False for intf in interfaces or []: if intf.get_gigether_options() and \ intf.get_gigether_options().get_ieee_802_3ad(): found = True break if not found: raise Exception("AE membership config not generated: " + pi)
def check_l2_evpn_vrf_targets(self, target_id): config = FakeDeviceConnect.get_xml_config() protocols = config.get_protocols() evpn = protocols.get_evpn() options = evpn.get_vni_options() vni = options.get_vni()[0] self.assertEqual(vni.get_vrf_target().get_community(), target_id)
def check_spine_bogus_lo0_ip(self, int_vn): vrf_name = DMUtils.make_vrf_name(int_vn.fq_name[-1], int_vn.virtual_network_network_id, "l3") config = FakeDeviceConnect.get_xml_config() ris = self.get_routing_instances(config, vrf_name) if not ris: raise Exception("No RI Config found for internal vn: " + vrf_name) ri = ris[0] intfs = ri.get_interface() if not intfs: raise Exception("No interfaces Config found for internal vn: " + vrf_name) found = False ifl_num = str(1000 + int(int_vn.virtual_network_network_id)) bogus_lo0 = "lo0." + ifl_num for intf in intfs: if intf.name == bogus_lo0: found = True break if not found: raise Exception("No lo0 interface Config found for internal vn: " + vrf_name) interfaces = self.get_interfaces(config) if not interfaces: raise Exception("Interface Config not lo0") found = False for intf in interfaces: if intf.name == "lo0" and intf.get_unit() and intf.get_unit()[0].get_name() == ifl_num: found = True if not found: raise Exception("Lo0 Interface unit not found")
def check_spine_evpn_type5_config(self, int_vn, lr_obj): vrf_name = DMUtils.make_vrf_name(int_vn.fq_name[-1], int_vn.virtual_network_network_id, "l3") config = FakeDeviceConnect.get_xml_config() ris = self.get_routing_instances(config, vrf_name) if not ris: raise Exception("No RI Config found for internal vn %s" %vrf_name) ri = ris[0] internal_vn_name = DMUtils.get_lr_internal_vn_name(lr_obj.uuid) vn_fq = lr_obj.get_fq_name()[:-1] + [internal_vn_name] vn_obj = self._vnc_lib.virtual_network_read(fq_name=vn_fq) vn_obj_properties = vn_obj.get_virtual_network_properties() # check ri has protocol evpn if not ri.protocols: raise Exception("protocol not present in internal vn %s" %vrf_name) if not ri.protocols.evpn: raise Exception("evpn not present in ri_protocols for internal vn \ %s" %vrf_name) # get ip_prefix config ip_pfx_obj = ri.protocols.evpn.ip_prefix_support vnc_vni = vn_obj_properties.vxlan_network_identifier if ip_pfx_obj.encapsulation != "vxlan": raise Exception("vxlan encaps not set in ip_prefix for int vn \ %s" %vrf_name) if (ip_pfx_obj.vni != '1111') or (vnc_vni != '1111'): raise Exception("vni mismatch for int vn %s: \ in vnc %s, confiugured %s" %(vrf_name, vnc_vni, ip_pfx_obj.vni))
def check_interface_ip_config(self, if_name='', ri_name='', ip_check='', ip_type='v4', network_id='', is_free=False): check = False if is_free: check = True config = FakeDeviceConnect.get_xml_config() ifl_num = DMUtils.compute_lo0_unit_number(network_id) intfs = self.get_interfaces(config, if_name) found = False for intf in intfs or []: ips = self.get_ip_list(intf, ip_type, ifl_num) if ip_check in ips: found = True break if not found: self.assertTrue(check) ris = self.get_routing_instances(config, ri_name) if not ris: self.assertTrue(check) ri = ris[0] intfs = ri.get_interface() or [] found = False for intf in intfs: if intf.get_name() == if_name + "." + ifl_num: found = True break if not found: self.assertTrue(check) return
def check_evpn_config(self, global_encap, vn_obj, interfaces=[]): vrf_name_l2 = DMUtils.make_vrf_name(vn_obj.fq_name[-1], vn_obj.virtual_network_network_id, 'l2') network_id = vn_obj.get_virtual_network_network_id() vn_obj_properties = vn_obj.get_virtual_network_properties() vxlan_id = vn_obj_properties.get_vxlan_network_identifier() fwd_mode = vn_obj_properties.get_forwarding_mode() config = FakeDeviceConnect.get_xml_config() ri = self.get_routing_instances(config, vrf_name_l2)[0] ri_intf = "irb." + str(network_id) if fwd_mode == 'l2_l3' else None protocols = ri.get_protocols() intfs = [] if global_encap in ['MPLSoGRE', 'MPLSoUDP']: self.assertEqual(ri.get_instance_type(), 'evpn') self.assertEqual(ri.get_vlan_id(), 'none') self.assertEqual(ri.get_routing_interface(), ri_intf) intfs = protocols.get_evpn().get_interface() if interfaces else [] if global_encap == 'VXLAN': self.assertEqual(protocols.get_evpn().get_encapsulation(), 'vxlan') bd = ri.get_bridge_domains().get_domain()[0] self.assertEqual(ri.get_instance_type(), 'virtual-switch') self.assertEqual(bd.name, "bd-" + str(vxlan_id)) self.assertEqual(bd.get_vlan_id(), 'none') self.assertEqual(bd.get_routing_interface(), ri_intf) intfs = bd.get_interface() or [] ifnames = [intf.name for intf in intfs] self.assertTrue(set(interfaces or []) <= set(ifnames)) return
def check_firewall_config(self, fnames, check=True): config = FakeDeviceConnect.get_xml_config() fwalls = config.get_firewall() if not fwalls or not fwalls.get_family() or not fwalls.get_family().get_ethernet_switching(): if check: raise Exception("No eth firewalls configured") else: return ff = fwalls.get_family().get_ethernet_switching().get_filter() if check: if not ff: raise Exception("No eth firewall filter configured") elif ff: raise Exception("firewall filters still configured") else: return conf_filters = [f.name for f in ff] for fname in fnames: if fname not in conf_filters: raise Exception("firewall filter %s configured"%(fname)) if check: found = False for f in ff or []: for term in f.get_term() or []: if term.name == 'allow-dns-dhcp': found = True break if not found: raise Exception("firewall filter default term: allow-dhcp-dns not found")
def check_ri_config(self, vn_obj, vn_mode='l2', check=True): vrf_name = DMUtils.make_vrf_name(vn_obj.fq_name[-1], vn_obj.virtual_network_network_id, vn_mode) config = FakeDeviceConnect.get_xml_config() ris = self.get_routing_instances(config, vrf_name) if not check and ris: raise Exception("Routing Instances Present for: " + vrf_name) if check and not ris: raise Exception("Routing Instances not Present for: " + vrf_name)
def check_switch_options_export_policy_config(self, should_present=True): config = FakeDeviceConnect.get_xml_config() switch_opts = config.get_switch_options() self.assertIsNotNone(switch_opts) exports = switch_opts.get_vrf_export() or [] export_name = DMUtils.get_switch_export_policy_name() if not should_present: self.assertNotIn(export_name, exports) else: self.assertIn(export_name, exports)
def check_tunnel_source_ip(self, ip_check='', look_for=True): config = FakeDeviceConnect.get_xml_config() tunnels = self.get_dynamic_tunnels(config) or DynamicTunnels() if look_for: self.assertIn(ip_check, [tunnel.source_address for tunnel in tunnels.get_dynamic_tunnel()]) else: self.assertNotIn(ip_check, [tunnel.source_address for tunnel in tunnels.get_dynamic_tunnel()]) return
def check_chassis_config(self): config = FakeDeviceConnect.get_xml_config() chassis = config.get_chassis() if not chassis: raise Exception("No Chassis Config generated") aggr_dv = chassis.get_aggregated_devices() eth = aggr_dv.get_ethernet() dv_count = eth.get_device_count() device_count = DMUtils.get_max_ae_device_count() self.assertEqual(device_count, dv_count)
def check_vlans_config(self, vn_obj, vni, vn_mode): vrf_name = DMUtils.make_vrf_name(vn_obj.fq_name[-1], vn_obj.virtual_network_network_id, vn_mode) config = FakeDeviceConnect.get_xml_config() vlans = config.get_vlans() self.assertIsNotNone(vlans) vlans = vlans.get_vlan() or [] vlan_name = vrf_name[1:] for vlan in vlans: if vlan.get_name() == vlan_name and str(vlan.get_vxlan().get_vni()) == str(vni): return raise Exception("Vlan Config Not Found: %s"%(vlan_name))
def check_l2_evpn_proto_config(self, vn_obj, vni): config = FakeDeviceConnect.get_xml_config() protocols = config.get_protocols() evpn_config = protocols.get_evpn() if not evpn_config or not evpn_config.get_vni_options(): raise Exception("No Correct EVPN Config generated") vni_options = evpn_config.get_vni_options() for vni_op in vni_options.get_vni() or []: if vni_op.name == str(vni) and vni_op.vrf_target.community: return raise Exception("No Correct EVPN Config generated")
def check_lo0_ip_config(self, ip_check=''): config = FakeDeviceConnect.get_xml_config() intfs = self.get_interfaces(config, "lo0") if ip_check: ips = self.get_ip_list(intfs[0], "v4", "0") self.assertEqual(ip_check, ips[0]) else: if not intfs or not self.get_ip_list(intfs[0], "v4", "0"): return self.assertTrue(False) return
def check_switch_options_config(self, vn_obj, vn_mode): vrf_name = DMUtils.make_vrf_name(vn_obj.fq_name[-1], vn_obj.virtual_network_network_id, vn_mode) config = FakeDeviceConnect.get_xml_config() switch_opts = config.get_switch_options() self.assertIsNotNone(switch_opts) self.assertEqual(switch_opts.get_vtep_source_interface(), "lo0.0") import_name = DMUtils.make_import_name(vrf_name) imports = switch_opts.get_vrf_import() or [] self.assertIn(import_name, imports) export_name = DMUtils.make_export_name(vrf_name) exports = switch_opts.get_vrf_export() or [] self.assertNotIn(export_name, exports)
def check_policy_options_config(self, should_present=True): config = FakeDeviceConnect.get_xml_config() try: policy_opts = config.get_policy_options() self.assertIsNotNone(policy_opts) comms = policy_opts.get_community() or [] self.assertIsNotNone(comms) comm_name = DMUtils.get_switch_export_community_name() if comm_name not in [comm.name for comm in comms]: raise Exception("comm name : " + comm_name + " not found") except Exception as e: if not should_present: return raise Exception("Policy Options not found: " + str(e))
def check_dm_bgp_export_policy(self, product): config = FakeDeviceConnect.get_xml_config() bgp_groups = self.get_bgp_groups(config) for gp in bgp_groups or []: if gp.get_type() == 'internal': if 'qfx5' not in product: self.assertEqual(gp.get_export(), DMUtils.make_ibgp_export_policy_name()) else: self.assertIsNone(gp.get_export()) return if gp.get_type() == 'external': self.assertThat(gp.get_export() != DMUtils.make_ibgp_export_policy_name()) return self.assertTrue(False) return
def check_ri_vlans_config(self, vn_obj, vni, vn_mode='l3'): vrf_name = DMUtils.make_vrf_name(vn_obj.fq_name[-1], vn_obj.virtual_network_network_id, vn_mode) config = FakeDeviceConnect.get_xml_config() ris = self.get_routing_instances(config, ri_name) if not ris: self.assertTrue(check) ri = ris[0] vlans = ri.get_vlans() or [] vlans = vlans.get_vlan() or [] vlan_name = vrf_name[1:] for vlan in vlans: if vlan.get_name() == vlan_name and vlan.get_vlan_id() == str(vni): return raise Exception("RI Vlan Config Not Found: %s"%(vlan_name))
def check_l2_evpn_config(self, ae_name, vlan_id): config = FakeDeviceConnect.get_xml_config() interfaces = self.get_interfaces(config, ae_name) if not interfaces: raise Exception("No AE Config generated") found = False for intf in interfaces: if intf.get_encapsulation() != "extended-vlan-bridge" or \ not intf.get_unit(): continue unit = intf.get_unit()[0] if not unit.get_vlan_id() or str(unit.get_vlan_id()) != str(vlan_id): continue found = True break if not found: raise Exception("l2 evpn config for ae intf not correct: " + ae_name)
def check_esi_config(self, pi_name, esi_value, should_present=True): config = FakeDeviceConnect.get_xml_config() if should_present: interfaces = self.get_interfaces(config, pi_name) if not interfaces: raise Exception("No Interface Config generated") intf = interfaces[0] self.assertIsNotNone(intf.get_esi()) self.assertIsNotNone(intf.get_esi().get_all_active()) self.assertEqual(intf.get_esi().get_identifier(), esi_value) else: interfaces = self.get_interfaces(config, pi_name) if not interfaces: return intf = interfaces[0] if intf.get_esi(): raise Exception("ESI Config still exist")
def check_auto_export_config(self, vrf_name_l3='', ip_type='v4', check=True): config = FakeDeviceConnect.get_xml_config() ri = self.get_routing_instances(config, vrf_name_l3)[0] ri_opts = ri.get_routing_options() auto_export = ri_opts.get_auto_export() family = auto_export.get_family() if ip_type == 'v4': if check: self.assertIsNotNone(family.get_inet().get_unicast()) else: self.assertTrue(not family.get_inet() or not family.get_inet().get_unicast()) elif ip_type == 'v6': if check: self.assertIsNotNone(family.get_inet6().get_unicast()) else: self.assertTrue(not family.get_inet6() or not family.get_inet6().get_unicast())
def check_acl_config(self, intf_name, input_list, check=True): config = FakeDeviceConnect.get_xml_config() interfaces = self.get_interfaces(config, intf_name) if not interfaces: raise Exception("Interface Config not generated : " + intf_name) if_config = interfaces[0] if not if_config.get_unit(): raise Exception("No Units are configured : " + intf_name) unit = if_config.get_unit()[0] if check: if not unit.get_family() or not unit.get_family().get_ethernet_switching(): raise Exception("No Ethernet Family configured : " + intf_name) elif unit.get_family() and unit.get_family().get_ethernet_switching() and eth.get_filter().get_input_list(): raise Exception("Filters are still configured") else: return eth = unit.get_family().get_ethernet_switching() flist = eth.get_filter().get_input_list() for iput in input_list: if iput not in flist: raise Exception("filter %s not attached %s"%(iput, intf_name))
def check_l2_evpn_vlan_config(self, vn_obj, vn_mode, intf_name, intf_unit): vrf_name = DMUtils.make_vrf_name(vn_obj.fq_name[-1], \ vn_obj.virtual_network_network_id, vn_mode) config = FakeDeviceConnect.get_xml_config() vlans = config.get_vlans() self.assertIsNotNone(vlans) vlans = vlans.get_vlan() or [] vlan_name = vrf_name[1:] interfaces = self.get_interfaces(config, intf_name) if not interfaces: raise Exception("No Vlan Interface Config: " + intf_name) if_config = interfaces[0] for vlan in vlans: if vlan.get_name() == vlan_name: intf = vlan.get_interface()[0] ifl_name = intf_name + "." + intf_unit if intf.get_name() != ifl_name: raise Exception("intf-vlan not correct:" + intf.get_name()) else: return raise Exception("vlan interface config is not correct")
def check_firewall_config(self, fnames, check=True): config = FakeDeviceConnect.get_xml_config() fwalls = config.get_firewall() if not fwalls or not fwalls.get_family() or not fwalls.get_family( ).get_ethernet_switching(): if check: raise Exception("No eth firewalls configured") else: return ff = fwalls.get_family().get_ethernet_switching().get_filter() if check: if not ff: raise Exception("No eth firewall filter configured") elif ff: raise Exception("firewall filters still configured") else: return conf_filters = [f.name for f in ff] for fname in fnames: if fname not in conf_filters: raise Exception("firewall filter %s configured" % (fname))
def check_esi_config(self, pi_name, esi_value, should_present=True): config = FakeDeviceConnect.get_xml_config() if should_present: interfaces = self.get_interfaces(config, pi_name) if not interfaces: raise Exception("No Interface Config generated") found = False for intf in interfaces: if intf.get_esi() and intf.get_esi().get_all_active() is not None and \ intf.get_esi().get_identifier() == esi_value: found = True break if not found: raise Exception("no interface has esi config: " + pi_name) else: interfaces = self.get_interfaces(config, pi_name) if not interfaces: return intf = interfaces[0] if intf.get_esi(): raise Exception("ESI Config still exist")
def check_switch_options_config(self, vn_obj, vn_mode, role): vrf_name = DMUtils.make_vrf_name(vn_obj.fq_name[-1], vn_obj.virtual_network_network_id, vn_mode) config = FakeDeviceConnect.get_xml_config() switch_opts = config.get_switch_options() self.assertIsNotNone(switch_opts) self.assertEqual(switch_opts.get_vtep_source_interface(), "lo0.0") import_name = DMUtils.make_import_name(vrf_name) imports = switch_opts.get_vrf_import() or [] if (role =='spine' and vn_mode == 'l2' and '_contrail_lr_internal_vn' in vrf_name) or \ (role =='leaf' and vn_mode == 'l3'): self.assertNotIn(import_name, imports) else: self.assertIn(import_name, imports) export_name = DMUtils.make_export_name(vrf_name) exports = switch_opts.get_vrf_export() or [] # export policy is applicable only for spine/l3 if (role =='spine' and vn_mode == 'l2' and '_contrail_lr_internal_vn' in vrf_name) or \ (role =='leaf'): self.assertNotIn(export_name, exports) else: self.assertIn(export_name, exports)
def check_l2_evpn_native_vlan_config(self, vn_obj, vn_mode, intf_name): vrf_name = DMUtils.make_vrf_name(vn_obj.fq_name[-1], vn_obj.virtual_network_network_id, vn_mode) config = FakeDeviceConnect.get_xml_config() vlans = config.get_vlans() self.assertIsNotNone(vlans) vlans = vlans.get_vlan() or [] vlan_name = vrf_name[1:] interfaces = self.get_interfaces(config, intf_name) if not interfaces: raise Exception("Interface Config not generated(native vlan check) : " + intf_name) if_config = interfaces[0] if if_config.get_unit()[0].get_name() != '0' or if_config.get_unit()[0].get_vlan_id() != '4094': raise Exception ("Native vlan config properly generated for intf: " + intf_name) for vlan in vlans: if vlan.get_name() == vlan_name: intf = vlan.get_interface()[0] ifl_name = intf_name + ".0" if intf.get_name() != ifl_name: raise Exception ("interface-vlan membership not set") else: return raise Exception ("native vlan interface config not generated")
def check_spine_irb_config(self, int_vn, vn_obj): vrf_name = DMUtils.make_vrf_name(int_vn.fq_name[-1], int_vn.virtual_network_network_id, "l3") config = FakeDeviceConnect.get_xml_config() ris = self.get_routing_instances(config, vrf_name) if not ris: raise Exception("No RI Config found for internal vn: " + vrf_name) ri = ris[0] irb_name = "irb." + str(vn_obj.virtual_network_network_id) # check if irb is attached to internal RI intfs = ri.get_interface() if not intfs: raise Exception("No interfaces Config found for internal vn: " + vrf_name) found = False for intf in intfs: if intf.name == irb_name: found = True break if not found: raise Exception("No IRB interface Config found for internal vn: " + vrf_name) # check client VNs, VLans Config vrf_name = DMUtils.make_vrf_name(vn_obj.fq_name[-1], vn_obj.virtual_network_network_id, "l2") vlans = config.get_vlans() self.assertIsNotNone(vlans) vlans = vlans.get_vlan() or [] found = False vlan = None # check bridges (vlans) are created for each client VN, and placed irb interface for vl in vlans: if vl.name == vrf_name[1:]: found = True vlan = vl break if not vlan: raise Exception("No VLAN config found for vn: " + vrf_name) if vlan.get_l3_interface() != irb_name: raise Exception("No IRB config attached to VLAN for vn: " + vrf_name)
def check_ri_vlans_config(self, vn_obj, vni, vn_mode='l3', check=True): vrf_name = DMUtils.make_vrf_name(vn_obj.fq_name[-1], vn_obj.virtual_network_network_id, vn_mode) config = FakeDeviceConnect.get_xml_config() ris = self.get_routing_instances(config, vrf_name) ri = None vlans = None try: ri = ris[0] vlans = ri.get_vlans().get_vlan() or [] except: if check: raise Exception("RI Vlan Config Not Found: %s"%(vrf_name)) if not vlans and not check: return vlan_name = vrf_name[1:] for vlan in vlans: if vlan.get_name() == vlan_name and vlan.get_vlan_id() == str(vni): if not check: raise Exception("RI Vlan Config Found: %s"%(vrf_name)) return if check: raise Exception("RI Vlan Config Not Found: %s"%(vlan_name))
def check_l2_evpn_native_vlan_config(self, vn_obj, vn_mode, intf_name): vrf_name = DMUtils.make_vrf_name(vn_obj.fq_name[-1], vn_obj.virtual_network_network_id, vn_mode) config = FakeDeviceConnect.get_xml_config() vlans = config.get_vlans() self.assertIsNotNone(vlans) vlans = vlans.get_vlan() or [] vlan_name = vrf_name[1:] interfaces = self.get_interfaces(config, intf_name) if not interfaces: raise Exception("Interface Config not generated(native vlan check) : " + intf_name) if_config = interfaces[0] if if_config.get_unit()[0].get_name() != '0' or \ if_config.get_unit()[0].get_vlan_id() != '4094' or \ if_config.get_native_vlan_id() != '4094': raise Exception ("Native vlan config properly generated for intf: " + intf_name) for vlan in vlans: if vlan.get_name() == vlan_name: intf = vlan.get_interface()[0] ifl_name = intf_name + ".0" if intf.get_name() != ifl_name: raise Exception ("interface-vlan membership not set") else: return raise Exception ("native vlan interface config not generated")
def check_router_id_config(self, ip_check=''): config = FakeDeviceConnect.get_xml_config() ri_opts = config.get_routing_options() self.assertIsNotNone(ri_opts) self.assertEqual(ip_check, ri_opts.get_router_id())
def check_bgp_auth_config(self, bgp_type, key): config = FakeDeviceConnect.get_xml_config() bgp_groups = self.get_bgp_groups(config, bgp_type) self.assertIn(key, [gp.get_authentication_key() for gp in bgp_groups or []]) return
def check_dm_bgp_hold_time_config(self, bgp_type, hold_time): config = FakeDeviceConnect.get_xml_config() bgp_groups = self.get_bgp_groups(config, bgp_type) self.assertIn(hold_time, [gp.get_hold_time() for gp in bgp_groups or []]) return
def tearDown(self): FakeDeviceConnect.reset() FakeJobHandler.reset() super(DMTestCase, self).tearDown()
def tearDown(self): FakeDeviceConnect.reset() super(DMTestCase, self).tearDown()
def test_dm_plugins(self): # check basic valid vendor, product plugin bgp_router, pr = self.create_router('router100' + self.id(), '1.1.1.1', product=self.product) self.check_dm_plugin() pr_config = FakeDeviceConnect.params.get("pr_config") # update valid another vendor, product; another plugin should be found FakeDeviceConnect.reset() FakeNetconfManager.set_model('qfx5110') pr.physical_router_vendor_name = "juniper" pr.physical_router_product_name = "qfx5110" self._vnc_lib.physical_router_update(pr) self.check_dm_plugin() FakeDeviceConnect.reset() FakeNetconfManager.set_model('qfx5100') pr.physical_router_vendor_name = "juniper" pr.physical_router_product_name = "qfx5100" self._vnc_lib.physical_router_update(pr) self.check_dm_plugin() FakeDeviceConnect.reset() FakeNetconfManager.set_model('qfx5200') pr.physical_router_vendor_name = "juniper" pr.physical_router_product_name = "qfx5200" self._vnc_lib.physical_router_update(pr) self.check_dm_plugin() FakeDeviceConnect.reset() FakeNetconfManager.set_model('qfx5300') pr.physical_router_vendor_name = "juniper" pr.physical_router_product_name = "qfx5300" self._vnc_lib.physical_router_update(pr) self.check_dm_plugin(is_valid=False) FakeDeviceConnect.reset() FakeNetconfManager.set_model('qfx10000') pr.physical_router_vendor_name = "juniper" pr.physical_router_product_name = "qfx10000" self._vnc_lib.physical_router_update(pr) self.check_dm_plugin() # check invalid vendor, product; no plugin FakeDeviceConnect.reset() FakeNetconfManager.set_model('cix') pr.physical_router_vendor_name = "cix" pr.physical_router_product_name = "cix100" self._vnc_lib.physical_router_update(pr) self.check_dm_plugin(is_valid=False) # update valid vendor, product; plugin should be found, config should be pushed FakeDeviceConnect.reset() FakeNetconfManager.set_model('mx80') pr.physical_router_vendor_name = "juniper" pr.physical_router_product_name = "mx" self._vnc_lib.physical_router_update(pr) self.check_dm_plugin() FakeDeviceConnect.reset() FakeNetconfManager.set_model('mx480') pr.physical_router_vendor_name = "juniper" pr.physical_router_product_name = "mx480" self._vnc_lib.physical_router_update(pr) self.check_dm_plugin() # device connection is down, config should not be pushed pr_config = FakeDeviceConnect.params.get("pr_config") pr_config._nc_manager.connected = False self.assertFalse(pr_config.is_connected()) FakeDeviceConnect.reset() self.set_hold_time(bgp_router, 100) self._vnc_lib.bgp_router_update(bgp_router) self.check_dm_plugin(False) # device connection is up, config should be auto pushed pr_config._nc_manager.connected = True self.check_dm_plugin() # unset vnc-managed, should generate delete groups config pr.physical_router_vnc_managed = False self._vnc_lib.physical_router_update(pr) self.check_dm_delete_groups() # set vnc-managed, should generate groups config again pr.physical_router_vnc_managed = True self._vnc_lib.physical_router_update(pr) self.check_if_xml_is_generated() bgp_router_fq = bgp_router.get_fq_name() pr_fq = pr.get_fq_name() self.delete_routers(bgp_router, pr) self.wait_for_routers_delete(bgp_router_fq, pr_fq)
def check_bgp_auth_neighbour_config(self, bgp_type, key): config = FakeDeviceConnect.get_xml_config() bgp_groups = self.get_bgp_groups(config, bgp_type) self.assertIn(key, [neigh.get_authentication_key() for neigh in itertools.chain.from_iterable([gp.get_neighbor() for gp in bgp_groups or []])]) return