def setUpClass(cls):
        super(ImagesOneServerTest, cls).setUpClass()
        cls.client = cls.images_client
        if not CONF.service_available.glance:
            skip_msg = ("%s skipped as glance is not available" % cls.__name__)
            raise cls.skipException(skip_msg)

        try:
            resp, server = cls.create_test_server(wait_until='ACTIVE')
            cls.server_id = server['id']
        except Exception:
            cls.tearDownClass()
            raise

        cls.image_ids = []

        if cls.multi_user:
            if CONF.compute.allow_tenant_isolation:
                creds = cls.isolated_creds.get_alt_creds()
                username, tenant_name, password = creds
                cls.alt_manager = clients.Manager(username=username,
                                                  password=password,
                                                  tenant_name=tenant_name)
            else:
                # Use the alt_XXX credentials in the config file
                cls.alt_manager = clients.AltManager()
            cls.alt_client = cls.alt_manager.images_client
Esempio n. 2
0
    def setUpClass(cls):
        super(VolumesTransfersTest, cls).setUpClass()

        # Add another tenant to test volume-transfer
        if CONF.compute.allow_tenant_isolation:
            creds = cls.isolated_creds.get_alt_creds()
            username, tenant_name, password = creds
            cls.os_alt = clients.Manager(username=username,
                                         password=password,
                                         tenant_name=tenant_name,
                                         interface=cls._interface)
            cls.alt_tenant_id = cls.isolated_creds.get_alt_tenant()['id']

            # Add admin tenant to cleanup resources
            adm_creds = cls.isolated_creds.get_admin_creds()
            admin_username, admin_tenant_name, admin_password = adm_creds
            cls.os_adm = clients.Manager(username=admin_username,
                                         password=admin_password,
                                         tenant_name=admin_tenant_name,
                                         interface=cls._interface)
        else:
            cls.os_alt = clients.AltManager()
            alt_tenant_name = cls.os_alt.credentials['tenant_name']
            identity_client = cls._get_identity_admin_client()
            _, tenants = identity_client.list_tenants()
            cls.alt_tenant_id = [tnt['id'] for tnt in tenants
                                 if tnt['name'] == alt_tenant_name][0]
            cls.os_adm = clients.ComputeAdminManager(interface=cls._interface)

        cls.client = cls.volumes_client
        cls.alt_client = cls.os_alt.volumes_client
        cls.adm_client = cls.os_adm.volumes_client
Esempio n. 3
0
 def setUpClass(cls):
     super(ServersNegativeV3Test, cls).setUpClass()
     cls.client = cls.servers_client
     cls.alt_os = clients.AltManager()
     cls.alt_client = cls.alt_os.servers_v3_client
     resp, server = cls.create_test_server(wait_until='ACTIVE')
     cls.server_id = server['id']
Esempio n. 4
0
    def resource_setup(cls):
        super(BaseV1ImageMembersTest, cls).resource_setup()
        if CONF.compute.allow_tenant_isolation:
            cls.os_alt = clients.Manager(cls.isolated_creds.get_alt_creds())
        else:
            cls.os_alt = clients.AltManager()

        cls.alt_img_cli = cls.os_alt.image_client
        cls.alt_tenant_id = cls.alt_img_cli.tenant_id
Esempio n. 5
0
    def setUpClass(cls):
        cls.set_network_resources()
        super(BaseObjectTest, cls).setUpClass()
        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 = isolated_creds.IsolatedCreds(
            cls.__name__, network_resources=cls.network_resources)
        if CONF.compute.allow_tenant_isolation:
            # Get isolated creds for normal user
            creds = cls.isolated_creds.get_primary_creds()
            username, tenant_name, password = creds
            cls.os = clients.Manager(username=username,
                                     password=password,
                                     tenant_name=tenant_name)
            # Get isolated creds for admin user
            admin_creds = cls.isolated_creds.get_admin_creds()
            admin_username, admin_tenant_name, admin_password = admin_creds
            cls.os_admin = clients.Manager(username=admin_username,
                                           password=admin_password,
                                           tenant_name=admin_tenant_name)
            # Get isolated creds for alt user
            alt_creds = cls.isolated_creds.get_alt_creds()
            alt_username, alt_tenant, alt_password = alt_creds
            cls.os_alt = clients.Manager(username=alt_username,
                                         password=alt_password,
                                         tenant_name=alt_tenant)
            # Add isolated users to operator role so that they can create a
            # container in swift.
            cls._assign_member_role()
        else:
            cls.os = clients.Manager()
            cls.os_admin = clients.AdminManager()
            cls.os_alt = clients.AltManager()

        cls.object_client = cls.os.object_client
        cls.container_client = cls.os.container_client
        cls.account_client = cls.os.account_client
        cls.custom_object_client = cls.os.custom_object_client
        cls.token_client = cls.os_admin.token_client
        cls.identity_admin_client = cls.os_admin.identity_client
        cls.custom_account_client = cls.os.custom_account_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.custom_object_client.auth_provider.clear_auth()
        cls.custom_account_client.auth_provider.clear_auth()
        cls.object_client_alt.auth_provider.clear_auth()
        cls.container_client_alt.auth_provider.clear_auth()

        cls.data = base.DataGenerator(cls.identity_admin_client)
Esempio n. 6
0
    def setUpClass(cls):
        if not CONF.service_available.glance:
            raise cls.skipException('Glance is not available.')
        # No network resources required for this test
        cls.set_network_resources()
        super(AuthorizationTestJSON, cls).setUpClass()
        if not cls.multi_user:
            msg = "Need >1 user"
            raise cls.skipException(msg)
        cls.client = cls.os.servers_client
        cls.images_client = cls.os.images_client
        cls.glance_client = cls.os.image_client
        cls.keypairs_client = cls.os.keypairs_client
        cls.security_client = cls.os.security_groups_client

        if CONF.compute.allow_tenant_isolation:
            creds = cls.isolated_creds.get_alt_creds()
            cls.alt_manager = clients.Manager(credentials=creds)
        else:
            # Use the alt_XXX credentials in the config file
            cls.alt_manager = clients.AltManager()

        cls.alt_client = cls.alt_manager.servers_client
        cls.alt_images_client = cls.alt_manager.images_client
        cls.alt_keypairs_client = cls.alt_manager.keypairs_client
        cls.alt_security_client = cls.alt_manager.security_groups_client

        resp, server = cls.create_test_server(wait_until='ACTIVE')
        resp, cls.server = cls.client.get_server(server['id'])

        name = data_utils.rand_name('image')
        resp, body = cls.glance_client.create_image(name=name,
                                                    container_format='bare',
                                                    disk_format='raw',
                                                    is_public=False)
        image_id = body['id']
        image_file = StringIO.StringIO(('*' * 1024))
        resp, body = cls.glance_client.update_image(image_id, data=image_file)
        cls.glance_client.wait_for_image_status(image_id, 'active')
        resp, cls.image = cls.images_client.get_image(image_id)

        cls.keypairname = data_utils.rand_name('keypair')
        resp, keypair = \
            cls.keypairs_client.create_keypair(cls.keypairname)

        name = data_utils.rand_name('security')
        description = data_utils.rand_name('description')
        resp, cls.security_group = cls.security_client.create_security_group(
            name, description)

        parent_group_id = cls.security_group['id']
        ip_protocol = 'tcp'
        from_port = 22
        to_port = 22
        resp, cls.rule = cls.security_client.create_security_group_rule(
            parent_group_id, ip_protocol, from_port, to_port)
 def setUpClass(cls):
     super(ServersNegativeTestJSON, cls).setUpClass()
     cls.client = cls.servers_client
     if CONF.compute.allow_tenant_isolation:
         cls.alt_os = clients.Manager(cls.isolated_creds.get_alt_creds())
     else:
         cls.alt_os = clients.AltManager()
     cls.alt_client = cls.alt_os.servers_client
     resp, server = cls.create_test_server(wait_until='ACTIVE')
     cls.server_id = server['id']
Esempio n. 8
0
 def setUpClass(cls):
     super(BaseV2MemberImageTest, cls).setUpClass()
     if CONF.compute.allow_tenant_isolation:
         creds = cls.isolated_creds.get_alt_creds()
         cls.os_alt = clients.Manager(creds)
     else:
         cls.os_alt = clients.AltManager()
     cls.os_img_client = cls.os.image_client_v2
     cls.alt_img_client = cls.os_alt.image_client_v2
     cls.alt_tenant_id = cls.alt_img_client.tenant_id
    def setUpClass(cls):
        if not compute.MULTI_USER:
            msg = "Need >1 user"
            raise cls.skipException(msg)

        super(AuthorizationTestJSON, cls).setUpClass()

        cls.client = cls.os.servers_client
        cls.images_client = cls.os.images_client
        cls.keypairs_client = cls.os.keypairs_client
        cls.security_client = cls.os.security_groups_client

        if cls.config.compute.allow_tenant_isolation:
            creds = cls.isolated_creds.get_alt_creds()
            username, tenant_name, password = creds
            cls.alt_manager = clients.Manager(username=username,
                                              password=password,
                                              tenant_name=tenant_name)
        else:
            # Use the alt_XXX credentials in the config file
            cls.alt_manager = clients.AltManager()

        cls.alt_client = cls.alt_manager.servers_client
        cls.alt_images_client = cls.alt_manager.images_client
        cls.alt_keypairs_client = cls.alt_manager.keypairs_client
        cls.alt_security_client = cls.alt_manager.security_groups_client

        cls.alt_security_client._set_auth()
        resp, server = cls.create_server(wait_until='ACTIVE')
        resp, cls.server = cls.client.get_server(server['id'])

        name = rand_name('image')
        resp, body = cls.client.create_image(server['id'], name)
        image_id = parse_image_id(resp['location'])
        cls.images_client.wait_for_image_resp_code(image_id, 200)
        cls.images_client.wait_for_image_status(image_id, 'ACTIVE')
        resp, cls.image = cls.images_client.get_image(image_id)

        cls.keypairname = rand_name('keypair')
        resp, keypair = \
            cls.keypairs_client.create_keypair(cls.keypairname)

        name = rand_name('security')
        description = rand_name('description')
        resp, cls.security_group = cls.security_client.create_security_group(
            name, description)

        parent_group_id = cls.security_group['id']
        ip_protocol = 'tcp'
        from_port = 22
        to_port = 22
        resp, cls.rule = cls.security_client.create_security_group_rule(
            parent_group_id, ip_protocol, from_port, to_port)
Esempio n. 10
0
    def setUpClass(cls):
        super(ListServersNegativeTestJSON, cls).setUpClass()
        cls.client = cls.servers_client
        cls.servers = []

        if compute.MULTI_USER:
            if cls.config.compute.allow_tenant_isolation:
                creds = cls.isolated_creds.get_alt_creds()
                username, tenant_name, password = creds
                cls.alt_manager = clients.Manager(username=username,
                                                  password=password,
                                                  tenant_name=tenant_name)
            else:
                # Use the alt_XXX credentials in the config file
                cls.alt_manager = clients.AltManager()
            cls.alt_client = cls.alt_manager.servers_client

        # Under circumstances when there is not a tenant/user
        # created for the test case, the test case checks
        # to see if there are existing servers for the
        # either the normal user/tenant or the alt user/tenant
        # and if so, the whole test is skipped. We do this
        # because we assume a baseline of no servers at the
        # start of the test instead of destroying any existing
        # servers.
        resp, body = cls.client.list_servers()
        cls._ensure_no_servers(body['servers'], cls.os.username,
                               cls.os.tenant_name)

        resp, body = cls.alt_client.list_servers()
        cls._ensure_no_servers(body['servers'], cls.alt_manager.username,
                               cls.alt_manager.tenant_name)

        # The following servers are created for use
        # by the test methods in this class. These
        # servers are cleaned up automatically in the
        # tearDownClass method of the super-class.
        cls.existing_fixtures = []
        cls.deleted_fixtures = []
        cls.start_time = datetime.datetime.utcnow()
        for x in xrange(2):
            resp, srv = cls.create_server()
            cls.existing_fixtures.append(srv)

        resp, srv = cls.create_server()
        cls.client.delete_server(srv['id'])
        # We ignore errors on termination because the server may
        # be put into ERROR status on a quick spawn, then delete,
        # as the compute node expects the instance local status
        # to be spawning, not deleted. See LP Bug#1061167
        cls.client.wait_for_server_termination(srv['id'], ignore_error=True)
        cls.deleted_fixtures.append(srv)
Esempio n. 11
0
    def setUpClass(cls):
        # No network resources required for this test
        cls.set_network_resources()
        super(AuthorizationTestJSON, cls).setUpClass()
        if not cls.multi_user:
            msg = "Need >1 user"
            raise cls.skipException(msg)
        cls.client = cls.os.servers_client
        cls.images_client = cls.os.images_client
        cls.keypairs_client = cls.os.keypairs_client
        cls.security_client = cls.os.security_groups_client

        if CONF.compute.allow_tenant_isolation:
            creds = cls.isolated_creds.get_alt_creds()
            cls.alt_manager = clients.Manager(credentials=creds)
        else:
            # Use the alt_XXX credentials in the config file
            cls.alt_manager = clients.AltManager()

        cls.alt_client = cls.alt_manager.servers_client
        cls.alt_images_client = cls.alt_manager.images_client
        cls.alt_keypairs_client = cls.alt_manager.keypairs_client
        cls.alt_security_client = cls.alt_manager.security_groups_client

        resp, server = cls.create_test_server(wait_until='ACTIVE')
        resp, cls.server = cls.client.get_server(server['id'])

        name = data_utils.rand_name('image')
        resp, body = cls.images_client.create_image(server['id'], name)
        image_id = data_utils.parse_image_id(resp['location'])
        cls.images_client.wait_for_image_status(image_id, 'ACTIVE')
        resp, cls.image = cls.images_client.get_image(image_id)

        cls.keypairname = data_utils.rand_name('keypair')
        resp, keypair = \
            cls.keypairs_client.create_keypair(cls.keypairname)

        name = data_utils.rand_name('security')
        description = data_utils.rand_name('description')
        resp, cls.security_group = cls.security_client.create_security_group(
            name, description)

        parent_group_id = cls.security_group['id']
        ip_protocol = 'tcp'
        from_port = 22
        to_port = 22
        resp, cls.rule = cls.security_client.create_security_group_rule(
            parent_group_id, ip_protocol, from_port, to_port)
Esempio n. 12
0
    def setUpClass(cls):
        super(BaseV1ImageMembersTest, cls).setUpClass()
        if CONF.compute.allow_tenant_isolation:
            creds = cls.isolated_creds.get_alt_creds()
            username, tenant_name, password = creds
            cls.os_alt = clients.Manager(username=username,
                                         password=password,
                                         tenant_name=tenant_name)
            cls.alt_tenant_id = cls.isolated_creds.get_alt_tenant()['id']
        else:
            cls.os_alt = clients.AltManager()
            identity_client = cls._get_identity_admin_client()
            cls.alt_tenant_id = identity_client.get_tenant_by_name(
                cls.os_alt.credentials['tenant_name'])['id']

        cls.alt_img_cli = cls.os_alt.image_client
Esempio n. 13
0
    def setUpClass(cls):
        super(ImageMembersTests, cls).setUpClass()
        if cls.config.compute.allow_tenant_isolation:
            creds = cls.isolated_creds.get_alt_creds()
            username, tenant_name, password = creds
            cls.os_alt = clients.Manager(username=username,
                                         password=password,
                                         tenant_name=tenant_name)
        else:
            cls.os_alt = clients.AltManager()

        alt_tenant_name = cls.os_alt.tenant_name
        identity_client = cls._get_identity_admin_client()
        _, tenants = identity_client.list_tenants()
        cls.alt_tenant_id = [
            tnt['id'] for tnt in tenants if tnt['name'] == alt_tenant_name
        ][0]
Esempio n. 14
0
 def setUpClass(cls):
     super(BaseV2MemberImageTest, cls).setUpClass()
     if CONF.compute.allow_tenant_isolation:
         creds = cls.isolated_creds.get_alt_creds()
         username, tenant_name, password = creds
         cls.os_alt = clients.Manager(username=username,
                                      password=password,
                                      tenant_name=tenant_name,
                                      interface=cls._interface)
         cls.alt_tenant_id = cls.isolated_creds.get_alt_tenant()['id']
     else:
         cls.os_alt = clients.AltManager()
         alt_tenant_name = cls.os_alt.tenant_name
         identity_client = cls._get_identity_admin_client()
         cls.alt_tenant_id = identity_client.get_tenant_by_name(
             alt_tenant_name)['id']
     cls.os_img_client = cls.os.image_client_v2
     cls.alt_img_client = cls.os_alt.image_client_v2
Esempio n. 15
0
    def resource_setup(cls):
        super(VolumesV2TransfersTest, cls).resource_setup()

        # Add another tenant to test volume-transfer
        if CONF.compute.allow_tenant_isolation:
            cls.os_alt = clients.Manager(cls.isolated_creds.get_alt_creds(),
                                         interface=cls._interface)
            # Add admin tenant to cleanup resources
            cls.os_adm = clients.Manager(cls.isolated_creds.get_admin_creds(),
                                         interface=cls._interface)
        else:
            cls.os_alt = clients.AltManager()
            cls.os_adm = clients.ComputeAdminManager(interface=cls._interface)

        cls.client = cls.volumes_client
        cls.alt_client = cls.os_alt.volumes_client
        cls.alt_tenant_id = cls.alt_client.tenant_id
        cls.adm_client = cls.os_adm.volumes_client
Esempio n. 16
0
    def setUpClass(cls):
        super(ImagesTestJSON, cls).setUpClass()
        cls.client = cls.images_client
        cls.servers_client = cls.servers_client

        cls.image_ids = []

        if compute.MULTI_USER:
            if cls.config.compute.allow_tenant_isolation:
                creds = cls._get_isolated_creds()
                username, tenant_name, password = creds
                cls.alt_manager = clients.Manager(username=username,
                                                  password=password,
                                                  tenant_name=tenant_name)
            else:
                # Use the alt_XXX credentials in the config file
                cls.alt_manager = clients.AltManager()
            cls.alt_client = cls.alt_manager.images_client
Esempio n. 17
0
    def setUpClass(cls):
        super(ImagesV3Test, cls).setUpClass()
        if not CONF.service_available.glance:
            skip_msg = ("%s skipped as glance is not available" % cls.__name__)
            raise cls.skipException(skip_msg)
        cls.client = cls.images_client
        cls.servers_client = cls.servers_client

        if cls.multi_user:
            if CONF.compute.allow_tenant_isolation:
                creds = cls.isolated_creds.get_alt_creds()
                username, tenant_name, password = creds
                cls.alt_manager = clients.Manager(username=username,
                                                  password=password,
                                                  tenant_name=tenant_name)
            else:
                # Use the alt_XXX credentials in the config file
                cls.alt_manager = clients.AltManager()
            cls.alt_client = cls.alt_manager.images_client
Esempio n. 18
0
    def setUpClass(cls):
        if not cls.config.service_available.swift:
            skip_msg = ("%s skipped as swift is not available" % cls.__name__)
            raise cls.skipException(skip_msg)
        cls.os = clients.Manager()
        cls.object_client = cls.os.object_client
        cls.container_client = cls.os.container_client
        cls.account_client = cls.os.account_client
        cls.custom_object_client = cls.os.custom_object_client
        cls.os_admin = clients.AdminManager()
        cls.token_client = cls.os_admin.token_client
        cls.identity_admin_client = cls.os_admin.identity_client
        cls.custom_account_client = cls.os.custom_account_client
        cls.os_alt = clients.AltManager()
        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

        cls.data = DataGenerator(cls.identity_admin_client)
Esempio n. 19
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 = isolated_creds.IsolatedCreds(
            cls.__name__, network_resources=cls.network_resources)
        if CONF.compute.allow_tenant_isolation:
            # 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())
        else:
            cls.os = clients.Manager()
            cls.os_admin = clients.AdminManager()
            cls.os_alt = clients.AltManager()

        cls.object_client = cls.os.object_client
        cls.container_client = cls.os.container_client
        cls.account_client = cls.os.account_client
        cls.custom_object_client = cls.os.custom_object_client
        cls.token_client = cls.os_admin.token_client
        cls.identity_admin_client = cls.os_admin.identity_client
        cls.custom_account_client = cls.os.custom_account_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.custom_object_client.auth_provider.clear_auth()
        cls.custom_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)
Esempio n. 20
0
    def setUpClass(cls):
        cls.os = clients.Manager()
        cls.object_client = cls.os.object_client
        cls.container_client = cls.os.container_client
        cls.account_client = cls.os.account_client
        cls.custom_object_client = cls.os.custom_object_client
        cls.os_admin = clients.AdminManager()
        cls.token_client = cls.os_admin.token_client
        cls.identity_admin_client = cls.os_admin.identity_client
        cls.custom_account_client = cls.os.custom_account_client
        cls.os_alt = clients.AltManager()
        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

        cls.data = DataGenerator(cls.identity_admin_client)

        try:
            cls.account_client.list_account_containers()
        except exceptions.EndpointNotFound:
            skip_msg = "No OpenStack Object Storage API endpoint"
            raise cls.skipException(skip_msg)
Esempio n. 21
0
    def setUpClass(cls):
        super(ImagesOneServerTestJSON, cls).setUpClass()
        cls.client = cls.images_client
        cls.servers_client = cls.servers_client

        try:
            resp, cls.server = cls.create_server(wait_until='ACTIVE')
        except Exception:
            cls.tearDownClass()
            raise

        cls.image_ids = []

        if compute.MULTI_USER:
            if cls.config.compute.allow_tenant_isolation:
                creds = cls._get_isolated_creds()
                username, tenant_name, password = creds
                cls.alt_manager = clients.Manager(username=username,
                                                  password=password,
                                                  tenant_name=tenant_name)
            else:
                # Use the alt_XXX credentials in the config file
                cls.alt_manager = clients.AltManager()
            cls.alt_client = cls.alt_manager.images_client
Esempio n. 22
0
 def setUpClass(cls):
     super(ServersNegativeTest, cls).setUpClass()
     cls.client = cls.servers_client
     cls.img_client = cls.images_client
     cls.alt_os = clients.AltManager()
     cls.alt_client = cls.alt_os.servers_client