• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python util.get_random_cidr函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tcutils.util.get_random_cidr函数的典型用法代码示例。如果您正苦于以下问题:Python get_random_cidr函数的具体用法?Python get_random_cidr怎么用?Python get_random_cidr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_random_cidr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
开发者ID:Juniper,项目名称:contrail-test,代码行数:30,代码来源:base.py


示例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
开发者ID:Ankitja,项目名称:contrail-test,代码行数:57,代码来源:config.py


示例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)
开发者ID:Juniper,项目名称:contrail-test,代码行数:34,代码来源:test_routing_policy.py


示例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
开发者ID:Juniper,项目名称:contrail-test,代码行数:28,代码来源:test_routing_policy.py


示例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
开发者ID:Ankitja,项目名称:contrail-test,代码行数:8,代码来源:neutron_util.py


示例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
开发者ID:Ankitja,项目名称:contrail-test,代码行数:9,代码来源:neutron_util.py


示例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]}]
开发者ID:Juniper,项目名称:contrail-test,代码行数:52,代码来源:sdn_single_vm_multiple_policy_topology.py


示例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
开发者ID:Juniper,项目名称:contrail-test,代码行数:22,代码来源:base.py


示例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))
开发者ID:aswanikumar90,项目名称:contrail-test,代码行数:14,代码来源:base.py


示例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
开发者ID:Ankitja,项目名称:contrail-test,代码行数:14,代码来源:verify.py


示例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
开发者ID:Juniper,项目名称:contrail-test,代码行数:15,代码来源:test_routing_policy.py


示例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
开发者ID:Juniper,项目名称:contrail-test,代码行数:16,代码来源:base.py


示例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)
开发者ID:Ankitja,项目名称:contrail-test,代码行数:16,代码来源:config.py


示例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)
开发者ID:Juniper,项目名称:contrail-test,代码行数:45,代码来源:test_routing_policy.py


示例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
开发者ID:dattamiruke,项目名称:contrail-test-ci,代码行数:18,代码来源:base.py


示例16: test_rp_bgpaas_matrix

    def test_rp_bgpaas_matrix(self):
        '''
        1. Create a routing policy with bgpaas 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. 
        '''

        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()
        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 = vn_fixture.get_subnets()[0]['gateway_ip']
        dns_ip = 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=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)
        config_dicts = {'vn_fixture':vn_fixture, 'from_term':'protocol', 'sub_from':'bgpaas', 'to_term':'med', 'sub_to':'444'}
        rp = self.configure_term_routing_policy(config_dicts)
        sleep(90)
        assert self.verify_policy_in_control(vn_fixture, test_vm, search_ip = str(vn_fixture.get_subnets()[0]['cidr']), search_value = '444')
        config_dicts = {'vn_fixture':vn_fixture, 'from_term':'protocol', 'sub_from':'bgpaas', 'to_term':'local-preference', 'sub_to':'555'}
        rp = self.configure_term_routing_policy(config_dicts)
        sleep(90)
        assert self.verify_policy_in_control(vn_fixture, test_vm, search_ip = str(vn_fixture.get_subnets()[0]['cidr']), search_value = '555')
        config_dicts = {'vn_fixture':vn_fixture, 'from_term':'protocol', 'sub_from':'bgpaas', 'to_term':'as-path', 'sub_to':'666'}
        rp = self.configure_term_routing_policy(config_dicts)
        sleep(90)
        assert self.verify_policy_in_control(vn_fixture, test_vm, search_ip = str(vn_fixture.get_subnets()[0]['cidr']), search_value = '666')
开发者ID:Juniper,项目名称:contrail-test,代码行数:44,代码来源:test_routing_policy.py


示例17: create_only_vn

 def create_only_vn(cls, vn_name=None, vn_subnets=None, vxlan_id=None, enable_dhcp=True, **kwargs):
     """Classmethod to do only VN creation
     """
     if not vn_name:
         vn_name = get_random_name("vn")
     if not vn_subnets:
         vn_subnets = [get_random_cidr()]
     vn_fixture = VNFixture(
         project_name=cls.inputs.project_name,
         connections=cls.connections,
         inputs=cls.inputs,
         vn_name=vn_name,
         subnets=vn_subnets,
         vxlan_id=vxlan_id,
         enable_dhcp=enable_dhcp,
         **kwargs
     )
     vn_fixture.setUp()
     return vn_fixture
开发者ID:Juniper,项目名称:contrail-test-ci,代码行数:19,代码来源:base.py


示例18: verify_multi_inline_svc

    def verify_multi_inline_svc(self, si_list=[('bridge', 1), ('in-net', 1), ('nat', 1)], flavor='contrail_flavor_2cpu', ordered_interfaces=True, vn1_subnets=None, vn2_subnets=None):
        """Validate in-line multi service chaining in network  datapath"""

        vn1_subnets = vn1_subnets or [get_random_cidr(af=self.inputs.get_af())]
        vn2_subnets = vn2_subnets or [get_random_cidr(af=self.inputs.get_af())]
        self.vn1_fq_name = "default-domain:" + self.inputs.project_name + \
            ":" + get_random_name("in_network_vn1")
        self.vn1_name = self.vn1_fq_name.split(':')[2]
        self.vn1_subnets = vn1_subnets
        self.vm1_name = get_random_name("in_network_vm1")
        self.vn2_fq_name = "default-domain:" + self.inputs.project_name + \
            ":" + get_random_name("in_network_vn2")
        self.vn2_name = self.vn2_fq_name.split(':')[2]
        self.vn2_subnets = vn2_subnets
        self.vm2_name = get_random_name("in_network_vm2")
        self.action_list = []
        self.si_list = []
        self.policy_name = get_random_name("policy_in_network")
        self.vn1_fixture = self.config_vn(self.vn1_name, self.vn1_subnets)
        self.vn2_fixture = self.config_vn(self.vn2_name, self.vn2_subnets)
        for si in si_list:
            self.if_list = [['management', False, False],
                            ['left', True, False], ['right', True, False]]
            svc_scaling = False
            si_count = 1
            self.st_name = get_random_name(
                ("multi_sc_") + si[0] + "_" + str(si_list.index(si)) + ("_st"))
            si_prefix = get_random_name(
                ("multi_sc_") + si[0] + "_" + str(si_list.index(si)) + ("_si")) + "_"
            max_inst = si[1]
            left_vn = self.vn1_fq_name
            right_vn = self.vn2_fq_name
            if max_inst > 1:
                svc_scaling = True
            if si[0] == 'nat':
                svc_mode = 'in-network-nat'
                svc_img_name = 'vsrx'
            elif si[0] == 'in-net':
                svc_mode = 'in-network'
                svc_img_name = 'ubuntu-in-net'
            else:
                svc_mode = 'transparent'
                svc_img_name = 'tiny_trans_fw'
                left_vn = None
                right_vn = None
            self.st_fixture, self.si_fixtures = self.config_st_si(
                self.st_name, si_prefix, si_count, svc_scaling, max_inst, left_vn=left_vn,
                right_vn=right_vn, svc_mode=svc_mode, flavor=flavor,
                ordered_interfaces=ordered_interfaces, project=self.inputs.project_name, svc_img_name=svc_img_name)
            action_step = self.chain_si(
                si_count, si_prefix, self.inputs.project_name)
            self.action_list += action_step
            self.si_list += self.si_fixtures
        self.rules = [
            {
                'direction': '<>',
                'protocol': 'any',
                'source_network': self.vn1_name,
                'src_ports': [0, -1],
                'dest_network': self.vn2_name,
                'dst_ports': [0, -1],
                'simple_action': None,
                'action_list': {'apply_service': self.action_list}
            },
        ]
        self.policy_fixture = self.config_policy(self.policy_name, self.rules)

        self.vn1_policy_fix = self.attach_policy_to_vn(
            self.policy_fixture, self.vn1_fixture)
        self.vn2_policy_fix = self.attach_policy_to_vn(
            self.policy_fixture, self.vn2_fixture)
        self.vm1_fixture = self.config_and_verify_vm(
            self.vn1_fixture, self.vm1_name)
        self.vm2_fixture = self.config_and_verify_vm(
            self.vn2_fixture, self.vm2_name)
        for si_fix in self.si_fixtures:
            si_fix.verify_on_setup()
        result, msg = self.validate_vn(
            self.vn1_name, project_name=self.inputs.project_name)
        assert result, msg
        result, msg = self.validate_vn(
            self.vn2_name, project_name=self.inputs.project_name)
        assert result, msg
        # Ping from left VM to right VM
        errmsg = "Ping to right VM ip %s from left VM failed" % self.vm2_fixture.vm_ip
        assert self.vm1_fixture.ping_with_certainty(
            self.vm2_fixture.vm_ip), errmsg
        return True
开发者ID:kimcharli,项目名称:contrail-test,代码行数:88,代码来源:verify.py


示例19: verify_svc_in_network_datapath

    def verify_svc_in_network_datapath(self, si_count=1, svc_scaling=False, max_inst=1, svc_mode='in-network-nat', flavor='contrail_flavor_2cpu', static_route=['None', 'None', 'None'], ordered_interfaces=True, svc_img_name='vsrx', vn1_subnets=None, vn2_fixture=None, vn2_subnets=None, ci=False):
        """Validate the service chaining in network  datapath"""

        self.vn1_fq_name = "default-domain:" + self.inputs.project_name + \
            ":" + get_random_name("in_network_vn1")
        self.vn1_name = self.vn1_fq_name.split(':')[2]
        self.vn1_subnets = vn1_subnets or [get_random_cidr(af=self.inputs.get_af())]
        self.vm1_name = get_random_name("in_network_vm1")
        self.vn2_fq_name = "default-domain:" + self.inputs.project_name + \
            ":" + get_random_name("in_network_vn2")
        self.vn2_name = self.vn2_fq_name.split(':')[2]
        self.vn2_subnets = vn2_subnets or [get_random_cidr(af=self.inputs.get_af())]
        self.vm2_name = get_random_name("in_network_vm2")
        self.action_list = []
        self.if_list = [['management', False, False],
                        ['left', True, False], ['right', True, False]]
        for entry in static_route:
            if entry != 'None':
                self.if_list[static_route.index(entry)][2] = True
        self.st_name = get_random_name("in_net_svc_template_1")
        si_prefix = get_random_name("in_net_svc_instance") + "_"

        self.policy_name = get_random_name("policy_in_network")
        self.vn1_fixture = self.config_vn(self.vn1_name, self.vn1_subnets)
        if vn2_fixture is None:
            self.vn2_fixture = self.config_vn(self.vn2_name, self.vn2_subnets)
        else:
            self.vn2_fixture = vn2_fixture
            self.vn2_fq_name = vn2_fixture.vn_fq_name
            self.vn2_name = self.vn2_fq_name.split(':')[2]
        self.st_fixture, self.si_fixtures = self.config_st_si(
            self.st_name, si_prefix, si_count, svc_scaling, max_inst, left_vn=self.vn1_fq_name,
            right_vn=self.vn2_fq_name, svc_mode=svc_mode, flavor=flavor, static_route=static_route, ordered_interfaces=ordered_interfaces, svc_img_name=svc_img_name, project=self.inputs.project_name)
        self.action_list = self.chain_si(
            si_count, si_prefix, self.inputs.project_name)
        self.rules = [
            {
                'direction': '<>',
                'protocol': 'any',
                'source_network': self.vn1_fq_name,
                'src_ports': [0, -1],
                'dest_network': self.vn2_fq_name,
                'dst_ports': [0, -1],
                'simple_action': None,
                'action_list': {'apply_service': self.action_list}
            },
        ]
        self.policy_fixture = self.config_policy(self.policy_name, self.rules)

        self.vn1_policy_fix = self.attach_policy_to_vn(
            self.policy_fixture, self.vn1_fixture)
        self.vn2_policy_fix = self.attach_policy_to_vn(
            self.policy_fixture, self.vn2_fixture)
        if ci and self.inputs.get_af() == 'v4':
            image_name = 'cirros-0.3.0-x86_64-uec'
        else:
            image_name = 'ubuntu-traffic'
        self.vm1_fixture = self.config_and_verify_vm(
            self.vn1_fixture, self.vm1_name, image_name)
        self.vm2_fixture = self.config_and_verify_vm(
            self.vn2_fixture, self.vm2_name, image_name)
        for si_fix in self.si_fixtures:
            si_fix.verify_on_setup()
        result, msg = self.validate_vn(
            self.vn1_name, project_name=self.vn1_fixture.project_name)
        assert result, msg
        result, msg = self.validate_vn(
            self.vn2_name, project_name=self.vn2_fixture.project_name)
        assert result, msg
        # Ping from left VM to right VM
        errmsg = "Ping to right VM ip %s from left VM failed" % self.vm2_fixture.vm_ip
        assert self.vm1_fixture.ping_with_certainty(
            self.vm2_fixture.vm_ip), errmsg
        return True
开发者ID:kimcharli,项目名称:contrail-test,

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.get_random_name函数代码示例发布时间:2022-05-27
下一篇:
Python commands.ssh函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap