Beispiel #1
0
    def resource_setup(cls):
        cls.set_network_resources()
        super(ShareScenarioTest, cls).resource_setup()

        # Manila clients
        cls.shares_client = shares_client.SharesClient(
            cls.os_primary.auth_provider)
        cls.shares_v2_client = shares_v2_client.SharesV2Client(
            cls.os_primary.auth_provider)
        cls.shares_admin_client = shares_client.SharesClient(
            cls.os_admin.auth_provider)
        cls.shares_admin_v2_client = shares_v2_client.SharesV2Client(
            cls.os_admin.auth_provider)
 def __init__(
         self,
         credentials=common_creds.get_configured_credentials('user'),
         service=None):
     super(Manager, self).__init__(credentials, service)
     self.shares_client = shares_client.SharesClient(self.auth_provider)
     self.shares_v2_client = shares_v2_client.SharesV2Client(
         self.auth_provider)
Beispiel #3
0
    def setup_clients(cls):
        super(BaseSharesMixedTest, cls).setup_clients()
        cls.admin_shares_client = shares_client.SharesClient(
            cls.os_admin.auth_provider)
        cls.admin_shares_v2_client = shares_v2_client.SharesV2Client(
            cls.os_admin.auth_provider)
        cls.alt_shares_client = shares_client.SharesClient(
            cls.os_alt.auth_provider)
        cls.alt_shares_v2_client = shares_v2_client.SharesV2Client(
            cls.os_alt.auth_provider)

        if CONF.share.multitenancy_enabled:
            admin_share_network_id = cls.provide_share_network(
                cls.admin_shares_v2_client, cls.os_admin.networks_client)
            cls.admin_shares_client.share_network_id = admin_share_network_id
            cls.admin_shares_v2_client.share_network_id = (
                admin_share_network_id)

            alt_share_network_id = cls.provide_share_network(
                cls.alt_shares_v2_client, cls.os_alt.networks_client)
            cls.alt_shares_client.share_network_id = alt_share_network_id
            cls.alt_shares_v2_client.share_network_id = alt_share_network_id
Beispiel #4
0
 def setup_clients(cls):
     super(BaseSharesTest, cls).setup_clients()
     os = getattr(cls, 'os_%s' % cls.credentials[0])
     os.shares_client = shares_client.SharesClient(os.auth_provider)
     cls.shares_client = os.shares_client
     os.shares_v2_client = shares_v2_client.SharesV2Client(os.auth_provider)
     cls.shares_v2_client = os.shares_v2_client
     if CONF.share.multitenancy_enabled:
         if not CONF.service_available.neutron:
             raise cls.skipException("Neutron support is required")
         share_network_id = cls.provide_share_network(
             cls.shares_v2_client, os.networks_client)
         cls.shares_client.share_network_id = share_network_id
         cls.shares_v2_client.share_network_id = share_network_id
Beispiel #5
0
    def setup_clients(cls):
        super(BaseSharesTest, cls).setup_clients()
        os = getattr(cls, 'os_%s' % cls.credentials[0])
        os.shares_client = shares_client.SharesClient(os.auth_provider)

        if CONF.identity.auth_version == 'v3':
            project_id = os.auth_provider.auth_data[1]['project']['id']
        else:
            project_id = os.auth_provider.auth_data[1]['token']['tenant']['id']
        cls.tenant_id = project_id
        cls.user_id = os.auth_provider.auth_data[1]['user']['id']

        cls.shares_client = os.shares_client
        os.shares_v2_client = shares_v2_client.SharesV2Client(os.auth_provider)
        cls.shares_v2_client = os.shares_v2_client
        if CONF.share.multitenancy_enabled:
            if (not CONF.service_available.neutron
                    and CONF.share.create_networks_when_multitenancy_enabled):
                raise cls.skipException("Neutron support is required")
            share_network_id = cls.provide_share_network(
                cls.shares_v2_client, os.networks_client)
            cls.shares_client.share_network_id = share_network_id
            cls.shares_v2_client.share_network_id = share_network_id
Beispiel #6
0
    def get_client_with_isolated_creds(cls,
                                       name=None,
                                       type_of_creds="admin",
                                       cleanup_in_class=False,
                                       client_version='1'):
        """Creates isolated creds.

        :param name: name, will be used for naming ic and related stuff
        :param type_of_creds: admin, alt or primary
        :param cleanup_in_class: defines place where to delete
        :returns: SharesClient -- shares client with isolated creds.
        :returns: To client added dict attr 'creds' with
        :returns: key elements 'tenant' and 'user'.
        """
        if name is None:
            # Get name of test method
            name = inspect.stack()[1][3]
            if len(name) > 32:
                name = name[0:32]

        # Choose type of isolated creds
        ic = dynamic_creds.DynamicCredentialProvider(
            identity_version=CONF.identity.auth_version,
            name=name,
            admin_role=CONF.identity.admin_role,
            admin_creds=common_creds.get_configured_admin_credentials())
        if "admin" in type_of_creds:
            creds = ic.get_admin_creds().credentials
        elif "alt" in type_of_creds:
            creds = ic.get_alt_creds().credentials
        else:
            creds = ic.get_credentials(type_of_creds).credentials
        ic.type_of_creds = type_of_creds

        # create client with isolated creds
        os = clients.Manager(credentials=creds)
        if client_version == '1':
            client = shares_client.SharesClient(os.auth_provider)
        elif client_version == '2':
            client = shares_v2_client.SharesV2Client(os.auth_provider)

        # Set place where will be deleted isolated creds
        ic_res = {
            "method": ic.clear_creds,
            "deleted": False,
        }
        if cleanup_in_class:
            cls.class_isolated_creds.insert(0, ic_res)
        else:
            cls.method_isolated_creds.insert(0, ic_res)

        # Provide share network
        if CONF.share.multitenancy_enabled:
            if (not CONF.service_available.neutron
                    and CONF.share.create_networks_when_multitenancy_enabled):
                raise cls.skipException("Neutron support is required")
            nc = os.networks_client
            share_network_id = cls.provide_share_network(client, nc, ic)
            client.share_network_id = share_network_id
            resource = {
                "type": "share_network",
                "id": client.share_network_id,
                "client": client,
            }
            if cleanup_in_class:
                cls.class_resources.insert(0, resource)
            else:
                cls.method_resources.insert(0, resource)
        return client
Beispiel #7
0
 def __init__(self, credentials=None, service=None):
     super(Manager, self).__init__(credentials, service)
     self.shares_client = shares_client.SharesClient(self.auth_provider)
     self.shares_v2_client = shares_v2_client.SharesV2Client(
         self.auth_provider)