Example #1
0
 def setUp(self):
     super(VncLibFixture, self).setUp()
     if not self.connections:
         self.logger = self.logger or contrail_logging.getLogger(__name__)
         self.vnc_api_h = VncApi(username=self.username,
                                 password=self.password,
                                 tenant_name=self.project_name,
                                 domain_name=self.orch_domain,
                                 api_server_host=self.cfgm_ip,
                                 api_server_port=self.api_server_port,
                                 auth_host=self.auth_server_ip,
                                 auth_port=self.auth_port,
                                 api_server_use_ssl=self.use_ssl,
                                 auth_url=self.authn_url)
         if self.orchestrator == 'openstack':
             self.auth_client = OpenstackAuth(self.username,
                                              self.password,
                                              self.project_name,
                                              domain_name=self.orch_domain,
                                              auth_url=self.auth_url,
                                              certfile=self.certfile,
                                              keyfile=self.keyfile,
                                              cacert=self.cacert,
                                              insecure=self.insecure,
                                              logger=self.logger,
                                              scope='project')
         elif self.orchestrator == 'vcenter':
             self.auth_client = VcenterAuth(self.username, self.password,
                                            self.project_name, self.inputs)
     if self.orch:
         self.vnc_h = self.orch.vnc_h
     else:
         self.vnc_h = ContrailVncApi(self.vnc_api_h, self.logger)
    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)
 def __init__(self, inputs, vnc, logger):
     self._inputs = inputs
     self._vnc = vnc
     self.logger = logger
     self._ipam_obj = self._get_ipam_object()
     self._gw = self._process_vcenter_gateway_info()
     self.vnc_h = ContrailVncApi(self._vnc, self.logger)
Example #4
0
 def setUpClass(cls):
     super(BaseInterAS, cls).setUpClass()
     cls.project_name = cls.inputs.project_name
     cls.quantum_h = cls.connections.quantum_h
     cls.orch = cls.connections.orch
     cls.nova_h = cls.connections.nova_h
     cls.vnc_lib = cls.connections.vnc_lib
     cls.vnc_h = ContrailVncApi(cls.vnc_lib, cls.logger)
     cls.agent_inspect = cls.connections.agent_inspect
     cls.cn_inspect = cls.connections.cn_inspect
     cls.analytics_obj = cls.connections.analytics_obj
Example #5
0
 def setUpClass(cls):
     cls.public_vn_obj = None
     super(BaseNeutronTest, cls).setUpClass()
     cls.vnc_h = ContrailVncApi(cls.vnc_lib, cls.logger) 
     if cls.inputs.admin_username:
         public_creds = cls.admin_isolated_creds
     else:
         public_creds = cls.isolated_creds
     cls.public_vn_obj = create_public_vn.PublicVn(
         connections=cls.connections,
         isolated_creds_obj=public_creds,
         logger=cls.logger)
Example #6
0
 def setUp(self):
     super(VncLibFixture, self).setUp()
     if self.connections:
         self.logger = self.connections.logger
         self.project_name = self.connections.project_name
         self.inputs = self.connections.inputs
         self.neutron_handle = self.connections.quantum_h
         self.vnc_api_h = self.connections.vnc_lib
         self.username = self.connections.username
         self.password = self.connections.password
         self.cfgm_ip = self.inputs.cfgm_ip
         self.auth_server_ip = self.inputs.auth_ip
         self.auth_client = self.connections.auth
         self.project_id = self.connections.project_id
     else:
         self.logger = self.logger or contrail_logging.getLogger(__name__)
         self.vnc_api_h = VncApi(
                           username=self.username,
                           password=self.password,
                           tenant_name=self.project_name,
                           domain_name=self.domain,
                           api_server_host=self.cfgm_ip,
                           api_server_port=self.api_server_port,
                           auth_host=self.auth_server_ip,
                           api_server_use_ssl=self.use_ssl,
                           auth_url=self.authn_url)
         if self.orchestrator == 'openstack':
             self.auth_client = OpenstackAuth(
                                 self.username,
                                 self.password,
                                 self.project_name,
                                 domain_name=self.domain,
                                 auth_url=self.auth_url,
                                 certfile=self.certfile,
                                 keyfile=self.keyfile,
                                 cacert=self.cacert,
                                 insecure=self.insecure,
                                 logger=self.logger)
         elif self.orchestrator == 'vcenter':
             self.auth_client = VcenterAuth(self.username,
                                             self.password,
                                             self.project_name,
                                             self.inputs
                                             )
         if not self.project_id:
             self.project_id = self.vnc_api_h.project_read(
                 fq_name=[self.domain, self.project_name]).uuid
     if self.orch:
         self.vnc_h = self.orch.vnc_h
     else:
         self.vnc_h = ContrailVncApi(self.vnc_api_h, self.logger)
 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
    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)
Example #9
0
    def setUp(self):
        super(PortFixture, self).setUp()
        self.vnc_h = ContrailVncApi(self.vnc_api_h, self.logger)
        self.vn_obj = self.vnc_api_h.virtual_network_read(id=self.vn_id)

        if self.api_type == 'neutron':
            self._neutron_create_port()
        else:
            self._contrail_create_port()
        #Sandipd:This code was crashing while creating port as part of
        #vcenter gateway testing.Hence handled the exception as the mac
        #not needed to be obtained always,its passed as an argument to the fixture
        try:
            self.neutron_handle = self.get_neutron_handle()
            self.obj = self.neutron_handle.get_port(self.uuid)
            self.mac_address = self.obj['mac_address']
        except Exception as e:
            pass
        self.vmi_obj = self.vnc_api_h.virtual_machine_interface_read(
            id=self.uuid)
        self.logger.debug('Created port %s' % (self.uuid))
Example #10
0
 def __init__(self, connections, alarm_name=None, uve_keys=[], alarm_severity=None,
              alarm_rules=None, operand1=None, operand2=None, description=None, variables=None,
              id_perms=None, perms2=None, display_name=None, parent_obj_type='project',
              clean_up=True, project_name=None, project_fixture=None):
     self.connections = connections
     self.inputs = connections.inputs
     self.logger = self.connections.logger
     self.vnc_lib_h = self.connections.get_vnc_lib_h()
     self.vnc_h = ContrailVncApi(self.vnc_lib_h, self.logger)
     self.api_s_inspect = self.connections.api_server_inspect
     self.analytics_obj = self.connections.analytics_obj
     self.alarm_name = alarm_name
     self.alarm_id = None
     self.alarm_fq_name = [self.inputs.domain_name, self.alarm_name]
     self.uve_keys = uve_keys
     self.alarm_severity = alarm_severity
     self.alarm_rules = alarm_rules
     self.operand1 = operand1
     self.operand2 = operand2
     self.description = description
     self.variables = variables
     self.id_perms = id_perms
     self.perms2 = perms2
     self.display_name = display_name
     self.parent_obj_type = parent_obj_type
     self.domain_name = self.connections.domain_name
     self.project_name = project_name or self.connections.project_name
     self.project_fixture = project_fixture
     if self.project_fixture:
         self.project_name = self.project_fixture.project_name
     self.project_id = self.connections.get_project_id()
     self.parent_obj = None
     self.clean_up = clean_up
     self.obj = None
     self.created = False
     if self.inputs.verify_thru_gui():
         from webui_test import WebuiTest
         self.webui = WebuiTest(self.connections, self.inputs)
Example #11
0
    def setUp(self):
        super(VncLibFixture, self).setUp()
        if self.connections:
            self.logger = self.connections.logger
            self.project_name = self.connections.project_name
            self.inputs = self.connections.inputs
            self.neutron_handle = self.connections.quantum_h
            self.vnc_api_h = self.connections.vnc_lib
            self.username = self.connections.username
            self.password = self.connections.password
            self.cfgm_ip = self.inputs.cfgm_ip
            self.auth_server_ip = self.inputs.auth_ip
            self.project_id = self.connections.project_id
            self.auth_url = 'http://' + self.inputs.auth_ip + ':5000/v2.0'
        else:
            self.logger = self.logger or contrail_logging.getLogger(__name__)
            self.vnc_api_h = VncApi(username=self.username,
                                    password=self.password,
                                    tenant_name=self.project_name,
                                    api_server_host=self.cfgm_ip,
                                    api_server_port=self.api_server_port,
                                    auth_host=self.auth_server_ip)
            if not self.project_id:
                if self.orchestrator == 'openstack':
                    self.auth_client = OpenstackAuth(self.username,
                                                     self.password,
                                                     self.project_name,
                                                     auth_url=self.auth_url,
                                                     logger=self.logger)
                    self.project_id = self.auth_client.get_project_id()
                elif self.orchestrator == 'vcenter':
                    self.auth_client = VcenterAuth(self.username,
                                                   self.password,
                                                   self.project_name,
                                                   self.inputs)
                    self.project_id = self.auth_client.get_project_id()

        self.vnc_h = ContrailVncApi(self.vnc_api_h, self.logger)
Example #12
0
 def __init__(self, inputs, vnc_api_h, logger=None):
     self.inputs = inputs
     self.logger = logger or logging.getLogger(__name__)
     self.vnc_h = ContrailVncApi(vnc_api_h, logger)
Example #13
0
 def setUp(self):
     super(InterfaceRouteTableFixture, self).setUp()
     self.vnc_h = ContrailVncApi(self.vnc_api_h, self.logger)
     self.create()
Example #14
0
 def setUp(self):
     super(StaticRouteTableBase, self).setUp()
     self.static_table_handle = ContrailVncApi(self.vnc_lib, self.logger)
Example #15
0
 def __init__(self, *args, **kwargs):
     super(VirtualRouterBase, self).__init__(*args, **kwargs)
     self.name = args[0]
     self.virtual_router_type = args[1]
     self.vr = None
     self.vnc_h = ContrailVncApi(self.vnc_api_h, self.logger)
Example #16
0
 def setUp(self):
     super(QosBaseFixture, self).setUp()
     self.vnc_h = ContrailVncApi(self.vnc_api_h, self.logger)
     if self.connections:
         self.agent_inspect = self.connections.agent_inspect
Example #17
0
    def setUpClass(cls):
        super(ECMPTestBase, cls).setUpClass()
        cls.inputs.set_af(cls.get_af())
        cls.vnc_h = ContrailVncApi(cls.vnc_lib, cls.logger)

        try:
            # Mgmt VN
            cls.mgmt_vn_name = get_random_name('mgmt_%s' % (
                                               cls.inputs.project_name))
            cls.mgmt_vn_subnets = [get_random_cidr(af=cls.inputs.get_af())]
            cls.mgmt_vn_fixture = cls.create_only_vn(
                    cls.mgmt_vn_name, cls.mgmt_vn_subnets)

            # Left VN
            cls.left_vn_name = get_random_name('left_%s' % (
                                              cls.inputs.project_name))
            cls.left_vn_subnets = [get_random_cidr(af=cls.inputs.get_af())]
            cls.left_vn_fixture = cls.create_only_vn(cls.left_vn_name,
                                                     cls.left_vn_subnets)

            # Right VN
            cls.right_vn_name = get_random_name('right_%s' % (
                                                 cls.inputs.project_name))
            cls.right_vn_subnets = [get_random_cidr(af=cls.inputs.get_af())]
            cls.right_vn_fixture = cls.create_only_vn(cls.right_vn_name,
                                                      cls.right_vn_subnets)
            #if cls.inputs.get_af() == 'v6':
            #    cls.left_vn_subnets += [get_random_cidr()]
            #    cls.right_vn_subnets += [get_random_cidr()]

            if not  hasattr(cls, 'image_name'):
                if cls.inputs.is_ci_setup() and cls.inputs.get_af() == 'v4':
                    cls.image_name = cls.inputs.get_ci_image()
                else:
                    cls.image_name = 'cirros-traffic'

            # End Vms
            cls.left_vm_name = get_random_name('left_vm_%s' % (
                                                cls.inputs.project_name))
            cls.left_vm_fixture = cls.create_only_vm(cls.left_vn_fixture,
                                                     vm_name=cls.left_vm_name,
                                                     image_name=cls.image_name)
            cls.right_vm_name = get_random_name('right_vm_%s' % (
                                                 cls.inputs.project_name))
            cls.right_vm_fixture = cls.create_only_vm(cls.right_vn_fixture,
                                                      vm_name=cls.right_vm_name,
                                                      image_name=cls.image_name)
        except:
            cls.tearDownClass()
            raise

        cls.common_args = { 'mgmt_vn_name' : cls.mgmt_vn_name,
                            'mgmt_vn_subnets' : cls.mgmt_vn_subnets,
                            'mgmt_vn_fixture' : cls.mgmt_vn_fixture,
                            'left_vn_name' : cls.left_vn_name,
                            'left_vn_subnets' : cls.left_vn_subnets,
                            'left_vn_fixture' : cls.left_vn_fixture,
                            'left_vm_name' : cls.left_vm_name,
                            'left_vm_fixture' : cls.left_vm_fixture,
                            'right_vn_name' : cls.right_vn_name,
                            'right_vn_subnets' : cls.right_vn_subnets,
                            'right_vn_fixture' : cls.right_vn_fixture,
                            'right_vm_name' : cls.right_vm_name,
                            'right_vm_fixture' : cls.right_vm_fixture,
                            'image_name' : cls.image_name }