コード例 #1
0
 def topo_setup(self, config_option='openstack', skip_verify='no', flavor='contrail_flavor_small', vms_on_single_compute=False, VmToNodeMapping=None):
     '''Take topology to be configured as input and return received & configured topology -collection 
     of dictionaries. we return received topology as some data is updated and is required for 
     reference.
     Bring up with 2G RAM to support multiple traffic streams..For scaling tests, min of 8192 is recommended.
     Available config_option for SDN topo setup
     1. 'openstack': Configures all sdn entities like VN,policy etc using Openstack API 
        a. Project: Keystone
        b. Policy:  Quantum
        c. IPAM:    Contrail API
        d. VN:      Quantum
        e. VM:      Nova
     2. 'contrail': Configures all sdn entities like VN,policy etc using Contrail API 
        a. Project: Keystone
        b. Policy:  Contrail API 
        c. IPAM:    Contrail API
        d. VN:      Contrail API 
        e. VM:      Nova
     '''
     self.result = True
     self.err_msg = []
     self.flavor = flavor
     self.skip_verify = skip_verify
     self.public_vn_present = False
     self.fvn_vm_map = False
     self.fvn_fixture = None
     self.fip_fixture = None
     self.fip_fixture_dict = {
     }
     self.secgrp_fixture = None
     topo_helper_obj = topology_helper(self.topo)
     self.topo.vmc_list = topo_helper_obj.get_vmc_list()
     self.topo.policy_vn = topo_helper_obj.get_policy_vn()
     self.logger.info("Starting setup")
     topo_steps.createProject(self)
     topo_steps.createSec_group(self, option=config_option)
     topo_steps.createServiceTemplate(self)
     topo_steps.createServiceInstance(self)
     topo_steps.createIPAM(self, option=config_option)
     topo_steps.createVN(self, option=config_option)
     topo_steps.createPolicy(self, option=config_option)
     topo_steps.attachPolicytoVN(self, option=config_option)
     # If vm to node pinning is defined then pass it on to create VM method.
     if VmToNodeMapping is not None:
         topo_steps.createVMNova(
             self, config_option, vms_on_single_compute, VmToNodeMapping)
     else:
         topo_steps.createVMNova(self, config_option, vms_on_single_compute)
     topo_steps.createPublicVN(self)
     topo_steps.verifySystemPolicy(self)
     topo_steps.createStaticRouteBehindVM(self)
     topo_steps.createAllocateAssociateVnFIPPools(self)
     # prepare return data
     config_topo = {
         'project': self.project_fixture, 'policy': self.policy_fixt, 'vn': self.vn_fixture, 'vm': self.vm_fixture,
         'fip': [self.public_vn_present, self.fvn_fixture, self.fip_fixture, self.fvn_vm_map, self.fip_fixture_dict],
         'si': self.si_fixture, 'st': self.st_fixture, 'sec_grp': self.secgrp_fixture, 'ipam': self.ipam_fixture}
     if self.err_msg != []:
         self.result = False
     return {'result': self.result, 'msg': self.err_msg, 'data': [self.topo, config_topo]}
コード例 #2
0
    def sdn_topo_setup(self, config_option='openstack', skip_verify='no', flavor='contrail_flavor_small', vms_on_single_compute=False):
        '''This is wrapper script which internally calls topo_setup to setup sdn topology based on topology.
        This wrapper is basically used to configure multiple projects and it support assigning of FIP to VM from public VN.
        '''
        topo = {}
        topo_objs = {}
        config_topo = {}
        result = True
        err_msg = [
        ]
        total_vm_cnt = 0
        fip_possible = False

        # If a vm to compute node mapping is defined pass it on to topo_setup()
        try:
            if self.topo.vm_node_map:
                VmToNodeMapping = self.topo.vm_node_map
            else:
                VmToNodeMapping = None
        except:
            VmToNodeMapping = None

        self.public_vn_present = False
        self.fvn_vm_map = False
        self.fip_ip_by_vm = {
        }
        self.fvn_fixture = None
        self.fip_fixture = None
        self.fip_fixture_dict = {}
        topo_name = self.topo.__class__
        if 'project_list' in dir(self.topo):
            self.projectList = self.topo.project_list
        else:
            self.projectList = [self.inputs.project_name]
        for project in self.projectList:
            setup_obj = {}
            topo_obj = topo_name()
            # expect class topology elements to be defined under method
            # "build_topo_<project_name>"
            try:
                topo[project] = eval("topo_obj." + self.topo.topo_of_project[project] + "(" +
                                        "project='" + project +
                                        "',username='******',password='******',config_option='" + config_option +
                                        "',af_test='" + self.inputs.get_af() +
                                        "')")
            except (NameError, AttributeError):
                topo[project] = eval("topo_obj.build_topo_" + project + "()")

            setup_obj[project] = self.useFixture(
                sdnTopoSetupFixture(self.connections, topo[project]))
            out = setup_obj[project].topo_setup(
                config_option, skip_verify, flavor, vms_on_single_compute, VmToNodeMapping)
            if out['result'] == True:
                topo_objs[project], config_topo[project] = out['data']
            total_vm_cnt = total_vm_cnt + len(config_topo[project]['vm'])
            fip_info = config_topo[project]['fip']
            # If public VN present, get the public vn and FIP fixture obj
            if fip_info[0]:
                self.public_vn_present = True
                self.fvn_fixture = fip_info[1]
                self.fip_fixture = fip_info[2]
            # If floating ip pools are created in VN's and supposed to be
            # assigned to VM's in other VN
            if fip_info[3]:
                self.fvn_vm_map = True
                self.fip_fixture_dict = fip_info[4]
            self.logger.info("Setup completed for project %s with result %s" %
                             (project, out['result']))
            if out['result'] == False:
                result = False
                err_msg.append(out['msg'])
        # Allocate and Associate floating IP to VM,if there is any provision to
        # do so
        fip_possible = topo_steps.verify_fip_associate_possible(
            self, vm_cnt=total_vm_cnt)
        if fip_possible:
            topo_steps.allocateNassociateFIP(self, config_topo)

        self.config_topo = config_topo
        # Extra steps to assign FIP from VNs configured with FIP pool to VMs as defined in topology
        topo_steps.createAllocateAssociateVnFIPPools(self)

        if len(self.projectList) == 1 and 'admin' in self.projectList:
            return {'result': result, 'msg': err_msg, 'data': [topo_objs[self.inputs.project_name], config_topo[self.inputs.project_name], [fip_possible, self.fip_ip_by_vm]]}
        else:
            return {'result': result, 'msg': err_msg, 'data': [topo_objs, config_topo, [fip_possible, self.fip_ip_by_vm]]}
コード例 #3
0
    def sdn_topo_setup(self, config_option='openstack', skip_verify='no', flavor='contrail_flavor_small', vms_on_single_compute=False):
        '''This is wrapper script which internally calls topo_setup to setup sdn topology based on topology.
        This wrapper is basically used to configure multiple projects and it support assigning of FIP to VM from public VN.
        '''
        topo = {}
        topo_objs = {}
        config_topo = {}
        result = True
        err_msg = [
        ]
        total_vm_cnt = 0
        fip_possible = False

        # If a vm to compute node mapping is defined pass it on to topo_setup()
        try:
            if self.topo.vm_node_map:
                VmToNodeMapping = self.topo.vm_node_map
            else:
                VmToNodeMapping = None
        except:
            VmToNodeMapping = None

        self.public_vn_present = False
        self.fvn_vm_map = False
        self.fip_ip_by_vm = {
        }
        self.fvn_fixture = None
        self.fip_fixture = None
        self.fip_fixture_dict = {}
        topo_name = self.topo.__class__
        if 'project_list' in dir(self.topo):
            self.projectList = self.topo.project_list
        else:
            self.projectList = [self.inputs.project_name]
        for project in self.projectList:
            setup_obj = {}
            topo_obj = topo_name()
            # expect class topology elements to be defined under method
            # "build_topo_<project_name>"
            try:
                topo[project] = eval("topo_obj." + self.topo.topo_of_project[project] + "(" +
                                        "project='" + project +
                                        "',username='******',password='******',config_option='" + config_option +
                                        "')")
            except (NameError, AttributeError):
                topo[project] = eval("topo_obj.build_topo_" + project + "()")

            setup_obj[project] = self.useFixture(
                sdnTopoSetupFixture(self.connections, topo[project]))
            out = setup_obj[project].topo_setup(
                config_option, skip_verify, flavor, vms_on_single_compute, VmToNodeMapping)
            if out['result'] == True:
                topo_objs[project], config_topo[project] = out['data']
            total_vm_cnt = total_vm_cnt + len(config_topo[project]['vm'])
            fip_info = config_topo[project]['fip']
            # If public VN present, get the public vn and FIP fixture obj
            if fip_info[0]:
                self.public_vn_present = True
                self.fvn_fixture = fip_info[1]
                self.fip_fixture = fip_info[2]
            # If floating ip pools are created in VN's and supposed to be
            # assigned to VM's in other VN
            if fip_info[3]:
                self.fvn_vm_map = True
                self.fip_fixture_dict = fip_info[4]
            self.logger.info("Setup completed for project %s with result %s" %
                             (project, out['result']))
            if out['result'] == False:
                result = False
                err_msg.append(out['msg'])
        # Allocate and Associate floating IP to VM,if there is any provision to
        # do so
        fip_possible = topo_steps.verify_fip_associate_possible(
            self, vm_cnt=total_vm_cnt)
        if fip_possible:
            topo_steps.allocateNassociateFIP(self, config_topo)

        self.config_topo = config_topo
        # Extra steps to assign FIP from VNs configured with FIP pool to VMs as defined in topology
        topo_steps.createAllocateAssociateVnFIPPools(self)

        if len(self.projectList) == 1 and 'admin' in self.projectList:
            return {'result': result, 'msg': err_msg, 'data': [topo_objs[self.inputs.project_name], config_topo[self.inputs.project_name], [fip_possible, self.fip_ip_by_vm]]}
        else:
            return {'result': result, 'msg': err_msg, 'data': [topo_objs, config_topo, [fip_possible, self.fip_ip_by_vm]]}