예제 #1
0
파일: tempest.py 프로젝트: colvert/functest
    def _create_network(self, project_name):
        """Create network for tests."""
        tempest_network_type = None
        tempest_physical_network = None
        tempest_segmentation_id = None

        if hasattr(CONST, 'tempest_network_type'):
            tempest_network_type = CONST.__getattribute__(
                'tempest_network_type')
        if hasattr(CONST, 'tempest_physical_network'):
            tempest_physical_network = CONST.__getattribute__(
                'tempest_physical_network')
        if hasattr(CONST, 'tempest_segmentation_id'):
            tempest_segmentation_id = CONST.__getattribute__(
                'tempest_segmentation_id')

        network_creator = deploy_utils.create_network(
            self.os_creds,
            NetworkConfig(
                name=CONST.__getattribute__('tempest_private_net_name') +
                self.guid,
                project_name=project_name,
                network_type=tempest_network_type,
                physical_network=tempest_physical_network,
                segmentation_id=tempest_segmentation_id,
                subnet_settings=[
                    SubnetConfig(name=CONST.__getattribute__(
                        'tempest_private_subnet_name') + self.guid,
                                 project_name=project_name,
                                 cidr=CONST.__getattribute__(
                                     'tempest_private_subnet_cidr'))
                ]))
        if network_creator is None or network_creator.get_network() is None:
            raise Exception("Failed to create private network")
        self.creators.append(network_creator)
예제 #2
0
    def run(self):
        """
        Begins the test execution which should originate from the subclass
        """
        self.logger.info('Begin virtual environment setup')

        self.start_time = time.time()
        self.logger.info("vPing Start Time:'%s'" % (datetime.fromtimestamp(
            self.start_time).strftime('%Y-%m-%d %H:%M:%S')))

        image_base_name = '{}-{}'.format(
            CONST.__getattribute__('vping_image_name'), str(self.guid))
        os_image_settings = openstack_tests.cirros_image_settings(
            image_base_name, image_metadata=self.cirros_image_config)
        self.logger.info("Creating image with name: '%s'" % image_base_name)

        self.image_creator = deploy_utils.create_image(self.os_creds,
                                                       os_image_settings)
        self.creators.append(self.image_creator)

        private_net_name = CONST.__getattribute__(
            'vping_private_net_name') + self.guid
        private_subnet_name = CONST.__getattribute__(
            'vping_private_subnet_name') + self.guid
        private_subnet_cidr = CONST.__getattribute__(
            'vping_private_subnet_cidr')
        self.logger.info("Creating network with name: '%s'" % private_net_name)
        self.network_creator = deploy_utils.create_network(
            self.os_creds,
            NetworkSettings(name=private_net_name,
                            subnet_settings=[
                                SubnetSettings(name=private_subnet_name,
                                               cidr=private_subnet_cidr)
                            ]))
        self.creators.append(self.network_creator)

        self.logger.info("Creating flavor with name: '%s'" % self.flavor_name)
        scenario = functest_utils.get_scenario()
        flavor_metadata = None
        if 'ovs' in scenario or 'fdio' in scenario:
            flavor_metadata = create_flavor.MEM_PAGE_SIZE_LARGE
        flavor_creator = OpenStackFlavor(
            self.os_creds,
            FlavorSettings(name=self.flavor_name,
                           ram=512,
                           disk=1,
                           vcpus=1,
                           metadata=flavor_metadata))
        flavor_creator.create()
        self.creators.append(flavor_creator)
예제 #3
0
    def create(self,
               use_custom_images=False,
               use_custom_flavors=False,
               create_project=False):
        if create_project:
            logger.debug("Creating project (tenant) for Tempest suite")
            project_name = CONST.__getattribute__(
                'tempest_identity_tenant_name') + self.guid
            project_creator = deploy_utils.create_project(
                self.os_creds,
                ProjectConfig(name=project_name,
                              description=CONST.__getattribute__(
                                  'tempest_identity_tenant_description')))
            if (project_creator is None
                    or project_creator.get_project() is None):
                raise Exception("Failed to create tenant")
            project_id = project_creator.get_project().id
            self.creators.append(project_creator)

            logger.debug("Creating user for Tempest suite")
            user_creator = deploy_utils.create_user(
                self.os_creds,
                UserConfig(
                    name=CONST.__getattribute__('tempest_identity_user_name') +
                    self.guid,
                    password=CONST.__getattribute__(
                        'tempest_identity_user_password'),
                    project_name=project_name))
            if user_creator is None or user_creator.get_user() is None:
                raise Exception("Failed to create user")
            user_id = user_creator.get_user().id
            self.creators.append(user_creator)
        else:
            project_name = None
            project_id = None
            user_id = None

        logger.debug("Creating private network for Tempest suite")
        network_creator = deploy_utils.create_network(
            self.os_creds,
            NetworkConfig(
                name=CONST.__getattribute__('tempest_private_net_name') +
                self.guid,
                project_name=project_name,
                subnet_settings=[
                    SubnetConfig(name=CONST.__getattribute__(
                        'tempest_private_subnet_name') + self.guid,
                                 cidr=CONST.__getattribute__(
                                     'tempest_private_subnet_cidr'))
                ]))
        if network_creator is None or network_creator.get_network() is None:
            raise Exception("Failed to create private network")
        self.creators.append(network_creator)

        image_id = None
        image_id_alt = None
        flavor_id = None
        flavor_id_alt = None

        logger.debug("Creating image for Tempest suite")
        image_base_name = CONST.__getattribute__(
            'openstack_image_name') + self.guid
        os_image_settings = openstack_tests.cirros_image_settings(
            image_base_name,
            public=True,
            image_metadata=self.cirros_image_config)
        logger.debug("Creating image for Tempest suite")
        image_creator = deploy_utils.create_image(self.os_creds,
                                                  os_image_settings)
        if image_creator is None:
            raise Exception('Failed to create image')
        self.creators.append(image_creator)
        image_id = image_creator.get_image().id

        if use_custom_images:
            logger.debug("Creating 2nd image for Tempest suite")
            image_base_name_alt = CONST.__getattribute__(
                'openstack_image_name_alt') + self.guid
            os_image_settings_alt = openstack_tests.cirros_image_settings(
                image_base_name_alt,
                public=True,
                image_metadata=self.cirros_image_config)
            logger.debug("Creating 2nd image for Tempest suite")
            image_creator_alt = deploy_utils.create_image(
                self.os_creds, os_image_settings_alt)
            if image_creator_alt is None:
                raise Exception('Failed to create image')
            self.creators.append(image_creator_alt)
            image_id_alt = image_creator_alt.get_image().id

        if (CONST.__getattribute__('tempest_use_custom_flavors') == 'True'
                or use_custom_flavors):
            logger.info("Creating flavor for Tempest suite")
            scenario = CONST.__getattribute__('DEPLOY_SCENARIO')
            flavor_metadata = None
            if 'ovs' in scenario or 'fdio' in scenario:
                flavor_metadata = create_flavor.MEM_PAGE_SIZE_LARGE
            flavor_creator = OpenStackFlavor(
                self.os_creds,
                FlavorConfig(
                    name=CONST.__getattribute__('openstack_flavor_name') +
                    self.guid,
                    ram=CONST.__getattribute__('openstack_flavor_ram'),
                    disk=CONST.__getattribute__('openstack_flavor_disk'),
                    vcpus=CONST.__getattribute__('openstack_flavor_vcpus'),
                    metadata=flavor_metadata))
            flavor = flavor_creator.create()
            if flavor is None:
                raise Exception('Failed to create flavor')
            self.creators.append(flavor_creator)
            flavor_id = flavor.id

        if use_custom_flavors:
            logger.info("Creating 2nd flavor for Tempest suite")
            scenario = CONST.__getattribute__('DEPLOY_SCENARIO')
            flavor_metadata_alt = None
            if 'ovs' in scenario or 'fdio' in scenario:
                flavor_metadata_alt = create_flavor.MEM_PAGE_SIZE_LARGE
                CONST.__setattr__('openstack_flavor_ram', 1024)
            flavor_creator_alt = OpenStackFlavor(
                self.os_creds,
                FlavorConfig(
                    name=CONST.__getattribute__('openstack_flavor_name_alt') +
                    self.guid,
                    ram=CONST.__getattribute__('openstack_flavor_ram'),
                    disk=CONST.__getattribute__('openstack_flavor_disk'),
                    vcpus=CONST.__getattribute__('openstack_flavor_vcpus'),
                    metadata=flavor_metadata_alt))
            flavor_alt = flavor_creator_alt.create()
            if flavor_alt is None:
                raise Exception('Failed to create flavor')
            self.creators.append(flavor_creator_alt)
            flavor_id_alt = flavor_alt.id

        print("RESOURCES CREATE: image_id: %s, image_id_alt: %s, "
              "flavor_id: %s, flavor_id_alt: %s" % (
                  image_id,
                  image_id_alt,
                  flavor_id,
                  flavor_id_alt,
              ))

        result = {
            'image_id': image_id,
            'image_id_alt': image_id_alt,
            'flavor_id': flavor_id,
            'flavor_id_alt': flavor_id_alt
        }

        if create_project:
            result['project_id'] = project_id
            result['tenant_id'] = project_id  # for compatibility
            result['user_id'] = user_id

        return result
예제 #4
0
파일: rally.py 프로젝트: colvert/functest
    def _prepare_env(self):
        """Create resources needed by test scenarios."""
        LOGGER.debug('Validating the test name...')
        if self.test_name not in self.TESTS:
            raise Exception("Test name '%s' is invalid" % self.test_name)

        network_name = self.RALLY_PRIVATE_NET_NAME + self.guid
        subnet_name = self.RALLY_PRIVATE_SUBNET_NAME + self.guid
        router_name = self.RALLY_ROUTER_NAME + self.guid
        self.image_name = self.GLANCE_IMAGE_NAME + self.guid
        self.flavor_name = self.FLAVOR_NAME + self.guid
        self.flavor_alt_name = self.FLAVOR_ALT_NAME + self.guid
        self.ext_net_name = snaps_utils.get_ext_net_name(self.os_creds)
        self.compute_cnt = snaps_utils.get_active_compute_cnt(self.os_creds)

        LOGGER.debug("Creating image '%s'...", self.image_name)
        image_creator = deploy_utils.create_image(
            self.os_creds, ImageConfig(
                name=self.image_name,
                image_file=self.GLANCE_IMAGE_PATH,
                img_format=self.GLANCE_IMAGE_FORMAT,
                image_user=self.GLANCE_IMAGE_USERNAME,
                public=True,
                extra_properties=self.GLANCE_IMAGE_EXTRA_PROPERTIES))
        if image_creator is None:
            raise Exception("Failed to create image")
        self.creators.append(image_creator)

        LOGGER.debug("Creating network '%s'...", network_name)

        rally_network_type = None
        rally_physical_network = None
        rally_segmentation_id = None

        if hasattr(CONST, 'rally_network_type'):
            rally_network_type = CONST.__getattribute__(
                'rally_network_type')
        if hasattr(CONST, 'rally_physical_network'):
            rally_physical_network = CONST.__getattribute__(
                'rally_physical_network')
        if hasattr(CONST, 'rally_segmentation_id'):
            rally_segmentation_id = CONST.__getattribute__(
                'rally_segmentation_id')

        network_creator = deploy_utils.create_network(
            self.os_creds, NetworkConfig(
                name=network_name,
                shared=True,
                network_type=rally_network_type,
                physical_network=rally_physical_network,
                segmentation_id=rally_segmentation_id,
                subnet_settings=[SubnetConfig(
                    name=subnet_name,
                    cidr=self.RALLY_PRIVATE_SUBNET_CIDR)]))
        if network_creator is None:
            raise Exception("Failed to create private network")
        self.priv_net_id = network_creator.get_network().id
        self.creators.append(network_creator)

        LOGGER.debug("Creating router '%s'...", router_name)
        router_creator = deploy_utils.create_router(
            self.os_creds, RouterConfig(
                name=router_name,
                external_gateway=self.ext_net_name,
                internal_subnets=[subnet_name]))
        if router_creator is None:
            raise Exception("Failed to create router")
        self.creators.append(router_creator)

        LOGGER.debug("Creating flavor '%s'...", self.flavor_name)
        flavor_creator = OpenStackFlavor(
            self.os_creds, FlavorConfig(
                name=self.flavor_name, ram=self.FLAVOR_RAM, disk=1, vcpus=1,
                metadata=self.FLAVOR_EXTRA_SPECS))
        if flavor_creator is None or flavor_creator.create() is None:
            raise Exception("Failed to create flavor")
        self.creators.append(flavor_creator)

        LOGGER.debug("Creating flavor '%s'...", self.flavor_alt_name)
        flavor_alt_creator = OpenStackFlavor(
            self.os_creds, FlavorConfig(
                name=self.flavor_alt_name, ram=self.FLAVOR_RAM_ALT, disk=1,
                vcpus=1, metadata=self.FLAVOR_EXTRA_SPECS))
        if flavor_alt_creator is None or flavor_alt_creator.create() is None:
            raise Exception("Failed to create flavor")
        self.creators.append(flavor_alt_creator)
예제 #5
0
    def run(self, **kwargs):  # pylint: disable=too-many-locals
        """
        Begins the test execution which should originate from the subclass
        """
        self.logger.info('Begin virtual environment setup')

        self.start_time = time.time()
        self.logger.info(
            "vPing Start Time:'%s'",
            datetime.fromtimestamp(
                self.start_time).strftime('%Y-%m-%d %H:%M:%S'))

        image_base_name = '{}-{}'.format(getattr(CONST, 'vping_image_name'),
                                         str(self.guid))
        os_image_settings = openstack_tests.cirros_image_settings(
            image_base_name, image_metadata=self.cirros_image_config)
        self.logger.info("Creating image with name: '%s'", image_base_name)

        self.image_creator = deploy_utils.create_image(self.os_creds,
                                                       os_image_settings)
        self.creators.append(self.image_creator)

        private_net_name = getattr(CONST, 'vping_private_net_name') + self.guid
        private_subnet_name = getattr(CONST,
                                      'vping_private_subnet_name') + self.guid
        private_subnet_cidr = getattr(CONST, 'vping_private_subnet_cidr')

        vping_network_type = None
        vping_physical_network = None
        vping_segmentation_id = None

        if hasattr(CONST, 'vping_network_type'):
            vping_network_type = getattr(CONST, 'vping_network_type')
        if hasattr(CONST, 'vping_physical_network'):
            vping_physical_network = getattr(CONST, 'vping_physical_network')
        if hasattr(CONST, 'vping_segmentation_id'):
            vping_segmentation_id = getattr(CONST, 'vping_segmentation_id')

        self.logger.info("Creating network with name: '%s'", private_net_name)
        self.network_creator = deploy_utils.create_network(
            self.os_creds,
            NetworkConfig(name=private_net_name,
                          network_type=vping_network_type,
                          physical_network=vping_physical_network,
                          segmentation_id=vping_segmentation_id,
                          subnet_settings=[
                              SubnetConfig(name=private_subnet_name,
                                           cidr=private_subnet_cidr)
                          ]))
        self.creators.append(self.network_creator)

        # Creating router to external network
        log = "Creating router with name: '%s'" % self.router_name
        self.logger.info(log)
        ext_net_name = snaps_utils.get_ext_net_name(self.os_creds)
        self.router_creator = deploy_utils.create_router(
            self.os_creds,
            RouterConfig(name=self.router_name,
                         external_gateway=ext_net_name,
                         internal_subnets=[private_subnet_name]))
        self.creators.append(self.router_creator)

        self.logger.info("Creating flavor with name: '%s'", self.flavor_name)
        scenario = getattr(CONST, 'DEPLOY_SCENARIO')
        flavor_metadata = None
        flavor_ram = 512
        if 'ovs' in scenario or 'fdio' in scenario:
            flavor_metadata = create_flavor.MEM_PAGE_SIZE_LARGE
            flavor_ram = 1024
        flavor_creator = OpenStackFlavor(
            self.os_creds,
            FlavorConfig(name=self.flavor_name,
                         ram=flavor_ram,
                         disk=1,
                         vcpus=1,
                         metadata=flavor_metadata))
        flavor_creator.create()
        self.creators.append(flavor_creator)