def test_update_raw_data_in_image(glance, image_file, suffix):
    """Checks updating raw data in Glance image

    Scenario:
        1. Create image
        2. Check that image is present in list and image status is `quened`
        3. Update image with `image_file`
        4. Check that image status changes to `active`
        5. Delete image
        6. Check that image deleted
    """
    name = "Test_{0}".format(suffix[:6])
    cmd = ("image-create --name {name} --container-format bare --disk-format "
           "qcow2".format(name=name))
    image = parser.details(glance(cmd))
    image_data = parser.details(glance('image-show {id}'.format(**image)))
    assert image_data['status'] == 'queued'

    check_image_in_list(glance, image)

    glance('image-update --file {file} --progress {id}'.format(
        file=image_file, **image))
    check_image_active(glance, image)

    glance('image-delete {id}'.format(**image))

    check_image_not_in_list(glance, image)
def test_update_properties_of_image(glance, image_file, suffix, key_name):
    """Check updating properties of glance image

    Scenario:
        1. Create image from `image_file`
        2. Check that image is present in list and image status is `active`
        3. Update image with property key=test
        4. Check that image has property 'key' = test
        5. Delete image
        6. Check that image deleted
    """
    name = "Test_{0}".format(suffix[:6])
    cmd = ("image-create --name {name} --container-format bare --disk-format "
           "qcow2 --file {file} --progress".format(name=name, file=image_file))
    image = parser.details(glance(cmd))

    check_image_active(glance, image)

    check_image_in_list(glance, image)

    glance('image-update {id} --property key=test'.format(**image))

    image_data = parser.details(glance('image-show {id}'.format(**image)))
    assert image_data[key_name] == 'test'

    glance('image-delete {id}'.format(**image))

    check_image_not_in_list(glance, image)
Exemplo n.º 3
0
    def test_update_quotas_for_share_groups(self, microversion):
        if not utils.is_microversion_supported(microversion):
            msg = "Microversion '%s' not supported." % microversion
            raise self.skipException(msg)

        # Get default quotas
        cmd = 'quota-defaults'
        quotas_raw = self.admin_client.manila(cmd, microversion=microversion)
        default_quotas = output_parser.details(quotas_raw)

        # Get project quotas
        cmd = 'quota-show --tenant-id %s ' % self.project_id
        quotas_raw = self.admin_client.manila(cmd, microversion=microversion)
        p_quotas = output_parser.details(quotas_raw)

        # Define custom share group quotas for project
        p_custom_quotas = {
            'share_groups':
            -1 if int(p_quotas['share_groups']) != -1 else 999,
            'share_group_snapshots':
            -1 if int(p_quotas['share_group_snapshots']) != -1 else 999,
        }

        # Update share group quotas for project
        cmd = ('quota-update %s --share-groups %s '
               '--share-group-snapshots %s') % (
                   self.project_id,
                   p_custom_quotas['share_groups'],
                   p_custom_quotas['share_group_snapshots'],
               )
        self.admin_client.manila(cmd, microversion=microversion)

        # Verify quotas
        self._verify_current_quotas_equal_to(p_custom_quotas, microversion)

        # Reset quotas
        cmd = 'quota-delete --tenant-id %s --share-type %s' % (self.project_id,
                                                               self.st_id)
        self.admin_client.manila(cmd, microversion=microversion)

        # Verify quotas after reset
        self._verify_current_quotas_equal_to(default_quotas, microversion)

        # Return project quotas back
        cmd = ('quota-update %s --share-groups %s '
               '--share-group-snapshots %s') % (
                   self.project_id, p_quotas['share_groups'],
                   p_quotas['share_group_snapshots'])
        self.admin_client.manila(cmd, microversion=microversion)

        # Verify quotas after reset
        self._verify_current_quotas_equal_to(p_quotas, microversion)
Exemplo n.º 4
0
    def test_update_quotas_for_share_groups(self, microversion):
        if not utils.is_microversion_supported(microversion):
            msg = "Microversion '%s' not supported." % microversion
            raise self.skipException(msg)

        # Get default quotas
        cmd = 'quota-defaults'
        quotas_raw = self.admin_client.manila(cmd, microversion=microversion)
        default_quotas = output_parser.details(quotas_raw)

        # Get project quotas
        cmd = 'quota-show --tenant-id %s ' % self.project_id
        quotas_raw = self.admin_client.manila(cmd, microversion=microversion)
        p_quotas = output_parser.details(quotas_raw)

        # Define custom share group quotas for project
        p_custom_quotas = {
            'share_groups': -1 if int(p_quotas['share_groups']) != -1 else 999,
            'share_group_snapshots': -1 if int(
                p_quotas['share_group_snapshots']) != -1 else 999,
        }

        # Update share group quotas for project
        cmd = ('quota-update %s --share-groups %s '
               '--share-group-snapshots %s') % (
            self.project_id,
            p_custom_quotas['share_groups'],
            p_custom_quotas['share_group_snapshots'],
        )
        self.admin_client.manila(cmd, microversion=microversion)

        # Verify quotas
        self._verify_current_quotas_equal_to(p_custom_quotas, microversion)

        # Reset quotas
        cmd = 'quota-delete --tenant-id %s --share-type %s' % (
            self.project_id, self.st_id)
        self.admin_client.manila(cmd, microversion=microversion)

        # Verify quotas after reset
        self._verify_current_quotas_equal_to(default_quotas, microversion)

        # Return project quotas back
        cmd = ('quota-update %s --share-groups %s '
               '--share-group-snapshots %s') % (
            self.project_id,
            p_quotas['share_groups'], p_quotas['share_group_snapshots'])
        self.admin_client.manila(cmd, microversion=microversion)

        # Verify quotas after reset
        self._verify_current_quotas_equal_to(p_quotas, microversion)
Exemplo n.º 5
0
def test_image_create_delete_from_url(glance, suffix, option):
    """Check image creation and deletion from URL

    Scenario:
        1. Create image from URL
        2. Wait until image has active `status`
        3. Delete image
        4. Check that image deleted
    """
    name = 'Test_{}'.format(suffix)
    image_url = settings.GLANCE_IMAGE_URL
    cmd = ('image-create --name {name} --container-format bare '
           '--disk-format qcow2 {option} {image_url} --progress'.format(
               name=name,
               option=option,
               image_url=image_url))

    image = parser.details(glance(cmd))

    def is_image_active():
        image_data = parser.details(glance('image-show {id}'.format(**image)))
        return image_data['status'] == 'active'

    wait(is_image_active, timeout_seconds=60, waiting_for='image is active')

    glance('image-delete {id}'.format(**image))

    check_image_not_in_list(glance, image)
Exemplo n.º 6
0
def test_image_file_equal(glance, image_file, suffix):
    """Check that after upload-download image file are not changed

    Scenario:
        1. Create image from file
        2. Download image to new file
        3. Compare file and new file
        4. Delete image
    """
    name = 'Test_{}'.format(suffix)
    cmd = ('image-create --name {name} --container-format bare '
           '--disk-format qcow2 --file {source} --progress'.format(
               name=name,
               source=image_file))

    image = parser.details(glance(cmd))

    with tempfile.NamedTemporaryFile() as new_file:
        new_file.write(glance('image-download {id}'.format(**image)))
        new_file.flush()
        original_md5 = calc_md5(image_file)
        new_md5 = calc_md5(new_file.name)

    assert original_md5 == new_md5, 'MD5 sums of images are different'

    glance('image-delete {id}'.format(**image))
Exemplo n.º 7
0
def test_update_properties_of_image(glance_remote, image_file_remote, suffix,
                                    key_name):
    """Check updating properties of glance image

    Scenario:
        1. Create image from `image_file`
        2. Check that image is present in list and image status is `active`
        3. Update image with property key=test
        4. Check that image has property 'key' = test
        5. Delete image
        6. Check that image deleted
    """
    name = "Test_{0}".format(suffix[:6])
    cmd = ("image-create --name {name} --container-format bare --disk-format "
           "qcow2 --file {file} --progress".format(name=name,
                                                   file=image_file_remote))
    image = parser.details(glance_remote(cmd))

    check_image_active(glance_remote, image)

    check_image_in_list(glance_remote, image)

    glance_remote('image-update {id} --property key=test'.format(**image))

    image_data = glance_remote('image-show {id}'.format(**image)).details()
    assert image_data[key_name] == 'test'

    glance_remote('image-delete {id}'.format(**image))

    check_image_not_in_list(glance_remote, image)
Exemplo n.º 8
0
def test_update_raw_data_in_image(glance_remote, image_file_remote, suffix):
    """Checks updating raw data in Glance image

    Scenario:
        1. Create image
        2. Check that image is present in list and image status is `quened`
        3. Update image with `image_file`
        4. Check that image status changes to `active`
        5. Delete image
        6. Check that image deleted
    """
    name = "Test_{0}".format(suffix[:6])
    cmd = ("image-create --name {name} --container-format bare --disk-format "
           "qcow2".format(name=name))
    image = parser.details(glance_remote(cmd))
    image_data = glance_remote('image-show {id}'.format(**image)).details()
    assert image_data['status'] == 'queued'

    check_image_in_list(glance_remote, image)

    glance_remote('image-update --file {file} --progress {id}'.format(
        file=image_file_remote,
        **image))
    check_image_active(glance_remote, image)

    glance_remote('image-delete {id}'.format(**image))

    check_image_not_in_list(glance_remote, image)
Exemplo n.º 9
0
def check_image_active(glance, image):
    __tracebackhide__ = True

    image_data = parser.details(glance('image-show {id}'.format(**image)))
    if image_data['status'] != 'active':
        pytest.fail('Image {id} status is {status} (not active)'.format(
            **image_data))
def test_remove_deleted_image(glance, message):
    """Checks error message on delete already deleted image"""
    image = parser.details(glance('image-create'))
    glance('image-delete {id}'.format(**image))

    out = glance('image-delete {id}'.format(**image), fail_ok=True,
                 merge_stderr=True)
    assert message.format(**image) in out
Exemplo n.º 11
0
 def test_details_with_normal_line_label_true(self):
     expected = {
         '__label': 'First Table',
         'foo': 'BUILD',
         'bar': 'ERROR',
         'bee': 'None'
     }
     actual = output_parser.details(self.DETAILS_LINES1, with_label=True)
     self.assertEqual(expected, actual)
Exemplo n.º 12
0
    def test_update_share_type_quotas_positive(self, microversion):
        if not utils.is_microversion_supported(microversion):
            msg = "Microversion '%s' not supported." % microversion
            raise self.skipException(msg)

        # Get project quotas
        cmd = 'quota-show --tenant-id %s ' % self.project_id
        quotas_raw = self.admin_client.manila(cmd, microversion=microversion)
        p_quotas = output_parser.details(quotas_raw)

        # Define share type quotas
        st_custom_quotas = {
            'shares': _get_share_type_quota_values(p_quotas['shares']),
            'snapshots': _get_share_type_quota_values(p_quotas['snapshots']),
            'gigabytes': _get_share_type_quota_values(p_quotas['gigabytes']),
            'snapshot_gigabytes': _get_share_type_quota_values(
                p_quotas['snapshot_gigabytes']),
        }
        supports_share_replica_quotas = (
            api_versions.APIVersion(microversion) >= api_versions.APIVersion(
                REPLICA_QUOTAS_MICROVERSION))

        if supports_share_replica_quotas:
            st_custom_quotas['share_replicas'] = _get_share_type_quota_values(
                p_quotas['share_replicas']
            )
            st_custom_quotas['replica_gigabytes'] = (
                _get_share_type_quota_values(p_quotas['replica_gigabytes']))
            replica_params = (' --share-replicas %s '
                              '--replica-gigabytes %s') % (
                st_custom_quotas['share_replicas'],
                st_custom_quotas['replica_gigabytes'])

        # Update quotas for share type
        cmd = ('quota-update %s --share-type %s '
               '--shares %s --gigabytes %s --snapshots %s '
               '--snapshot-gigabytes %s') % (
                   self.project_id, self.st_id,
                   st_custom_quotas['shares'],
                   st_custom_quotas['gigabytes'],
                   st_custom_quotas['snapshots'],
                   st_custom_quotas['snapshot_gigabytes'])

        if supports_share_replica_quotas:
            cmd += replica_params
        self.admin_client.manila(cmd, microversion=microversion)

        # Verify share type quotas
        self._verify_current_st_quotas_equal_to(st_custom_quotas, microversion)

        # Reset share type quotas
        cmd = 'quota-delete --tenant-id %s --share-type %s' % (
            self.project_id, self.st_id)
        self.admin_client.manila(cmd, microversion=microversion)

        # Verify share type quotas after reset
        self._verify_current_st_quotas_equal_to(p_quotas, microversion)
Exemplo n.º 13
0
def test_remove_deleted_image(glance_remote):
    """Checks error message on delete already deleted image"""
    image = parser.details(glance_remote('image-create'))
    glance_remote('image-delete {id}'.format(**image))

    out = glance_remote('image-delete {id}'.format(**image),
                        fail_ok=True,
                        merge_stderr=True)
    assert "No image with an ID of '{id}' exists".format(**image) in out
Exemplo n.º 14
0
    def test_shutdown_active_controller_during_upload(self,
                                                      glance,
                                                      image_file,
                                                      suffix,
                                                      timeout=60):
        """Check that image is created successfully if during creating image
        to perform shutdown of active controller

        Steps:
            1. Create image using URL Link
            2. Shutdown active controller during creation of image
            3. Check that image is present in list and image status is `active`
            4. Delete created image
            5. Check that image deleted
        """

        # Find a primary controller
        primary_controller = self.env.primary_controller
        mac = primary_controller.data['mac']
        self.primary_node = DevopsClient.get_node_by_mac(
            env_name=self.env_name, mac=mac)

        name = 'Test_{}'.format(suffix[:6])
        image_url = settings.GLANCE_IMAGE_URL
        cmd = ('image-create --name {name} --container-format bare '
               '--disk-format qcow2 --location {image_url}'.format(
                   name=name, image_url=image_url))
        image = parser.details(glance(cmd))
        logger.info('Image starts to upload')

        # Shutdown primary controller
        self.env.warm_shutdown_nodes([self.primary_node])

        image_list = parser.listing(glance('image-list'))
        assert image['id'] in [x['ID'] for x in image_list]

        image_data = parser.details(glance('image-show {id}'.format(**image)))
        assert image_data['status'] == 'active'
        logger.info('Image is active')

        glance('image-delete {id}'.format(**image))

        images = parser.listing(glance('image-list'))
        assert image['id'] not in [x['ID'] for x in images]
def test_download_zero_size_image(glance, message):
    image = parser.details(glance('image-create'))

    for command in ('image-download {id}', 'image-download {id} --progress'):
        out = glance(command.format(**image), fail_ok=True, merge_stderr=True)
        assert message.format(**image) in out

    glance('image-delete {id}'.format(**image))

    images = parser.listing(glance('image-list'))
    assert image['id'] not in [x['ID'] for x in images]
Exemplo n.º 16
0
    def test_shutdown_primary_controller(self,
                                         glance,
                                         image_file,
                                         suffix,
                                         timeout=60):
        """Check creating image after shutdown primary controller

        Steps:
            1. Shutdown primary controller
            2. Create image from `image_file`
            3. Check that image is present in list and image status is `active`
            4. Delete created image
            5. Check that image deleted
        """
        # Find a primary controller
        primary_controller = self.env.primary_controller
        mac = primary_controller.data['mac']
        primary_node = DevopsClient.get_node_by_mac(env_name=self.env_name,
                                                    mac=mac)

        # Shutdown primary controller
        self.env.warm_shutdown_nodes([primary_node])

        name = 'Test_{}'.format(suffix[:6])
        cmd = ('image-create --name {name} --container-format bare '
               '--disk-format qcow2 --file {file}'.format(name=name,
                                                          file=image_file))
        image = parser.details(glance(cmd))
        logger.info('Image starts to upload')

        image_list = parser.listing(glance('image-list'))
        assert image['id'] in [x['ID'] for x in image_list]

        image_data = parser.details(glance('image-show {id}'.format(**image)))
        assert image_data['status'] == 'active'
        logger.info('Image is active')

        glance('image-delete {id}'.format(**image))

        images = parser.listing(glance('image-list'))
        assert image['id'] not in [x['ID'] for x in images]
Exemplo n.º 17
0
    def test_shutdown_active_controller_during_upload(
            self, glance, image_file, suffix, timeout=60):
        """Check that image is created successfully if during creating image
        to perform shutdown of active controller

        Steps:
            1. Create image using URL Link
            2. Shutdown active controller during creation of image
            3. Check that image is present in list and image status is `active`
            4. Delete created image
            5. Check that image deleted
        """

        # Find a primary controller
        primary_controller = self.env.primary_controller
        mac = primary_controller.data['mac']
        self.primary_node = DevopsClient.get_node_by_mac(
            env_name=self.env_name, mac=mac)

        name = 'Test_{}'.format(suffix[:6])
        image_url = settings.GLANCE_IMAGE_URL
        cmd = ('image-create --name {name} --container-format bare '
               '--disk-format qcow2 --location {image_url}'.format(
                    name=name, image_url=image_url))
        image = parser.details(glance(cmd))
        logger.info('Image starts to upload')

        # Shutdown primary controller
        self.env.warm_shutdown_nodes([self.primary_node])

        image_list = parser.listing(glance('image-list'))
        assert image['id'] in [x['ID'] for x in image_list]

        image_data = parser.details(glance('image-show {id}'.format(**image)))
        assert image_data['status'] == 'active'
        logger.info('Image is active')

        glance('image-delete {id}'.format(**image))

        images = parser.listing(glance('image-list'))
        assert image['id'] not in [x['ID'] for x in images]
Exemplo n.º 18
0
def test_unicode_support(glance_remote, suffix):
    """Check support of unicode symbols in image name

    Scenario:
        1. Create image with name 試験画像
        2. Check that created image is in list and has status `queued`
        3. Delete image
        4. Check that image deleted
    """
    name = u"試験画像_{0}".format(suffix[:6])
    cmd = (u"image-create --name {name}".format(name=name))
    image = parser.details(glance_remote(cmd))

    check_image_in_list(glance_remote, image)

    image_data = parser.details(
        glance_remote('image-show {id}'.format(**image)))
    assert image_data['status'] == 'queued'

    glance_remote('image-delete {id}'.format(**image))
    check_image_not_in_list(glance_remote, image)
Exemplo n.º 19
0
def test_download_zero_size_image(glance_remote, message):
    image = parser.details(glance_remote('image-create'))

    for command in ('image-download {id}', 'image-download {id} --progress'):
        out = glance_remote(command.format(**image),
                            fail_ok=True,
                            merge_stderr=True)
        assert message.format(**image) in out

    glance_remote('image-delete {id}'.format(**image))

    images = parser.listing(glance_remote('image-list'))
    assert image['id'] not in [x['ID'] for x in images]
Exemplo n.º 20
0
    def test_shutdown_primary_controller(
            self, glance, image_file, suffix, timeout=60):
        """Check creating image after shutdown primary controller

        Steps:
            1. Shutdown primary controller
            2. Create image from `image_file`
            3. Check that image is present in list and image status is `active`
            4. Delete created image
            5. Check that image deleted
        """
        # Find a primary controller
        primary_controller = self.env.primary_controller
        mac = primary_controller.data['mac']
        primary_node = DevopsClient.get_node_by_mac(
            env_name=self.env_name, mac=mac)

        # Shutdown primary controller
        self.env.warm_shutdown_nodes([primary_node])

        name = 'Test_{}'.format(suffix[:6])
        cmd = ('image-create --name {name} --container-format bare '
               '--disk-format qcow2 --file {file}'.format(
                    name=name, file=image_file))
        image = parser.details(glance(cmd))
        logger.info('Image starts to upload')

        image_list = parser.listing(glance('image-list'))
        assert image['id'] in [x['ID'] for x in image_list]

        image_data = parser.details(glance('image-show {id}'.format(**image)))
        assert image_data['status'] == 'active'
        logger.info('Image is active')

        glance('image-delete {id}'.format(**image))

        images = parser.listing(glance('image-list'))
        assert image['id'] not in [x['ID'] for x in images]
Exemplo n.º 21
0
    def _verify_current_quotas_equal_to(self, quotas, microversion):
        # Read quotas
        cmd = 'quota-show --tenant-id %s' % self.project_id
        quotas_raw = self.admin_client.manila(cmd, microversion=microversion)
        quotas = output_parser.details(quotas_raw)

        # Verify that quotas
        self.assertGreater(len(quotas), 3)
        for key, value in quotas.items():
            if key not in ('shares', 'gigabytes', 'snapshots',
                           'snapshot_gigabytes', 'share_groups',
                           'share_group_snapshots'):
                continue
            self.assertIn(key, quotas)
            self.assertEqual(int(quotas[key]), int(value))
Exemplo n.º 22
0
    def _verify_current_quotas_equal_to(self, quotas, microversion):
        # Read quotas
        cmd = 'quota-show --tenant-id %s' % self.project_id
        quotas_raw = self.admin_client.manila(
            cmd, microversion=microversion)
        quotas = output_parser.details(quotas_raw)

        # Verify that quotas
        self.assertGreater(len(quotas), 3)
        for key, value in quotas.items():
            if key not in ('shares', 'gigabytes', 'snapshots',
                           'snapshot_gigabytes',
                           'share_groups', 'share_group_snapshots'):
                continue
            self.assertIn(key, quotas)
            self.assertEqual(int(quotas[key]), int(value))
Exemplo n.º 23
0
    def test_update_share_type_quotas_positive(self, microversion):
        if not utils.is_microversion_supported(microversion):
            msg = "Microversion '%s' not supported." % microversion
            raise self.skipException(msg)

        # Get project quotas
        cmd = 'quota-show --tenant-id %s ' % self.project_id
        quotas_raw = self.admin_client.manila(cmd, microversion=microversion)
        p_quotas = output_parser.details(quotas_raw)

        # Define share type quotas
        st_custom_quotas = {
            'shares':
            _get_share_type_quota_values(p_quotas['shares']),
            'snapshots':
            _get_share_type_quota_values(p_quotas['snapshots']),
            'gigabytes':
            _get_share_type_quota_values(p_quotas['gigabytes']),
            'snapshot_gigabytes':
            _get_share_type_quota_values(p_quotas['snapshot_gigabytes']),
        }

        # Update quotas for share type
        cmd = ('quota-update %s --share-type %s '
               '--shares %s --gigabytes %s --snapshots %s '
               '--snapshot-gigabytes %s') % (
                   self.project_id, self.st_id, st_custom_quotas['shares'],
                   st_custom_quotas['gigabytes'],
                   st_custom_quotas['snapshots'],
                   st_custom_quotas['snapshot_gigabytes'])
        self.admin_client.manila(cmd, microversion=microversion)

        # Verify share type quotas
        self._verify_current_st_quotas_equal_to(st_custom_quotas, microversion)

        # Reset share type quotas
        cmd = 'quota-delete --tenant-id %s --share-type %s' % (self.project_id,
                                                               self.st_id)
        self.admin_client.manila(cmd, microversion=microversion)

        # Verify share type quotas after reset
        self._verify_current_st_quotas_equal_to(p_quotas, microversion)
Exemplo n.º 24
0
def test_unicode_support(glance_remote, suffix):
    """Check support of unicode symbols in image name

    Scenario:
        1. Create image with name 試験画像
        2. Check that created image is in list and has status `queued`
        3. Delete image
        4. Check that image deleted
    """
    name = u"試験画像_{0}".format(suffix[:6])
    cmd = (u"image-create --name {name}".format(name=name))
    image = parser.details(glance_remote(cmd))

    check_image_in_list(glance_remote, image)

    image_data = glance_remote('image-show {id}'.format(**image)).details()
    assert image_data['status'] == 'queued'

    glance_remote('image-delete {id}'.format(**image))
    check_image_not_in_list(glance_remote, image)
Exemplo n.º 25
0
def test_upload_image_with_token_expiration(glance, image_file, suffix):
    """Check that big image uploaded succcess if token expired during uploading

    Scenario:
        1. Create image from big file
        2. Check that created image is in list and has status `active`
        3. Delete image
        4. Check that image deleted
    """
    name = u"Test_{0}".format(suffix[:6])
    cmd = ('image-create --name {name} --container-format bare '
           '--disk-format qcow2 --file {source} --progress'.format(
                name=name, source=image_file))

    image = parser.details(glance(cmd))

    check_image_active(glance, image)

    glance('image-delete {id}'.format(**image))

    check_image_not_in_list(glance, image)
Exemplo n.º 26
0
def test_image_create_delete_from_file(glance, image_file, suffix):
    """Checks image creation and deletion from file

    Scenario:
        1. Create image from file
        2. Check that image exists and has `active` status
        3. Delete image
        4. Check that image deleted
    """
    name = 'Test_{}'.format(suffix)
    cmd = ('image-create --name {name} --container-format bare '
           '--disk-format qcow2 --file {source} --progress'.format(
                name=name, source=image_file))

    image = parser.details(glance(cmd))

    check_image_active(glance, image)

    glance('image-delete {id}'.format(**image))

    check_image_not_in_list(glance, image)
Exemplo n.º 27
0
    def test_update_share_type_quotas_positive(self, microversion):
        if not utils.is_microversion_supported(microversion):
            msg = "Microversion '%s' not supported." % microversion
            raise self.skipException(msg)

        # Get project quotas
        cmd = 'quota-show --tenant-id %s ' % self.project_id
        quotas_raw = self.admin_client.manila(cmd, microversion=microversion)
        p_quotas = output_parser.details(quotas_raw)

        # Define share type quotas
        st_custom_quotas = {
            'shares': _get_share_type_quota_values(p_quotas['shares']),
            'snapshots': _get_share_type_quota_values(p_quotas['snapshots']),
            'gigabytes': _get_share_type_quota_values(p_quotas['gigabytes']),
            'snapshot_gigabytes': _get_share_type_quota_values(
                p_quotas['snapshot_gigabytes']),
        }

        # Update quotas for share type
        cmd = ('quota-update %s --share-type %s '
               '--shares %s --gigabytes %s --snapshots %s '
               '--snapshot-gigabytes %s') % (
                   self.project_id, self.st_id,
                   st_custom_quotas['shares'],
                   st_custom_quotas['gigabytes'],
                   st_custom_quotas['snapshots'],
                   st_custom_quotas['snapshot_gigabytes'])
        self.admin_client.manila(cmd, microversion=microversion)

        # Verify share type quotas
        self._verify_current_st_quotas_equal_to(st_custom_quotas, microversion)

        # Reset share type quotas
        cmd = 'quota-delete --tenant-id %s --share-type %s' % (
            self.project_id, self.st_id)
        self.admin_client.manila(cmd, microversion=microversion)

        # Verify share type quotas after reset
        self._verify_current_st_quotas_equal_to(p_quotas, microversion)
Exemplo n.º 28
0
def test_share_glance_image(glance, user, project, image_file, suffix):
    """Check sharing glance image to another project

    Scenario:
        1. Create image from `image_file`
        2. Check that image is present in list and image status is `active`
        3. Bind another project to image
        4. Check that binded project id is present in image member list
        5. Unbind project from image
        6. Check that project id is not present in image member list
        7. Delete image
        8. Check that image deleted
    """
    name = "Test_{0}".format(suffix[:6])
    cmd = ("image-create --name {name} --container-format bare --disk-format "
           "qcow2 --file {file} --progress".format(name=name,
                                                   file=image_file))
    image = parser.details(glance(cmd))

    check_image_active(glance, image)

    check_image_in_list(glance, image)

    glance('member-create {id} {project_id}'.format(project_id=project['id'],
                                                    **image))

    member_list = parser.listing(glance('member-list --image-id {id}'.format(
        **image)))
    assert project['id'] in [x['Member ID'] for x in member_list]

    glance('member-delete {id} {project_id}'.format(project_id=project['id'],
                                                    **image))

    member_list = parser.listing(glance('member-list --image-id {id}'.format(
        **image)))
    assert project['id'] not in [x['Member ID'] for x in member_list]

    glance('image-delete {id}'.format(**image))

    check_image_not_in_list(glance, image)
Exemplo n.º 29
0
def test_image_create_delete_from_file(glance, image_file, suffix):
    """Checks image creation and deletion from file

    Scenario:
        1. Create image from file
        2. Check that image exists and has `active` status
        3. Delete image
        4. Check that image deleted
    """
    name = 'Test_{}'.format(suffix)
    cmd = ('image-create --name {name} --container-format bare '
           '--disk-format qcow2 --file {source} --progress'.format(
               name=name,
               source=image_file))

    image = parser.details(glance(cmd))

    check_image_active(glance, image)

    glance('image-delete {id}'.format(**image))

    check_image_not_in_list(glance, image)
def test_big_image_create_delete_from_file(glance_remote, image_file_remote,
                                           suffix):
    """Checks big image creation and deletion from file.

    Scenario:
        1. Create big 25GB image from file;
        2. Check that image exists and has `active` status;
        3. Delete image;
        4. Check that image deleted.
    Duration: ~ 25 minutes
    """
    name = 'Test_big_{}'.format(suffix)
    timeout_for_cli_cmd = int(1 * 60 * 60)  # 1 hour
    cmd = ('--timeout {sec} image-create --name {name} '
           '--container-format bare '
           '--disk-format qcow2 --file {source} --progress'.format(
               sec=timeout_for_cli_cmd, name=name, source=image_file_remote))

    image = parser.details(glance_remote(cmd))
    check_image_active(glance_remote, image)
    glance_remote('image-delete {id}'.format(**image))
    check_image_not_in_list(glance_remote, image)
Exemplo n.º 31
0
def test_upload_image_with_token_expiration(glance, image_file, suffix):
    """Check that big image uploaded succcess if token expired during uploading

    Scenario:
        1. Create image from big file
        2. Check that created image is in list and has status `active`
        3. Delete image
        4. Check that image deleted
    """
    name = u"Test_{0}".format(suffix[:6])
    cmd = ('image-create --name {name} --container-format bare '
           '--disk-format qcow2 --file {source} --progress'.format(
               name=name,
               source=image_file))

    image = parser.details(glance(cmd))

    check_image_active(glance, image)

    glance('image-delete {id}'.format(**image))

    check_image_not_in_list(glance, image)
Exemplo n.º 32
0
 def details(self):
     return parser.details(self)
Exemplo n.º 33
0
 def test_details_with_normal_line_label_false(self):
     expected = {'foo': 'BUILD', 'bar': 'ERROR', 'bee': 'None'}
     actual = output_parser.details(self.DETAILS_LINES1)
     self.assertEqual(expected, actual)
Exemplo n.º 34
0
 def test_details_with_normal_line_label_true(self):
     expected = {'__label': 'First Table',
                 'foo': 'BUILD', 'bar': 'ERROR', 'bee': 'None'}
     actual = output_parser.details(self.DETAILS_LINES1, with_label=True)
     self.assertEqual(expected, actual)
Exemplo n.º 35
0
 def test_details_with_normal_line_label_true(self):
     expected = {"__label": "First Table", "foo": "BUILD", "bar": "ERROR", "bee": "None"}
     actual = output_parser.details(self.DETAILS_LINES1, with_label=True)
     self.assertEqual(expected, actual)
Exemplo n.º 36
0
 def test_details_with_normal_line_label_false(self):
     expected = {"foo": "BUILD", "bar": "ERROR", "bee": "None"}
     actual = output_parser.details(self.DETAILS_LINES1)
     self.assertEqual(expected, actual)
Exemplo n.º 37
0
 def details(self):
     return parser.details(self)
Exemplo n.º 38
0
 def is_image_active():
     image_data = parser.details(glance('image-show {id}'.format(**image)))
     return image_data['status'] == 'active'
Exemplo n.º 39
0
 def test_quuz_success(self, options_str, expected_result):
     output = self.shell('quuz %s' % options_str)
     parsed_output = output_parser.details(output)
     self.assertEqual({'key': expected_result}, parsed_output)
Exemplo n.º 40
0
 def test_details_with_normal_line_label_false(self):
     expected = {'foo': 'BUILD', 'bar': 'ERROR', 'bee': 'None'}
     actual = output_parser.details(self.DETAILS_LINES1)
     self.assertEqual(expected, actual)