示例#1
0
    def __init__(self, **kwargs):
        super(SnapsTestRunner, self).__init__(**kwargs)
        self.logger = logging.getLogger(__name__)
        self.os_creds = kwargs.get('os_creds') or snaps_utils.get_credentials()

        if 'ext_net_name' in kwargs:
            self.ext_net_name = kwargs['ext_net_name']
        else:
            self.ext_net_name = snaps_utils.get_ext_net_name(self.os_creds)

        self.netconf_override = None
        if hasattr(config.CONF, 'snaps_network_config'):
            self.netconf_override = getattr(config.CONF,
                                            'snaps_network_config')

        self.use_fip = (getattr(config.CONF,
                                'snaps_use_floating_ips') == 'True')
        self.use_keystone = (getattr(config.CONF,
                                     'snaps_use_keystone') == 'True')

        self.flavor_metadata = getattr(config.CONF, 'snaps_flavor_extra_specs',
                                       None)
        self.logger.info("Using flavor metadata '%s'", self.flavor_metadata)

        self.image_metadata = None
        if hasattr(config.CONF, 'snaps_images'):
            self.image_metadata = getattr(config.CONF, 'snaps_images')
示例#2
0
    def __init__(self, **kwargs):
        super(VPingBase, self).__init__(**kwargs)
        self.logger = logging.getLogger(__name__)
        self.os_creds = kwargs.get('os_creds') or snaps_utils.get_credentials()
        self.creators = list()
        self.image_creator = None
        self.network_creator = None
        self.vm1_creator = None
        self.vm2_creator = None
        self.router_creator = None

        # Shared metadata
        self.guid = '-' + str(uuid.uuid4())

        self.router_name = getattr(CONST, 'vping_router_name') + self.guid
        self.vm1_name = getattr(CONST, 'vping_vm_name_1') + self.guid
        self.vm2_name = getattr(CONST, 'vping_vm_name_2') + self.guid

        self.vm_boot_timeout = getattr(CONST, 'vping_vm_boot_timeout')
        self.vm_delete_timeout = getattr(CONST, 'vping_vm_delete_timeout')
        self.vm_ssh_connect_timeout = getattr(CONST,
                                              'vping_vm_ssh_connect_timeout')
        self.ping_timeout = getattr(CONST, 'vping_ping_timeout')
        self.flavor_name = 'vping-flavor' + self.guid

        # Move this configuration option up for all tests to leverage
        if hasattr(CONST, 'snaps_images_cirros'):
            self.cirros_image_config = getattr(CONST, 'snaps_images_cirros')
        else:
            self.cirros_image_config = None
示例#3
0
    def __init__(self, **kwargs):
        super(SnapsTestRunner, self).__init__(**kwargs)
        self.logger = logging.getLogger(__name__)
        self.os_creds = kwargs.get('os_creds') or snaps_utils.get_credentials()

        if 'ext_net_name' in kwargs:
            self.ext_net_name = kwargs['ext_net_name']
        else:
            self.ext_net_name = snaps_utils.get_ext_net_name(self.os_creds)

        self.netconf_override = None
        if hasattr(CONST, 'snaps_network_config'):
            self.netconf_override = CONST.__getattribute__(
                'snaps_network_config')

        self.use_fip = (
            CONST.__getattribute__('snaps_use_floating_ips') == 'True')
        self.use_keystone = (
            CONST.__getattribute__('snaps_use_keystone') == 'True')
        scenario = CONST.__getattribute__('DEPLOY_SCENARIO')

        self.flavor_metadata = None
        if 'ovs' in scenario or 'fdio' in scenario:
            self.flavor_metadata = create_flavor.MEM_PAGE_SIZE_LARGE

        self.logger.info("Using flavor metadata '%s'", self.flavor_metadata)

        self.image_metadata = None
        if hasattr(CONST, 'snaps_images'):
            self.image_metadata = CONST.__getattribute__('snaps_images')
示例#4
0
    def __init__(self, **kwargs):
        super(SnapsTestRunner, self).__init__(**kwargs)
        self.logger = logging.getLogger(__name__)

        try:
            cloud_config = os_client_config.get_config()
            self.orig_cloud = shade.OpenStackCloud(cloud_config=cloud_config)
            guid = str(uuid.uuid4())
            self.project = tenantnetwork.NewProject(self.orig_cloud,
                                                    self.case_name, guid)
            self.project.create()
        except Exception:  # pylint: disable=broad-except
            raise Exception("Cannot create user or project")

        if self.orig_cloud.get_role("admin"):
            role_name = "admin"
        elif self.orig_cloud.get_role("Admin"):
            role_name = "Admin"
        else:
            raise Exception("Cannot detect neither admin nor Admin")
        self.orig_cloud.grant_role(role_name,
                                   user=self.project.user.id,
                                   project=self.project.project.id,
                                   domain=self.project.domain.id)
        self.role = None
        if not self.orig_cloud.get_role("heat_stack_owner"):
            self.role = self.orig_cloud.create_role("heat_stack_owner")
        self.orig_cloud.grant_role("heat_stack_owner",
                                   user=self.project.user.id,
                                   project=self.project.project.id,
                                   domain=self.project.domain.id)
        creds_overrides = dict(username=self.project.user.name,
                               project_name=self.project.project.name,
                               project_id=self.project.project.id,
                               password=self.project.password)
        self.os_creds = kwargs.get('os_creds') or snaps_utils.get_credentials(
            overrides=creds_overrides)
        if 'ext_net_name' in kwargs:
            self.ext_net_name = kwargs['ext_net_name']
        else:
            self.ext_net_name = snaps_utils.get_ext_net_name(self.os_creds)

        self.netconf_override = None
        if hasattr(config.CONF, 'snaps_network_config'):
            self.netconf_override = getattr(config.CONF,
                                            'snaps_network_config')

        self.use_fip = (getattr(config.CONF,
                                'snaps_use_floating_ips') == 'True')
        self.use_keystone = (getattr(config.CONF,
                                     'snaps_use_keystone') == 'True')

        self.flavor_metadata = getattr(config.CONF, 'snaps_flavor_extra_specs',
                                       None)
        self.logger.info("Using flavor metadata '%s'", self.flavor_metadata)

        self.image_metadata = None
        if hasattr(config.CONF, 'snaps_images'):
            self.image_metadata = getattr(config.CONF, 'snaps_images')
示例#5
0
    def __init__(self, **kwargs):
        self.os_creds = kwargs.get('os_creds') or snaps_utils.get_credentials()
        self.guid = '-' + str(uuid.uuid4())
        self.creators = list()

        if hasattr(CONST, 'snaps_images_cirros'):
            self.cirros_image_config = CONST.__getattribute__(
                'snaps_images_cirros')
        else:
            self.cirros_image_config = None
示例#6
0
文件: rally.py 项目: colvert/functest
 def __init__(self, **kwargs):
     """Initialize RallyBase object."""
     super(RallyBase, self).__init__(**kwargs)
     self.os_creds = kwargs.get('os_creds') or snaps_utils.get_credentials()
     self.guid = '-' + str(uuid.uuid4())
     self.creators = []
     self.mode = ''
     self.summary = []
     self.scenario_dir = ''
     self.image_name = None
     self.ext_net_name = None
     self.priv_net_id = None
     self.flavor_name = None
     self.flavor_alt_name = None
     self.smoke = None
     self.test_name = None
     self.start_time = None
     self.result = None
     self.details = None
     self.compute_cnt = 0
示例#7
0
    def run(self, **kwargs):
        """Run suites in OPNFV environment

        It basically checks env vars to call main() with the keywords
        required.

        Args:
            kwargs: Arbitrary keyword arguments.

        Returns:
            EX_OK if all suites ran well.
            EX_RUN_ERROR otherwise.
        """
        try:
            suites = self.default_suites
            try:
                suites = kwargs["suites"]
            except KeyError:
                pass
            snaps_creds = snaps_utils.get_credentials()
            kwargs = {
                'neutronurl':
                keystone_utils.get_endpoint(snaps_creds, 'network')
            }
            kwargs['odlip'] = urllib.parse.urlparse(
                kwargs['neutronurl']).hostname
            kwargs['odlwebport'] = '8080'
            kwargs['odlrestconfport'] = '8181'
            kwargs['odlusername'] = '******'
            kwargs['odlpassword'] = '******'
            installer_type = None
            if 'INSTALLER_TYPE' in os.environ:
                installer_type = os.environ['INSTALLER_TYPE']
            kwargs['osusername'] = os.environ['OS_USERNAME']
            kwargs['osuserdomainname'] = os.environ.get(
                'OS_USER_DOMAIN_NAME', 'Default')
            kwargs['osprojectname'] = os.environ['OS_PROJECT_NAME']
            kwargs['osprojectdomainname'] = os.environ.get(
                'OS_PROJECT_DOMAIN_NAME', 'Default')
            kwargs['osauthurl'] = os.environ['OS_AUTH_URL']
            kwargs['ospassword'] = os.environ['OS_PASSWORD']
            if installer_type == 'fuel':
                kwargs['odlwebport'] = '8181'
                kwargs['odlrestconfport'] = '8282'
            elif installer_type == 'apex' or installer_type == 'netvirt':
                kwargs['odlip'] = os.environ['SDN_CONTROLLER_IP']
                kwargs['odlwebport'] = '8081'
                kwargs['odlrestconfport'] = '8081'
            elif installer_type == 'joid':
                kwargs['odlip'] = os.environ['SDN_CONTROLLER']
            elif installer_type == 'compass':
                kwargs['odlrestconfport'] = '8080'
            elif installer_type == 'daisy':
                kwargs['odlip'] = os.environ['SDN_CONTROLLER_IP']
                kwargs['odlwebport'] = '8181'
                kwargs['odlrestconfport'] = '8087'
            else:
                kwargs['odlip'] = os.environ['SDN_CONTROLLER_IP']
        except KeyError as ex:
            self.__logger.error(
                "Cannot run ODL testcases. "
                "Please check env var: "
                "%s", str(ex))
            return self.EX_RUN_ERROR
        except Exception:  # pylint: disable=broad-except
            self.__logger.exception("Cannot run ODL testcases.")
            return self.EX_RUN_ERROR

        return self.run_suites(suites, **kwargs)