Esempio n. 1
0
    def __init__(self, credentials=None, service=None):
        super(Manager, self).__init__(credentials=credentials)

        params = {'service': 'image', 'region': CONF.identity.region}
        self.images_client = images_client.ImagesClient(
            self.auth_provider, **params)
        self.container_client = ZunClient(self.auth_provider)
Esempio n. 2
0
    def __init__(self, credentials=None, service=None):
        super(Manager, self).__init__(credentials=credentials)

        self.images_client = images_client.ImagesClient(
            self.auth_provider, 'image', CONF.identity.region)
        self.ports_client = ports_client.PortsClient(
            self.auth_provider, 'network', CONF.identity.region)
        self.sgs_client = security_groups_client.SecurityGroupsClient(
            self.auth_provider, 'network', CONF.identity.region)
        self.container_client = ZunClient(self.auth_provider)
Esempio n. 3
0
 def set_image_client_v2(self):
     self.image_client_v2 = image_cli.ImagesClient(self.auth_provider,
                                                   **self.image_params)
Esempio n. 4
0
 def setUp(self):
     super(TestImagesClient, self).setUp()
     fake_auth = fake_auth_provider.FakeAuthProvider()
     self.client = images_client.ImagesClient(fake_auth, 'image',
                                              'regionOne')
Esempio n. 5
0
    def __init__(self, conf, admin):
        self.identity_version = self.get_identity_version(conf)
        if admin:
            username = conf.get_defaulted('identity', 'admin_username')
            password = conf.get_defaulted('identity', 'admin_password')
            tenant_name = conf.get_defaulted('identity', 'admin_tenant_name')
        else:
            username = conf.get_defaulted('identity', 'username')
            password = conf.get_defaulted('identity', 'password')
            tenant_name = conf.get_defaulted('identity', 'tenant_name')

        self.identity_region = conf.get_defaulted('identity', 'region')
        default_params = {
            'disable_ssl_certificate_validation':
                conf.get_defaulted('identity',
                                   'disable_ssl_certificate_validation'),
            'ca_certs': conf.get_defaulted('identity', 'ca_certificates_file')
        }
        compute_params = {
            'service': conf.get_defaulted('compute', 'catalog_type'),
            'region': self.identity_region,
            'endpoint_type': conf.get_defaulted('compute', 'endpoint_type')
        }
        compute_params.update(default_params)

        if self.identity_version == "v2":
            _creds = self.get_credentials(conf, username, tenant_name,
                                          password)
        else:
            _creds = self.get_credentials(
                conf, username, tenant_name, password,
                identity_version=self.identity_version)

        _auth = self.get_auth_provider(conf, _creds)
        self.auth_provider = _auth

        if "v2.0" in conf.get("identity", "uri"):
            self.identity = identity_client.IdentityClient(
                _auth, conf.get_defaulted('identity', 'catalog_type'),
                self.identity_region, endpoint_type='adminURL',
                **default_params)
        else:
            self.identity = identity_v3_client.IdentityV3Client(
                _auth, conf.get_defaulted('identity', 'catalog_type'),
                self.identity_region, endpoint_type='adminURL',
                **default_params)

        self.tenants = tenants_client.TenantsClient(
            _auth,
            conf.get_defaulted('identity', 'catalog_type'),
            self.identity_region,
            endpoint_type='adminURL',
            **default_params)

        self.roles = roles_client.RolesClient(
            _auth,
            conf.get_defaulted('identity', 'catalog_type'),
            self.identity_region,
            endpoint_type='adminURL',
            **default_params)

        self.users = users_client.UsersClient(
            _auth,
            conf.get_defaulted('identity', 'catalog_type'),
            self.identity_region,
            endpoint_type='adminURL',
            **default_params)

        self.images = images_client.ImagesClient(
            _auth,
            conf.get_defaulted('image', 'catalog_type'),
            self.identity_region,
            **default_params)
        self.servers = servers_client.ServersClient(_auth,
                                                    **compute_params)
        self.flavors = flavors_client.FlavorsClient(_auth,
                                                    **compute_params)

        self.networks = None

        def create_nova_network_client():
            if self.networks is None:
                self.networks = nova_net_client.NetworksClient(
                    _auth, **compute_params)
            return self.networks

        def create_neutron_client():
            if self.networks is None:
                self.networks = networks_client.NetworksClient(
                    _auth,
                    conf.get_defaulted('network', 'catalog_type'),
                    self.identity_region,
                    endpoint_type=conf.get_defaulted('network',
                                                     'endpoint_type'),
                    **default_params)
            return self.networks

        self.get_nova_net_client = create_nova_network_client
        self.get_neutron_client = create_neutron_client

        # Set admin tenant id needed for keystone v3 tests.
        if admin:
            tenant_id = identity.get_tenant_by_name(self.tenants,
                                                    tenant_name)['id']
            conf.set('identity', 'admin_tenant_id', tenant_id)
Esempio n. 6
0
    def __init__(self, conf, creds):
        """Init method of ClientManager.

        :param conf: TempestConf object
        :param creds: Credentials object
        """
        self.identity_region = creds.identity_region
        self.auth_provider = creds.get_auth_provider()

        default_params = self._get_default_params(conf)
        compute_params = self._get_compute_params(conf)
        compute_params.update(default_params)

        catalog_type = conf.get_defaulted('identity', 'catalog_type')

        self.identity = self.get_identity_client(creds.identity_version,
                                                 catalog_type, default_params)

        self.projects = ProjectsClient(
            self.auth_provider, conf.get_defaulted('identity', 'catalog_type'),
            self.identity_region, 'publicURL', creds.identity_version,
            **default_params)

        self.set_roles_client(auth=self.auth_provider,
                              identity_version=creds.identity_version,
                              catalog_type=catalog_type,
                              endpoint_type='publicURL',
                              default_params=default_params)

        self.hosts_client = hosts_client.HostsClient(
            self.auth_provider, conf.get_defaulted('compute', 'catalog_type'),
            self.identity_region, **default_params)

        self.accounts = account_client.AccountClient(
            self.auth_provider,
            conf.get_defaulted('object-storage', 'catalog_type'),
            self.identity_region, **default_params)

        self.set_users_client(auth=self.auth_provider,
                              identity_version=creds.identity_version,
                              catalog_type=catalog_type,
                              endpoint_type='publicURL',
                              default_params=default_params)

        self.images = images_client.ImagesClient(
            self.auth_provider, conf.get_defaulted('image', 'catalog_type'),
            self.identity_region, **default_params)

        self.servers = servers_client.ServersClient(self.auth_provider,
                                                    **compute_params)
        self.flavors = flavors_client.FlavorsClient(self.auth_provider,
                                                    **compute_params)

        self.service_client = s_client.ServicesClient(
            self.auth_provider, conf.get_defaulted('identity', 'catalog_type'),
            self.identity_region, **default_params)

        self.volume_client = services_client.ServicesClient(
            self.auth_provider, conf.get_defaulted('volume', 'catalog_type'),
            self.identity_region, **default_params)

        self.networks = None

        def create_neutron_client():
            if self.networks is None:
                self.networks = networks_client.NetworksClient(
                    self.auth_provider,
                    conf.get_defaulted('network', 'catalog_type'),
                    self.identity_region,
                    endpoint_type=conf.get_defaulted('network',
                                                     'endpoint_type'),
                    **default_params)
            return self.networks

        self.get_neutron_client = create_neutron_client

        # Set admin project id needed for keystone v3 tests.
        if creds.admin:
            project = self.projects.get_project_by_name(creds.project_name)
            conf.set('auth', 'admin_project_id', project['id'])