本文整理汇总了Python中tcutils.util.get_random_cidr函数的典型用法代码示例。如果您正苦于以下问题:Python get_random_cidr函数的具体用法?Python get_random_cidr怎么用?Python get_random_cidr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_random_cidr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_2_legs
def create_2_legs(self):
vn1_name = get_random_name('bgpaas_vn')
vn1_subnets = [get_random_cidr()]
vn1_fixture = self.create_vn(vn1_name, vn1_subnets)
test_vm = self.create_vm(vn1_fixture, 'test_vm',
image_name='ubuntu-traffic')
assert test_vm.wait_till_vm_is_up()
vn2_name = get_random_name('bgpaas_vn')
vn2_subnets = [get_random_cidr()]
vn2_fixture = self.create_vn(vn2_name, vn2_subnets)
bgpaas_vm1 = self.useFixture(
VMFixture(
project_name=self.inputs.project_name,
connections=self.connections,
vn_objs=[
vn1_fixture.obj,
vn2_fixture.obj],
vm_name='bgpaas_vm1',
node_name=None,
image_name='vsrx'))
assert bgpaas_vm1.wait_till_vm_is_up()
ret_dict = {
'vn1_fixture': vn1_fixture,
'vn2_fixture': vn2_fixture,
'test_vm': test_vm,
'bgpaas_vm1': bgpaas_vm1,
}
return ret_dict
示例2: config_svc_mirroring
def config_svc_mirroring(self, service_mode='transparent', *args, **kwargs):
"""Validate the service chaining datapath
Test steps:
1. Create the SI/ST in svc_mode specified.
2. Create vn11/vm1, vn21/vm2
3. Create the policy rule for ICMP/UDP and attach to vn's
4. Send the traffic from vm1 to vm2 and verify if the packets gets mirrored to the analyzer
5. If its a single analyzer only ICMP(5 pkts) will be sent else ICMP and UDP traffic will be sent.
Pass criteria :
count = sent
single node : Pkts mirrored to the analyzer should be equal to 'count'
multinode :Pkts mirrored to the analyzer should be equal to '2xcount'
"""
ci = self.inputs.is_ci_setup()
create_svms = kwargs.get('create_svms', True)
vn1_subnets = [get_random_cidr(af=self.inputs.get_af())]
vn2_subnets = [get_random_cidr(af=self.inputs.get_af())]
vn1_name = get_random_name('left')
vn2_name = get_random_name('right')
st_name = get_random_name("st1")
action_list = []
service_type = 'analyzer'
si_prefix = get_random_name("mirror_si")
policy_name = get_random_name("mirror_policy")
vn1_fixture = self.config_vn(vn1_name, vn1_subnets)
vn2_fixture = self.config_vn(vn2_name, vn2_subnets)
ret_dict = self.verify_svc_chain(service_mode=service_mode,
service_type=service_type,
left_vn_fixture=vn1_fixture,
right_vn_fixture=vn2_fixture,
create_svms=create_svms, **kwargs)
si_fixture = ret_dict['si_fixture']
policy_fixture = ret_dict['policy_fixture']
si_fq_name = si_fixture.fq_name_str
rules = [{'direction': '<>',
'protocol': 'icmp',
'source_network': vn1_fixture.vn_fq_name,
'src_ports': [0, 65535],
'dest_network': vn2_fixture.vn_fq_name,
'dst_ports': [0, 65535],
'action_list': {'simple_action': 'pass',
'mirror_to': {'analyzer_name': si_fq_name}}
},
{'direction': '<>',
'protocol': 'icmp6',
'source_network': vn1_fixture.vn_fq_name,
'src_ports': [0, 65535],
'dest_network': vn2_fixture.vn_fq_name,
'dst_ports': [0, 65535],
'action_list': {'simple_action': 'pass',
'mirror_to': {'analyzer_name': si_fq_name}}
}]
policy_fixture.update_policy_api(rules)
ret_dict['policy_fixture'] = policy_fixture
return ret_dict
示例3: test_rp_interface_static_matrix
def test_rp_interface_static_matrix(self):
'''
1. Create a routing policy with interface-static match and different "to" conditions:med, as-path, local-pref, community.
2. Launch VMs.
3. Attach policy to VN and confirm if policy takes hold.
'''
ret_dict = self.config_basic()
vn_fixture = ret_dict['vn_fixture']
test_vm = ret_dict['test_vm']
test2_vm = ret_dict['test2_vm']
self.static_table_handle = ContrailVncApi(self.vnc_lib, self.logger)
random_cidr = get_random_cidr()
self.intf_table_to_right_obj = self.static_table_handle.create_route_table(
prefixes=[random_cidr],
name=get_random_name('int_table_right'),
parent_obj=self.project.project_obj,
)
id_entry = self.inputs.project_fq_name[0] + ':' + \
self.inputs.project_fq_name[1] + ':' + vn_fixture.vn_name
self.static_table_handle.bind_vmi_to_interface_route_table(
str(test_vm.get_vmi_ids()[id_entry]),
self.intf_table_to_right_obj)
config_dicts = {'vn_fixture':vn_fixture, 'from_term':'protocol', 'sub_from':'interface-static', 'to_term':'med', 'sub_to':'444'}
rp = self.configure_term_routing_policy(config_dicts)
assert self.verify_policy_in_control(vn_fixture, test_vm, search_ip = random_cidr, search_value = '444')
config_dicts = {'vn_fixture':vn_fixture, 'from_term':'protocol', 'sub_from':'interface-static', 'to_term':'local-preference', 'sub_to':'555'}
rp = self.configure_term_routing_policy(config_dicts)
assert self.verify_policy_in_control(vn_fixture, test_vm, search_ip = random_cidr, search_value = '555')
config_dicts = {'vn_fixture':vn_fixture, 'from_term':'protocol', 'sub_from':'interface-static', 'to_term':'as-path', 'sub_to':'666'}
rp = self.configure_term_routing_policy(config_dicts)
assert self.verify_policy_in_control(vn_fixture, test_vm, search_ip = random_cidr, search_value = '666')
assert test_vm.ping_with_certainty(test2_vm.vm_ip)
示例4: create_bgpaas_routes
def create_bgpaas_routes(self):
ret_dict = {}
vn_name = get_random_name('bgpaas_vn')
vn_subnets = [get_random_cidr()]
ret_dict['vn_fixture'] = self.create_vn(vn_name, vn_subnets)
ret_dict['test_vm'] = self.create_vm(ret_dict['vn_fixture'], 'test_vm',
image_name='ubuntu-traffic')
assert ret_dict['test_vm'].wait_till_vm_is_up()
bgpaas_vm1 = self.create_vm(ret_dict['vn_fixture'], 'bgpaas_vm1',image_name='vsrx')
assert bgpaas_vm1.wait_till_vm_is_up()
bgpaas_fixture = self.create_bgpaas(bgpaas_shared=True, autonomous_system=64500, bgpaas_ip_address=bgpaas_vm1.vm_ip)
bgpaas_vm1.wait_for_ssh_on_vm()
port1 = {}
port1['id'] = bgpaas_vm1.vmi_ids[bgpaas_vm1.vn_fq_name]
address_families = []
address_families = ['inet', 'inet6']
autonomous_system = 64500
gw_ip = ret_dict['vn_fixture'].get_subnets()[0]['gateway_ip']
dns_ip = ret_dict['vn_fixture'].get_subnets()[0]['dns_server_address']
neighbors = []
neighbors = [gw_ip, dns_ip]
self.logger.info('We will configure BGP on the two vSRX')
self.config_bgp_on_vsrx(src_vm=ret_dict['test_vm'], dst_vm=bgpaas_vm1, bgp_ip=bgpaas_vm1.vm_ip, lo_ip=bgpaas_vm1.vm_ip,
address_families=address_families, autonomous_system=autonomous_system, neighbors=neighbors, bfd_enabled=False)
bgpaas_vm1.wait_for_ssh_on_vm()
self.attach_vmi_to_bgpaas(port1['id'], bgpaas_fixture)
self.addCleanup(self.detach_vmi_from_bgpaas,port1['id'], bgpaas_fixture)
return ret_dict
示例5: get_random_ip_list
def get_random_ip_list(max_list_length=4):
list_length = random.randint(1, max_list_length)
final_list = []
for i in range(0, list_length):
cidr = get_random_cidr()
random_ip = get_random_ip(cidr)
final_list.append(random_ip)
return final_list
示例6: get_route_dict_list
def get_route_dict_list(cidr, max_length=4):
list_length = random.randint(1, max_length)
final_list = []
for i in range(0, list_length):
route_dict = {'destination': get_random_cidr(),
'nexthop': str(get_random_ip(cidr))}
final_list.append(route_dict)
return final_list
示例7: __init__
def __init__(self, domain='default-domain', project='admin', username=None, password=None):
#
# Domain and project defaults: Do not change until support for
# non-default is tested!
self.domain = domain
self.project = project
self.username = username
self.password = password
#
# Define VN's in the project:
self.vnet_list = [get_random_name('vnet0')]
#
# Define network info for each VN:
if self.project == 'vCenter':
# For vcenter, only one subnet per VN is supported
self.vn_nets = {self.vnet_list[0]: [get_random_cidr(af='v4')]}
else:
self.vn_nets = {self.vnet_list[0]: ['10.1.1.0/24', '11.1.1.0/24']}
#
# Define network policies
self.policy_list = list()
for i in range(10):
self.policy_list.append(get_random_name('policy%d'%i))
self.vn_policy = {self.vnet_list[0]: self.policy_list}
#
# Define VM's
# VM distribution on available compute nodes is handled by nova
# scheduler or contrail vm naming scheme
self.vn_of_vm = {get_random_name('vmc0'): self.vnet_list[0]}
#
# Define network policy rules
self.rules = {}
self.rules[self.policy_list[0]] = [{'direction': '>', 'protocol': 'udp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [0, 0]}, {'direction': '>', 'protocol': 'udp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [1, 1]}, {'direction': '>', 'protocol': 'udp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [2, 2]}, {'direction': '>', 'protocol': 'udp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [3, 3]}]
self.rules[self.policy_list[1]] = [{'direction': '>', 'protocol': 'icmp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [0, 0]}, {'direction': '>', 'protocol': 'icmp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [1, 1]}, {'direction': '>', 'protocol': 'icmp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [2, 2]}, {'direction': '>', 'protocol': 'icmp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [3, 3]}]
self.rules[self.policy_list[2]] = [{'direction': '>', 'protocol': 'udp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [0, 0]}, {'direction': '>', 'protocol': 'udp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [1, 1]}, {'direction': '>', 'protocol': 'udp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [2, 2]}, {'direction': '>', 'protocol': 'udp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [3, 3]}]
self.rules[self.policy_list[3]] = [{'direction': '>', 'protocol': 'udp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [0, 0]}, {'direction': '>', 'protocol': 'udp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [1, 1]}, {'direction': '>', 'protocol': 'udp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [2, 2]}, {'direction': '>', 'protocol': 'udp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [3, 3]}]
self.rules[self.policy_list[4]] = [{'direction': '>', 'protocol': 'udp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [0, 0]}, {'direction': '>', 'protocol': 'udp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [1, 1]}, {'direction': '>', 'protocol': 'udp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [2, 2]}, {'direction': '>', 'protocol': 'udp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [3, 3]}]
self.rules[self.policy_list[5]] = [{'direction': '>', 'protocol': 'udp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [0, 0]}, {'direction': '>', 'protocol': 'udp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [1, 1]}, {'direction': '>', 'protocol': 'udp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [2, 2]}, {'direction': '>', 'protocol': 'udp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [3, 3]}]
self.rules[self.policy_list[6]] = [{'direction': '>', 'protocol': 'tcp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [0, 0]}, {'direction': '>', 'protocol': 'tcp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [1, 1]}, {'direction': '>', 'protocol': 'tcp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [2, 2]}, {'direction': '>', 'protocol': 'tcp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [3, 3]}]
self.rules[self.policy_list[7]] = [{'direction': '>', 'protocol': 'tcp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [0, 0]}, {'direction': '>', 'protocol': 'tcp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [1, 1]}, {'direction': '>', 'protocol': 'tcp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [2, 2]}, {'direction': '>', 'protocol': 'tcp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [3, 3]}]
self.rules[self.policy_list[8]] = [{'direction': '>', 'protocol': 'udp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [0, 0]}, {'direction': '>', 'protocol': 'udp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [1, 1]}, {'direction': '>', 'protocol': 'udp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [2, 2]}, {'direction': '>', 'protocol': 'udp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [3, 3]}]
self.rules[self.policy_list[9]] = [{'direction': '>', 'protocol': 'tcp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [0, 0]}, {'direction': '>', 'protocol': 'tcp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [1, 1]}, {'direction': '>', 'protocol': 'tcp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [2, 2]}, {'direction': '>', 'protocol': 'tcp', 'dest_network': self.vnet_list[0], 'source_network': self.vnet_list[0], 'dst_ports': 'any', 'simple_action': 'deny', 'src_ports': [3, 3]}]
示例8: config_basic
def config_basic(self):
vn_name = get_random_name('bgpaas_vn')
vn2_name = get_random_name('bgpaas_vn')
vn_subnets = [get_random_cidr()]
vn2_subnets = [get_random_cidr()]
vn_fixture = self.create_vn(vn_name, vn_subnets)
rt_value = randint(50000, 60000)
vn_fixture.add_route_target(vn_fixture.ri_name, self.inputs.router_asn, rt_value)
vn2_fixture = self.create_vn(vn2_name, vn2_subnets)
vn2_fixture.add_route_target(vn2_fixture.ri_name, self.inputs.router_asn, rt_value)
test_vm = self.create_vm(vn_fixture, 'test_vm',
image_name='cirros')
test2_vm = self.create_vm(vn2_fixture, 'test2_vm', image_name='cirros')
assert test_vm.wait_till_vm_is_up()
assert test2_vm.wait_till_vm_is_up()
ret_dict = {
'vn_fixture' : vn_fixture,
'test_vm' : test_vm,
'test2_vm' : test2_vm,
}
return ret_dict
示例9: create_vn
def create_vn(self, vn_name=None, vn_subnets=None, vxlan_id=None,
enable_dhcp=True):
if not vn_name:
vn_name = get_random_name('vn')
if not vn_subnets:
vn_subnets = [get_random_cidr()]
return self.useFixture(
VNFixture(project_name=self.inputs.project_name,
connections=self.connections,
inputs=self.inputs,
vn_name=vn_name,
subnets=vn_subnets,
vxlan_id=vxlan_id,
enable_dhcp=enable_dhcp))
示例10: create_sub_intf
def create_sub_intf(self, vn_fix_uuid, intf_type, mac_address=None):
vlan = self.vlan
parent_port_vn_subnets = [get_random_cidr(af=self.inputs.get_af())]
parent_port_vn_name = get_random_name( intf_type + "_parent_port_vn")
parent_port_vn_fixture = self.config_vn(parent_port_vn_name, parent_port_vn_subnets)
parent_port = self.setup_vmi(parent_port_vn_fixture.uuid)
mac_address = parent_port.mac_address
port = self.setup_vmi(vn_fix_uuid,
parent_vmi=parent_port.vmi_obj,
vlan_id=vlan,
api_type='contrail',
mac_address=mac_address)
return port, parent_port, parent_port_vn_fixture
示例11: create_interface_static_routes
def create_interface_static_routes(self):
ret_dict = self.config_basic()
self.static_table_handle = ContrailVncApi(self.vnc_lib, self.logger)
random_cidr = get_random_cidr()
self.intf_table_to_right_obj = self.static_table_handle.create_route_table(
prefixes=[random_cidr],
name=get_random_name('int_table_right'),
parent_obj=self.project.project_obj,
)
id_entry = self.inputs.project_fq_name[0] + ':' + \
self.inputs.project_fq_name[1] + ':' + ret_dict['vn_fixture'].vn_name
self.static_table_handle.bind_vmi_to_interface_route_table(
str(ret_dict['test_vm'].get_vmi_ids()[id_entry]),
self.intf_table_to_right_obj)
return ret_dict,random_cidr
示例12: config_basic
def config_basic(self):
vn_name = get_random_name('bgpaas_vn')
vn_subnets = [get_random_cidr()]
vn_fixture = self.create_vn(vn_name, vn_subnets)
test_vm = self.create_vm(vn_fixture, 'test_vm',
image_name='ubuntu-traffic')
assert test_vm.wait_till_vm_is_up()
bgpaas_vm1 = self.create_vm(
vn_fixture, 'bgpaas_vm1', image_name='vsrx')
assert bgpaas_vm1.wait_till_vm_is_up()
ret_dict = {
'vn_fixture': vn_fixture,
'test_vm': test_vm,
'bgpaas_vm1': bgpaas_vm1,
}
return ret_dict
示例13: _get_vn_for_config
def _get_vn_for_config(self,
vn_name,
vn_subnets,
vn_fixture,
vn_name_prefix,
**kwargs):
if vn_fixture:
vn_name = vn_fixture.vn_name
vn_subnets = [x['cidr'] for x in vn_fixture.vn_subnets]
else:
vn_name = vn_name or get_random_name(vn_name_prefix)
vn_subnets = vn_subnets or \
[get_random_cidr(af=self.inputs.get_af())]
vn_fixture = vn_fixture or self.config_vn(vn_name, vn_subnets, **kwargs)
vn_fq_name = vn_fixture.vn_fq_name
return (vn_name, vn_subnets, vn_fixture, vn_fq_name)
示例14: test_rp_network_static_matrix
def test_rp_network_static_matrix(self):
'''
1. Create a routing policy with interface match and different "to" conditions:med, as-path, local-pref, community.
2. Launch VMs.
3. Attach policy to VN and confirm if policy takes hold.
'''
ret_dict = self.config_basic()
vn_fixture = ret_dict['vn_fixture']
test_vm = ret_dict['test_vm']
test2_vm = ret_dict['test2_vm']
self.static_table_handle = ContrailVncApi(self.vnc_lib, self.logger)
random_cidr = get_random_cidr()
self.nw_handle_to_right = self.static_table_handle.create_route_table(
prefixes=[random_cidr],
name="network_table_left_to_right",
next_hop=test_vm.vm_ip,
parent_obj=self.project.project_obj,
next_hop_type='ip-address',
route_table_type='network',
)
self.static_table_handle.bind_network_route_table_to_vn(
vn_uuid=vn_fixture.uuid,
nw_route_table_obj=self.nw_handle_to_right)
config_dicts = {'vn_fixture':vn_fixture, 'from_term':'protocol', 'sub_from':'static', 'to_term':'community', 'sub_to':'64512:55555'}
rp = self.configure_term_routing_policy(config_dicts)
assert self.verify_policy_in_control(vn_fixture, test_vm, search_ip = random_cidr, search_value = '55555')
config_dicts = {'vn_fixture':vn_fixture, 'from_term':'protocol', 'sub_from':'static', 'to_term':'add_ext_community', 'sub_to':'target:64512:44444'}
rp = self.configure_term_routing_policy(config_dicts)
assert self.verify_policy_in_control(vn_fixture, test_vm, search_ip = random_cidr, search_value = 'target:64512:44444')
config_dicts = {'vn_fixture':vn_fixture, 'from_term':'protocol', 'sub_from':'static', 'to_term':'set_ext_community', 'sub_to':'target:64512:33333'}
rp = self.configure_term_routing_policy(config_dicts)
assert self.verify_policy_in_control(vn_fixture, test_vm, search_ip = random_cidr, search_value = 'target:64512:33333'), 'Search term not found in introspect'
config_dicts = {'vn_fixture':vn_fixture, 'from_term':'protocol', 'sub_from':'static', 'to_term':'med', 'sub_to':'444'}
rp = self.configure_term_routing_policy(config_dicts)
assert self.verify_policy_in_control(vn_fixture, test_vm, search_ip = random_cidr, search_value = '444')
config_dicts = {'vn_fixture':vn_fixture, 'from_term':'protocol', 'sub_from':'static', 'to_term':'local-preference', 'sub_to':'555'}
rp = self.configure_term_routing_policy(config_dicts)
assert self.verify_policy_in_control(vn_fixture, test_vm, search_ip = random_cidr, search_value = '555')
config_dicts = {'vn_fixture':vn_fixture, 'from_term':'protocol', 'sub_from':'static', 'to_term':'as-path', 'sub_to':'666'}
rp = self.configure_term_routing_policy(config_dicts)
assert self.verify_policy_in_control(vn_fixture, test_vm, search_ip = random_cidr, search_value = '666')
assert test_vm.ping_with_certainty(test2_vm.vm_ip)
示例15: create_vn
def create_vn(self, vn_name=None, vn_subnets=None, vxlan_id=None,
enable_dhcp=True, cleanup=True):
if not vn_name:
vn_name = get_random_name('vn')
if not vn_subnets:
vn_subnets = [get_random_cidr()]
vn_fixture = VNFixture(project_name=self.inputs.project_name,
connections=self.connections,
inputs=self.inputs,
vn_name=vn_name,
subnets=vn_subnets,
vxlan_id=vxlan_id,
enable_dhcp=enable_dhcp)
vn_fixture.setUp()
if cleanup:
self.addCleanup(vn_fixture.cleanUp)
return vn_fixture