本文整理汇总了Python中test_dm_utils.FakeDeviceConnect类的典型用法代码示例。如果您正苦于以下问题:Python FakeDeviceConnect类的具体用法?Python FakeDeviceConnect怎么用?Python FakeDeviceConnect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FakeDeviceConnect类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_dm_instance
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()
开发者ID:cijohnson,项目名称:contrail-controller,代码行数:7,代码来源:test_dm_infra.py
示例2: check_spine_evpn_type5_config
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))
开发者ID:rombie,项目名称:contrail-controller,代码行数:29,代码来源:test_dm_qfx_basic.py
示例3: check_spine_bogus_lo0_ip
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")
开发者ID:rombie,项目名称:contrail-controller,代码行数:30,代码来源:test_dm_qfx_basic.py
示例4: check_l2_evpn_vrf_targets
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)
开发者ID:rombie,项目名称:contrail-controller,代码行数:7,代码来源:test_dm_qfx_basic.py
示例5: check_lacp_config
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)
开发者ID:rombie,项目名称:contrail-controller,代码行数:28,代码来源:test_dm_qfx_basic.py
示例6: check_interface_ip_config
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
开发者ID:Juniper,项目名称:contrail-controller,代码行数:32,代码来源:test_dm_networks.py
示例7: check_evpn_config
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
开发者ID:Juniper,项目名称:contrail-controller,代码行数:31,代码来源:test_dm_networks.py
示例8: check_firewall_config
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")
开发者ID:rombie,项目名称:contrail-controller,代码行数:29,代码来源:test_dm_qfx_basic.py
示例9: check_ri_config
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)
开发者ID:rombie,项目名称:contrail-controller,代码行数:9,代码来源:test_dm_qfx_basic.py
示例10: check_chassis_config
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)
开发者ID:rombie,项目名称:contrail-controller,代码行数:10,代码来源:test_dm_qfx_basic.py
示例11: check_tunnel_source_ip
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
开发者ID:cijohnson,项目名称:contrail-controller,代码行数:10,代码来源:test_dm_bgp.py
示例12: check_switch_options_export_policy_config
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)
开发者ID:rombie,项目名称:contrail-controller,代码行数:10,代码来源:test_dm_qfx_basic.py
示例13: check_l2_evpn_proto_config
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")
开发者ID:rombie,项目名称:contrail-controller,代码行数:11,代码来源:test_dm_qfx_basic.py
示例14: check_vlans_config
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))
开发者ID:cijohnson,项目名称:contrail-controller,代码行数:11,代码来源:test_dm_qfx_basic.py
示例15: check_lo0_ip_config
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
开发者ID:cijohnson,项目名称:contrail-controller,代码行数:11,代码来源:test_dm_bgp.py
示例16: check_switch_options_config
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)
开发者ID:cijohnson,项目名称:contrail-controller,代码行数:13,代码来源:test_dm_qfx_basic.py
示例17: check_policy_options_config
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))
开发者ID:rombie,项目名称:contrail-controller,代码行数:14,代码来源:test_dm_qfx_basic.py
示例18: check_ri_vlans_config
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))
开发者ID:cijohnson,项目名称:contrail-controller,代码行数:15,代码来源:test_dm_qfx_basic.py
示例19: check_dm_bgp_export_policy
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
开发者ID:cijohnson,项目名称:contrail-controller,代码行数:15,代码来源:test_dm_bgp.py
示例20: check_esi_config
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")
开发者ID:cijohnson,项目名称:contrail-controller,代码行数:17,代码来源:test_dm_qfx_basic.py
注:本文中的test_dm_utils.FakeDeviceConnect类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论