Пример #1
0
    def _prepare_run(self):
        # pylint: disable=attribute-defined-outside-init
        self._isolated_creds = credentials.get_isolated_credentials(
            self.__class__.__name__, network_resources={})
        self._manager = clients.Manager(credentials=self._credentials())
        self._admin_manager = clients.Manager(self._admin_credentials())

        # Clients (in alphabetical order)
        self._flavors_client = self._manager.flavors_client
        self._floating_ips_client = self._manager.floating_ips_client
        # Glance image client v1
        self._image_client = self._manager.image_client
        # Compute image client
        self._images_client = self._manager.images_client
        self._keypairs_client = self._manager.keypairs_client
        self._networks_client = self._admin_manager.networks_client
        # Nova security groups client
        self._security_groups_client = self._manager.security_groups_client
        self._servers_client = self._manager.servers_client
        self._volumes_client = self._manager.volumes_client
        self._snapshots_client = self._manager.snapshots_client
        self._interface_client = self._manager.interfaces_client
        # Neutron network client
        self._network_client = self._manager.network_client
        # Heat client
        self._orchestration_client = self._manager.orchestration_client
Пример #2
0
    def resource_setup(cls):
        cls.set_network_resources()
        super(BaseObjectTest, cls).resource_setup()
        if not CONF.service_available.swift:
            skip_msg = ("%s skipped as swift is not available" % cls.__name__)
            raise cls.skipException(skip_msg)
        cls.isolated_creds = credentials.get_isolated_credentials(
            cls.__name__, network_resources=cls.network_resources)
        # Get isolated creds for normal user
        cls.os = clients.Manager(cls.isolated_creds.get_primary_creds())
        # Get isolated creds for admin user
        cls.os_admin = clients.Manager(cls.isolated_creds.get_admin_creds())
        # Get isolated creds for alt user
        cls.os_alt = clients.Manager(cls.isolated_creds.get_alt_creds())

        cls.object_client = cls.os.object_client
        cls.container_client = cls.os.container_client
        cls.account_client = cls.os.account_client
        cls.token_client = cls.os_admin.token_client
        cls.identity_admin_client = cls.os_admin.identity_client
        cls.object_client_alt = cls.os_alt.object_client
        cls.container_client_alt = cls.os_alt.container_client
        cls.identity_client_alt = cls.os_alt.identity_client

        # Make sure we get fresh auth data after assigning swift role
        cls.object_client.auth_provider.clear_auth()
        cls.container_client.auth_provider.clear_auth()
        cls.account_client.auth_provider.clear_auth()
        cls.object_client_alt.auth_provider.clear_auth()
        cls.container_client_alt.auth_provider.clear_auth()

        cls.data = SwiftDataGenerator(cls.identity_admin_client)
Пример #3
0
 def setup_credentials(cls):
     super(BaseBaremetalTest, cls).setup_credentials()
     if (not hasattr(cls, 'isolated_creds')
             or not cls.isolated_creds.name == cls.__name__):
         cls.isolated_creds = credentials.get_isolated_credentials(
             name=cls.__name__, network_resources=cls.network_resources)
     cls.mgr = clients.Manager(cls.isolated_creds.get_admin_creds())
Пример #4
0
 def setup_credentials(cls):
     super(BaseBaremetalTest, cls).setup_credentials()
     if (not hasattr(cls, 'isolated_creds') or
         not cls.isolated_creds.name == cls.__name__):
         cls.isolated_creds = credentials.get_isolated_credentials(
             name=cls.__name__, network_resources=cls.network_resources)
     cls.mgr = clients.Manager(cls.isolated_creds.get_admin_creds())
Пример #5
0
    def get_client_manager(cls,
                           identity_version=None,
                           credential_type='primary'):
        """
        Returns an OpenStack client manager
        """
        force_tenant_isolation = getattr(cls, 'force_tenant_isolation', None)
        identity_version = identity_version or CONF.identity.auth_version

        if (not hasattr(cls, 'isolated_creds')
                or not cls.isolated_creds.name == cls.__name__):
            cls.isolated_creds = credentials.get_isolated_credentials(
                name=cls.__name__,
                network_resources=cls.network_resources,
                force_tenant_isolation=force_tenant_isolation,
                identity_version=identity_version)

        credentials_method = 'get_%s_creds' % credential_type
        if hasattr(cls.isolated_creds, credentials_method):
            creds = getattr(cls.isolated_creds, credentials_method)()
        else:
            raise exceptions.InvalidCredentials("Invalid credentials type %s" %
                                                credential_type)
        os = clients.Manager(credentials=creds, service=cls._service)
        return os
Пример #6
0
def main():
    print('Running config verification...')
    opts = parse_args()
    update = opts.update
    replace = opts.replace_ext
    global CONF_PARSER

    outfile = sys.stdout
    if update:
        conf_file = _get_config_file()
        if opts.output:
            outfile = open(opts.output, 'w+')
        CONF_PARSER = moves.configparser.SafeConfigParser()
        CONF_PARSER.optionxform = str
        CONF_PARSER.readfp(conf_file)
    icreds = credentials.get_isolated_credentials('verify_tempest_config')
    os = clients.Manager(icreds.get_primary_creds())
    services = check_service_availability(os, update)
    results = {}
    for service in ['nova', 'cinder', 'neutron', 'swift']:
        if service not in services:
            continue
        results = verify_extensions(os, service, results)

    # Verify API versions of all services in the keystone catalog and keystone
    # itself.
    services.append('keystone')
    for service in services:
        verify_api_versions(os, service, update)

    display_results(results, update, replace)
    if update:
        conf_file.close()
        CONF_PARSER.write(outfile)
    outfile.close()
Пример #7
0
def main():
    print('Running config verification...')
    opts = parse_args()
    update = opts.update
    replace = opts.replace_ext
    global CONF_PARSER

    outfile = sys.stdout
    if update:
        conf_file = _get_config_file()
        if opts.output:
            outfile = open(opts.output, 'w+')
        CONF_PARSER = moves.configparser.SafeConfigParser()
        CONF_PARSER.optionxform = str
        CONF_PARSER.readfp(conf_file)
    icreds = credentials.get_isolated_credentials('verify_tempest_config')
    os = clients.Manager(icreds.get_primary_creds())
    services = check_service_availability(os, update)
    results = {}
    for service in ['nova', 'cinder', 'neutron', 'swift']:
        if service not in services:
            continue
        results = verify_extensions(os, service, results)

    # Verify API versions of all services in the keystone catalog and keystone
    # itself.
    services.append('keystone')
    for service in services:
        verify_api_versions(os, service, update)

    display_results(results, update, replace)
    if update:
        conf_file.close()
        CONF_PARSER.write(outfile)
    outfile.close()
Пример #8
0
 def resource_setup(cls):
     if not CONF.cli.enabled:
         msg = "cli testing disabled"
         raise cls.skipException(msg)
     super(ClientTestBase, cls).resource_setup()
     cls.isolated_creds = credentials.get_isolated_credentials(cls.__name__)
     cls.creds = cls.isolated_creds.get_admin_creds()
Пример #9
0
    def resource_setup(cls):
        cls.set_network_resources()
        super(BaseObjectTest, cls).resource_setup()
        if not CONF.service_available.swift:
            skip_msg = ("%s skipped as swift is not available" % cls.__name__)
            raise cls.skipException(skip_msg)
        cls.isolated_creds = credentials.get_isolated_credentials(
            cls.__name__, network_resources=cls.network_resources)
        # Get isolated creds for normal user
        cls.os = clients.Manager(cls.isolated_creds.get_primary_creds())
        # Get isolated creds for admin user
        cls.os_admin = clients.Manager(cls.isolated_creds.get_admin_creds())
        # Get isolated creds for alt user
        cls.os_alt = clients.Manager(cls.isolated_creds.get_alt_creds())

        cls.object_client = cls.os.object_client
        cls.container_client = cls.os.container_client
        cls.account_client = cls.os.account_client
        cls.token_client = cls.os_admin.token_client
        cls.identity_admin_client = cls.os_admin.identity_client
        cls.object_client_alt = cls.os_alt.object_client
        cls.container_client_alt = cls.os_alt.container_client
        cls.identity_client_alt = cls.os_alt.identity_client

        # Make sure we get fresh auth data after assigning swift role
        cls.object_client.auth_provider.clear_auth()
        cls.container_client.auth_provider.clear_auth()
        cls.account_client.auth_provider.clear_auth()
        cls.object_client_alt.auth_provider.clear_auth()
        cls.container_client_alt.auth_provider.clear_auth()

        cls.data = SwiftDataGenerator(cls.identity_admin_client)
Пример #10
0
 def resource_setup(cls):
     if not CONF.cli.enabled:
         msg = "cli testing disabled"
         raise cls.skipException(msg)
     super(ClientTestBase, cls).resource_setup()
     cls.cred_prov = credentials.get_isolated_credentials(cls.__name__)
     cls.creds = cls.cred_prov.get_admin_creds()
Пример #11
0
 def __init__(self):
     self.isolated_creds = credentials.get_isolated_credentials(
         name='InputScenarioUtils',
         identity_version=CONF.identity.auth_version)
     os = clients.Manager(self.isolated_creds.get_primary_creds())
     self.images_client = os.images_client
     self.flavors_client = os.flavors_client
     self.image_pattern = CONF.input_scenario.image_regex
     self.flavor_pattern = CONF.input_scenario.flavor_regex
Пример #12
0
 def __init__(self):
     network_resources = {"network": False, "router": False, "subnet": False, "dhcp": False}
     self.isolated_creds = credentials.get_isolated_credentials(
         name="InputScenarioUtils", identity_version=CONF.identity.auth_version, network_resources=network_resources
     )
     os = clients.Manager(self.isolated_creds.get_primary_creds())
     self.images_client = os.images_client
     self.flavors_client = os.flavors_client
     self.image_pattern = CONF.input_scenario.image_regex
     self.flavor_pattern = CONF.input_scenario.flavor_regex
Пример #13
0
 def resource_setup(cls):
     cls.set_network_resources()
     super(BaseImageTest, cls).resource_setup()
     cls.created_images = []
     cls._interface = 'json'
     cls.isolated_creds = credentials.get_isolated_credentials(
         cls.__name__, network_resources=cls.network_resources)
     if not CONF.service_available.glance:
         skip_msg = ("%s skipped as glance is not available" % cls.__name__)
         raise cls.skipException(skip_msg)
     cls.os = clients.Manager(cls.isolated_creds.get_primary_creds())
Пример #14
0
 def __init__(self):
     # Load configuration items
     self.ssh_users = json.loads(CONF.input_scenario.ssh_user_regex)
     self.non_ssh_image_pattern = \
         CONF.input_scenario.non_ssh_image_regex
     # Setup clients
     self.isolated_creds = credentials.get_isolated_credentials(
         name='ScenarioImageUtils',
         identity_version=CONF.identity.auth_version)
     os = clients.Manager(self.isolated_creds.get_primary_creds())
     self.images_client = os.images_client
     self.flavors_client = os.flavors_client
Пример #15
0
    def setup_credentials(cls):
        cls.set_network_resources()
        super(BaseObjectTest, cls).setup_credentials()

        cls.isolated_creds = credentials.get_isolated_credentials(
            cls.__name__, network_resources=cls.network_resources)
        # Get isolated creds for normal user
        cls.os = clients.Manager(cls.isolated_creds.get_primary_creds())
        # Get isolated creds for admin user
        cls.os_admin = clients.Manager(cls.isolated_creds.get_admin_creds())
        cls.data = SwiftDataGenerator(cls.os_admin.identity_client)
        # Get isolated creds for alt user
        cls.os_alt = clients.Manager(cls.isolated_creds.get_alt_creds())
Пример #16
0
    def setup_credentials(cls):
        cls.set_network_resources()
        super(BaseObjectTest, cls).setup_credentials()

        cls.isolated_creds = credentials.get_isolated_credentials(
            cls.__name__, network_resources=cls.network_resources)
        # Get isolated creds for normal user
        cls.os = clients.Manager(cls.isolated_creds.get_primary_creds())
        # Get isolated creds for admin user
        cls.os_admin = clients.Manager(cls.isolated_creds.get_admin_creds())
        cls.data = SwiftDataGenerator(cls.os_admin.identity_client)
        # Get isolated creds for alt user
        cls.os_alt = clients.Manager(cls.isolated_creds.get_alt_creds())
Пример #17
0
 def setup_credentials(cls):
     cls.set_network_resources()
     super(BaseObjectTest, cls).setup_credentials()
     cls.isolated_creds = credentials.get_isolated_credentials(
         cls.__name__, network_resources=cls.network_resources)
     operator_role = CONF.object_storage.operator_role
     if not cls.isolated_creds.is_role_available(operator_role):
         skip_msg = ("%s skipped because the configured credential provider"
                     " is not able to provide credentials with the %s role "
                     "assigned." % (cls.__name__, operator_role))
         raise cls.skipException(skip_msg)
     else:
         # Get isolated creds for normal user
         cls.os = clients.Manager(cls.isolated_creds.get_creds_by_roles(
             [operator_role]))
Пример #18
0
 def setup_credentials(cls):
     super(BaseOrchestrationTest, cls).setup_credentials()
     if (not hasattr(cls, 'isolated_creds') or
         not cls.isolated_creds.name == cls.__name__):
         cls.isolated_creds = credentials.get_isolated_credentials(
             name=cls.__name__, network_resources=cls.network_resources)
     stack_owner_role = CONF.orchestration.stack_owner_role
     if not cls.isolated_creds.is_role_available(stack_owner_role):
         skip_msg = ("%s skipped because the configured credential provider"
                     " is not able to provide credentials with the %s role "
                     "assigned." % (cls.__name__, stack_owner_role))
         raise cls.skipException(skip_msg)
     else:
         cls.os = clients.Manager(cls.isolated_creds.get_creds_by_roles(
             [stack_owner_role]))
Пример #19
0
 def setup_credentials(cls):
     super(BaseOrchestrationTest, cls).setup_credentials()
     if (not hasattr(cls, 'isolated_creds')
             or not cls.isolated_creds.name == cls.__name__):
         cls.isolated_creds = credentials.get_isolated_credentials(
             name=cls.__name__, network_resources=cls.network_resources)
     stack_owner_role = CONF.orchestration.stack_owner_role
     if not cls.isolated_creds.is_role_available(stack_owner_role):
         skip_msg = ("%s skipped because the configured credential provider"
                     " is not able to provide credentials with the %s role "
                     "assigned." % (cls.__name__, stack_owner_role))
         raise cls.skipException(skip_msg)
     else:
         cls.os = clients.Manager(
             cls.isolated_creds.get_creds_by_roles([stack_owner_role]))
Пример #20
0
 def setup_credentials(cls):
     cls.set_network_resources()
     super(BaseObjectTest, cls).setup_credentials()
     cls.isolated_creds = credentials.get_isolated_credentials(
         cls.__name__, network_resources=cls.network_resources)
     operator_role = CONF.object_storage.operator_role
     if not cls.isolated_creds.is_role_available(operator_role):
         skip_msg = ("%s skipped because the configured credential provider"
                     " is not able to provide credentials with the %s role "
                     "assigned." % (cls.__name__, operator_role))
         raise cls.skipException(skip_msg)
     else:
         # Get isolated creds for normal user
         cls.os = clients.Manager(
             cls.isolated_creds.get_creds_by_roles([operator_role]))
Пример #21
0
 def __init__(self):
     network_resources = {
         'network': False,
         'router': False,
         'subnet': False,
         'dhcp': False,
     }
     self.isolated_creds = credentials.get_isolated_credentials(
         name='InputScenarioUtils',
         identity_version=CONF.identity.auth_version,
         network_resources=network_resources)
     os = clients.Manager(self.isolated_creds.get_primary_creds())
     self.images_client = os.images_client
     self.flavors_client = os.flavors_client
     self.image_pattern = CONF.input_scenario.image_regex
     self.flavor_pattern = CONF.input_scenario.flavor_regex
Пример #22
0
    def get_client_manager(cls):
        """
        Returns an OpenStack client manager
        """
        force_tenant_isolation = getattr(cls, 'force_tenant_isolation', None)

        if (not hasattr(cls, 'isolated_creds') or
            not cls.isolated_creds.name == cls.__name__):
            cls.isolated_creds = credentials.get_isolated_credentials(
                name=cls.__name__, network_resources=cls.network_resources,
                force_tenant_isolation=force_tenant_isolation,
            )

        creds = cls.isolated_creds.get_primary_creds()
        os = clients.Manager(credentials=creds, service=cls._service)
        return os
Пример #23
0
    def _get_credentials_provider(cls):
        """Returns a credentials provider

        If no credential provider exists yet creates one.
        It uses self.identity_version if defined, or the configuration value
        """
        if (not hasattr(cls, '_creds_provider') or not cls._creds_provider or
                not cls._creds_provider.name == cls.__name__):
            force_tenant_isolation = getattr(cls, 'force_tenant_isolation',
                                             False)
            identity_version = getattr(cls, 'identity_version', None)
            identity_version = identity_version or CONF.identity.auth_version

            cls._creds_provider = credentials.get_isolated_credentials(
                name=cls.__name__, network_resources=cls.network_resources,
                force_tenant_isolation=force_tenant_isolation,
                identity_version=identity_version)
        return cls._creds_provider
Пример #24
0
    def _get_credentials_provider(cls):
        """Returns a credentials provider

        If no credential provider exists yet creates one.
        It uses self.identity_version if defined, or the configuration value
        """
        if (not hasattr(cls, '_creds_provider') or not cls._creds_provider or
                not cls._creds_provider.name == cls.__name__):
            force_tenant_isolation = getattr(cls, 'force_tenant_isolation',
                                             False)
            identity_version = getattr(cls, 'identity_version', None)
            identity_version = identity_version or CONF.identity.auth_version

            cls._creds_provider = credentials.get_isolated_credentials(
                name=cls.__name__, network_resources=cls.network_resources,
                force_tenant_isolation=force_tenant_isolation,
                identity_version=identity_version)
        return cls._creds_provider
Пример #25
0
    def get_client_manager(cls, identity_version=None):
        """
        Returns an OpenStack client manager
        """
        force_tenant_isolation = getattr(cls, 'force_tenant_isolation', None)
        identity_version = identity_version or CONF.identity.auth_version

        if (not hasattr(cls, 'isolated_creds')
                or not cls.isolated_creds.name == cls.__name__):
            cls.isolated_creds = credentials.get_isolated_credentials(
                name=cls.__name__,
                network_resources=cls.network_resources,
                force_tenant_isolation=force_tenant_isolation,
                identity_version=identity_version)

        creds = cls.isolated_creds.get_primary_creds()
        os = clients.Manager(credentials=creds, service=cls._service)
        return os
Пример #26
0
    def get_client_manager(cls, interface=None):
        """
        Returns an OpenStack client manager
        """
        force_tenant_isolation = getattr(cls, "force_tenant_isolation", None)

        cls.isolated_creds = credentials.get_isolated_credentials(
            name=cls.__name__, network_resources=cls.network_resources, force_tenant_isolation=force_tenant_isolation
        )

        creds = cls.isolated_creds.get_primary_creds()
        params = dict(credentials=creds, service=cls._service)
        if getattr(cls, "_interface", None):
            interface = cls._interface
        if interface:
            params["interface"] = interface
        os = clients.Manager(**params)
        return os
Пример #27
0
    def get_client_manager(cls, interface=None):
        """
        Returns an OpenStack client manager
        """
        force_tenant_isolation = getattr(cls, 'force_tenant_isolation', None)

        cls.isolated_creds = credentials.get_isolated_credentials(
            name=cls.__name__, network_resources=cls.network_resources,
            force_tenant_isolation=force_tenant_isolation,
        )

        creds = cls.isolated_creds.get_primary_creds()
        params = dict(credentials=creds, service=cls._service)
        if getattr(cls, '_interface', None):
            interface = cls._interface
        if interface:
            params['interface'] = interface
        os = clients.Manager(**params)
        return os
Пример #28
0
    def get_client_manager(cls, interface=None):
        """
        Returns an OpenStack client manager
        """
        force_tenant_isolation = getattr(cls, 'force_tenant_isolation', None)

        if (not hasattr(cls, 'isolated_creds') or
            not cls.isolated_creds.name == cls.__name__):
            cls.isolated_creds = credentials.get_isolated_credentials(
                name=cls.__name__, network_resources=cls.network_resources,
                force_tenant_isolation=force_tenant_isolation,
            )

        creds = cls.isolated_creds.get_primary_creds()
        params = dict(credentials=creds, service=cls._service)
        if getattr(cls, '_interface', None):
            interface = cls._interface
        if interface:
            params['interface'] = interface
        os = clients.Manager(**params)
        return os
Пример #29
0
    def get_client_manager(cls, identity_version=None,
                           credential_type='primary'):
        """
        Returns an OpenStack client manager
        """
        force_tenant_isolation = getattr(cls, 'force_tenant_isolation', None)
        identity_version = identity_version or CONF.identity.auth_version

        if (not hasattr(cls, 'isolated_creds') or
            not cls.isolated_creds.name == cls.__name__):
            cls.isolated_creds = credentials.get_isolated_credentials(
                name=cls.__name__, network_resources=cls.network_resources,
                force_tenant_isolation=force_tenant_isolation,
                identity_version=identity_version
            )

        credentials_method = 'get_%s_creds' % credential_type
        if hasattr(cls.isolated_creds, credentials_method):
            creds = getattr(cls.isolated_creds, credentials_method)()
        else:
            raise exceptions.InvalidCredentials(
                "Invalid credentials type %s" % credential_type)
        os = clients.Manager(credentials=creds, service=cls._service)
        return os
Пример #30
0
 def _get_tenant(self, tenant):
     iso_creds = credentials.get_isolated_credentials(tenant)
     self.addCleanup(iso_creds.clear_isolated_creds)
     # Get admin credentials to be able to create resources
     tenant_admin_creds = iso_creds.get_credentials("admin")
     return tenant_admin_creds
Пример #31
0
 def setup_credentials(cls):
     super(BaseImageTest, cls).setup_credentials()
     cls.isolated_creds = credentials.get_isolated_credentials(
         cls.__name__, network_resources=cls.network_resources)
     cls.os = clients.Manager(cls.isolated_creds.get_primary_creds())
Пример #32
0
 def _get_tenant(self, tenant):
     iso_creds = credentials.get_isolated_credentials(tenant)
     self.addCleanup(iso_creds.clear_isolated_creds)
     # Get admin credentials to be able to create resources
     tenant_admin_creds = iso_creds.get_credentials('admin')
     return tenant_admin_creds
Пример #33
0
 def setup_credentials(cls):
     super(BaseImageTest, cls).setup_credentials()
     cls.isolated_creds = credentials.get_isolated_credentials(
         cls.__name__, network_resources=cls.network_resources)
     cls.os = clients.Manager(cls.isolated_creds.get_primary_creds())