• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python waiters.wait_for_image_status函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tempest.common.waiters.wait_for_image_status函数的典型用法代码示例。如果您正苦于以下问题:Python wait_for_image_status函数的具体用法?Python wait_for_image_status怎么用?Python wait_for_image_status使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wait_for_image_status函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_create_delete_image

    def test_create_delete_image(self):

        # Create a new image
        name = data_utils.rand_name("image")
        meta = {"image_type": "test"}
        body = self.client.create_image(self.server_id, name, meta)
        image_id = data_utils.parse_image_id(body.response["location"])
        waiters.wait_for_image_status(self.client, image_id, "ACTIVE")

        # Verify the image was created correctly
        image = self.client.show_image(image_id)
        self.assertEqual(name, image["name"])
        self.assertEqual("test", image["metadata"]["image_type"])

        original_image = self.client.show_image(self.image_ref)

        # Verify minRAM is the same as the original image
        self.assertEqual(image["minRam"], original_image["minRam"])

        # Verify minDisk is the same as the original image or the flavor size
        flavor_disk_size = self._get_default_flavor_disk_size(self.flavor_ref)
        self.assertIn(str(image["minDisk"]), (str(original_image["minDisk"]), str(flavor_disk_size)))

        # Verify the image was deleted correctly
        self.client.delete_image(image_id)
        self.client.wait_for_resource_deletion(image_id)
开发者ID:SivagnanamCiena,项目名称:tempest,代码行数:26,代码来源:test_images_oneserver.py


示例2: test_create_delete_image

    def test_create_delete_image(self):

        # Create a new image
        name = data_utils.rand_name('image')
        meta = {'image_type': 'test'}
        body = self.client.create_image(self.server_id, name=name,
                                        metadata=meta)
        image_id = data_utils.parse_image_id(body.response['location'])
        waiters.wait_for_image_status(self.client, image_id, 'ACTIVE')

        # Verify the image was created correctly
        image = self.client.show_image(image_id)['image']
        self.assertEqual(name, image['name'])
        self.assertEqual('test', image['metadata']['image_type'])

        original_image = self.client.show_image(self.image_ref)['image']

        # Verify minRAM is the same as the original image
        self.assertEqual(image['minRam'], original_image['minRam'])

        # Verify minDisk is the same as the original image or the flavor size
        flavor_disk_size = self._get_default_flavor_disk_size(self.flavor_ref)
        self.assertIn(str(image['minDisk']),
                      (str(original_image['minDisk']), str(flavor_disk_size)))

        # Verify the image was deleted correctly
        self.client.delete_image(image_id)
        self.client.wait_for_resource_deletion(image_id)
开发者ID:flyingfish007,项目名称:tempest,代码行数:28,代码来源:test_images_oneserver.py


示例3: _create_image

        def _create_image():
            params = {
                'name': data_utils.rand_name('image'),
                'container_format': 'bare',
                'disk_format': 'raw'
            }
            if CONF.image_feature_enabled.api_v1:
                params.update({'is_public': False})
                params = {'headers':
                          common_image.image_meta_to_headers(**params)}
            else:
                params.update({'visibility': 'private'})

            body = cls.glance_client.create_image(**params)
            body = body['image'] if 'image' in body else body
            image_id = body['id']
            cls.images.append(image_id)
            # Wait 1 second between creation and upload to ensure a delta
            # between created_at and updated_at.
            time.sleep(1)
            image_file = six.StringIO(('*' * 1024))
            if CONF.image_feature_enabled.api_v1:
                cls.glance_client.update_image(image_id, data=image_file)
            else:
                cls.glance_client.store_image_file(image_id, data=image_file)
            waiters.wait_for_image_status(cls.client, image_id, 'ACTIVE')
            body = cls.client.show_image(image_id)['image']
            return body
开发者ID:WoolenWang,项目名称:tempest,代码行数:28,代码来源:test_list_image_filters.py


示例4: test_wait_for_image_status

 def test_wait_for_image_status(self):
     self.client.show_image.return_value = ({'status': 'active'})
     start_time = int(time.time())
     waiters.wait_for_image_status(self.client, 'fake_image_id', 'active')
     end_time = int(time.time())
     # Ensure waiter returns before build_timeout
     self.assertLess((end_time - start_time), 10)
开发者ID:Juniper,项目名称:tempest,代码行数:7,代码来源:test_waiters.py


示例5: _create_image

        def _create_image():
            params = {
                "name": data_utils.rand_name(cls.__name__ + "-image"),
                "container_format": "bare",
                "disk_format": "raw",
            }
            if CONF.image_feature_enabled.api_v1:
                params.update({"is_public": False})
                params = {"headers": common_image.image_meta_to_headers(**params)}
            else:
                params.update({"visibility": "private"})

            body = cls.glance_client.create_image(**params)
            body = body["image"] if "image" in body else body
            image_id = body["id"]
            cls.images.append(image_id)
            # Wait 1 second between creation and upload to ensure a delta
            # between created_at and updated_at.
            time.sleep(1)
            image_file = six.BytesIO((b"*" * 1024))
            if CONF.image_feature_enabled.api_v1:
                cls.glance_client.update_image(image_id, data=image_file)
            else:
                cls.glance_client.store_image_file(image_id, data=image_file)
            waiters.wait_for_image_status(cls.client, image_id, "ACTIVE")
            body = cls.client.show_image(image_id)["image"]
            return body
开发者ID:sebrandon1,项目名称:tempest,代码行数:27,代码来源:test_list_image_filters.py


示例6: _create_image

        def _create_image():
            params = {
                'name': data_utils.rand_name(cls.__name__ + '-image'),
                'container_format': 'bare',
                'disk_format': 'raw'
            }
            if CONF.image_feature_enabled.api_v1:
                params.update({'is_public': False})
                params = {'headers':
                          common_image.image_meta_to_headers(**params)}
            else:
                params.update({'visibility': 'private'})

            body = cls.glance_client.create_image(**params)
            body = body['image'] if 'image' in body else body
            image_id = body['id']
            cls.addClassResourceCleanup(
                test_utils.call_and_ignore_notfound_exc,
                cls.compute_images_client.delete_image,
                image_id)
            # Wait 1 second between creation and upload to ensure a delta
            # between created_at and updated_at.
            time.sleep(1)
            image_file = six.BytesIO((b'*' * 1024))
            if CONF.image_feature_enabled.api_v1:
                cls.glance_client.update_image(image_id, data=image_file)
            else:
                cls.glance_client.store_image_file(image_id, data=image_file)
            waiters.wait_for_image_status(cls.client, image_id, 'ACTIVE')
            body = cls.client.show_image(image_id)['image']
            return body
开发者ID:openstack,项目名称:tempest,代码行数:31,代码来源:test_list_image_filters.py


示例7: test_register_http_image

 def test_register_http_image(self):
     container_format, disk_format = get_container_and_disk_format()
     image = self.create_image(name='New Http Image',
                               container_format=container_format,
                               disk_format=disk_format, is_public=False,
                               copy_from=CONF.image.http_image)
     self.assertEqual('New Http Image', image.get('name'))
     self.assertFalse(image.get('is_public'))
     waiters.wait_for_image_status(self.client, image['id'], 'active')
     self.client.show_image(image['id'])
开发者ID:Juniper,项目名称:tempest,代码行数:10,代码来源:test_images.py


示例8: test_volume_upload

 def test_volume_upload(self):
     # NOTE(gfidente): the volume uploaded in Glance comes from setUpClass,
     # it is shared with the other tests. After it is uploaded in Glance,
     # there is no way to delete it from Cinder, so we delete it from Glance
     # using the Glance image_client and from Cinder via tearDownClass.
     image_name = data_utils.rand_name(self.__class__.__name__ + "-Image")
     body = self.client.upload_volume(self.volume["id"], image_name=image_name, disk_format=CONF.volume.disk_format)[
         "os-volume_upload_image"
     ]
     image_id = body["image_id"]
     self.addCleanup(test_utils.call_and_ignore_notfound_exc, self.image_client.delete_image, image_id)
     waiters.wait_for_image_status(self.image_client, image_id, "active")
     waiters.wait_for_volume_status(self.client, self.volume["id"], "available")
开发者ID:sebrandon1,项目名称:tempest,代码行数:13,代码来源:test_volumes_actions.py


示例9: test_volume_upload

 def test_volume_upload(self):
     # NOTE(gfidente): the volume uploaded in Glance comes from setUpClass,
     # it is shared with the other tests. After it is uploaded in Glance,
     # there is no way to delete it from Cinder, so we delete it from Glance
     # using the Glance image_client and from Cinder via tearDownClass.
     image_name = data_utils.rand_name('Image')
     body = self.client.upload_volume(
         self.volume['id'], image_name=image_name,
         disk_format=CONF.volume.disk_format)['os-volume_upload_image']
     image_id = body["image_id"]
     self.addCleanup(self._cleanup_image, image_id)
     waiters.wait_for_image_status(self.image_client, image_id, 'active')
     waiters.wait_for_volume_status(self.client,
                                    self.volume['id'], 'available')
开发者ID:NeCTAR-RC,项目名称:tempest,代码行数:14,代码来源:test_volumes_actions.py


示例10: resource_setup

    def resource_setup(cls):
        super(ImagesMetadataTestJSON, cls).resource_setup()
        cls.image_id = None

        name = data_utils.rand_name('image')
        body = cls.glance_client.create_image(name=name,
                                              container_format='bare',
                                              disk_format='raw',
                                              is_public=False)['image']
        cls.image_id = body['id']
        cls.images.append(cls.image_id)
        image_file = six.StringIO(('*' * 1024))
        cls.glance_client.update_image(cls.image_id, data=image_file)
        waiters.wait_for_image_status(cls.client, cls.image_id, 'ACTIVE')
开发者ID:rishabhdas,项目名称:tempest,代码行数:14,代码来源:test_image_metadata.py


示例11: _create_image

 def _create_image():
     name = data_utils.rand_name('image')
     body = cls.glance_client.create_image(name=name,
                                           container_format='bare',
                                           disk_format='raw',
                                           is_public=False)['image']
     image_id = body['id']
     cls.images.append(image_id)
     # Wait 1 second between creation and upload to ensure a delta
     # between created_at and updated_at.
     time.sleep(1)
     image_file = six.StringIO(('*' * 1024))
     cls.glance_client.update_image(image_id, data=image_file)
     waiters.wait_for_image_status(cls.client, image_id, 'ACTIVE')
     body = cls.client.show_image(image_id)['image']
     return body
开发者ID:Hybrid-Cloud,项目名称:hybrid-tempest,代码行数:16,代码来源:test_list_image_filters.py


示例12: create_server_snapshot

    def create_server_snapshot(self, server, name=None):
        # Glance client
        _image_client = self.image_client
        # Compute client
        _images_client = self.compute_images_client
        if name is None:
            name = data_utils.rand_name(self.__class__.__name__ + 'snapshot')
        LOG.debug("Creating a snapshot image for server: {}"
                  .format(server['name']))
        image = _images_client.create_image(server['id'], name=name)
        image_id = image.response['location'].split('images/')[1]
        waiters.wait_for_image_status(_image_client, image_id, 'active')

        self.addCleanup(_image_client.wait_for_resource_deletion,
                        image_id)
        self.addCleanup(test_utils.call_and_ignore_notfound_exc,
                        _image_client.delete_image, image_id)

        if CONF.image_feature_enabled.api_v1:
            # In glance v1 the additional properties are stored in the headers.
            resp = _image_client.check_image(image_id)
            snapshot_image = common_image.get_image_meta_from_headers(resp)
            image_props = snapshot_image.get('properties', {})
        else:
            # In glance v2 the additional properties are flattened.
            snapshot_image = _image_client.show_image(image_id)
            image_props = snapshot_image

        bdm = image_props.get('block_device_mapping')
        if bdm:
            bdm = json.loads(bdm)
            if bdm and 'snapshot_id' in bdm[0]:
                snapshot_id = bdm[0]['snapshot_id']
                self.addCleanup(
                    self.snapshots_client.wait_for_resource_deletion,
                    snapshot_id)
                self.addCleanup(test_utils.call_and_ignore_notfound_exc,
                                self.snapshots_client.delete_snapshot,
                                snapshot_id)
                waiters.wait_for_volume_resource_status(self.snapshots_client,
                                                        snapshot_id,
                                                        'available')
        image_name = snapshot_image['name']
        self.assertEqual(name, image_name)
        LOG.debug("Created snapshot image {} for server {}"
                  .format(image_name, server['name']))
        return snapshot_image
开发者ID:openstack,项目名称:nova-lxd,代码行数:47,代码来源:manager.py


示例13: create_image

    def create_image(self):
        # Create image
        image_name = data_utils.rand_name(self.__class__.__name__ + "-image")
        image = self.images_client.create_image(
            name=image_name,
            container_format=CONF.image.container_formats[0],
            disk_format=CONF.image.disk_formats[0],
            visibility='private',
            min_disk=CONF.volume.volume_size + 1)
        self.addCleanup(test_utils.call_and_ignore_notfound_exc,
                        self.images_client.delete_image, image['id'])

        # Upload image with 1KB data
        image_file = six.BytesIO(data_utils.random_bytes())
        self.images_client.store_image_file(image['id'], image_file)
        waiters.wait_for_image_status(self.images_client,
                                      image['id'], 'active')
        return image
开发者ID:vedujoshi,项目名称:tempest,代码行数:18,代码来源:test_volumes_negative.py


示例14: create_image_from_server

    def create_image_from_server(cls, server_id, **kwargs):
        """Wrapper utility that returns an image created from the server."""
        name = data_utils.rand_name(cls.__name__ + "-image")
        if "name" in kwargs:
            name = kwargs.pop("name")

        image = cls.images_client.create_image(server_id, name=name)
        image_id = data_utils.parse_image_id(image.response["location"])
        cls.images.append(image_id)

        if "wait_until" in kwargs:
            waiters.wait_for_image_status(cls.images_client, image_id, kwargs["wait_until"])
            image = cls.images_client.show_image(image_id)

            if kwargs["wait_until"] == "ACTIVE":
                if kwargs.get("wait_for_server", True):
                    waiters.wait_for_server_status(cls.servers_client, server_id, "ACTIVE")
        return image
开发者ID:shoham-stratoscale,项目名称:tempest,代码行数:18,代码来源:base.py


示例15: create_image_from_server

    def create_image_from_server(cls, server_id, **kwargs):
        """Wrapper utility that returns an image created from the server."""
        name = data_utils.rand_name(cls.__name__ + "-image")
        if 'name' in kwargs:
            name = kwargs.pop('name')

        image = cls.images_client.create_image(server_id, name)
        image_id = data_utils.parse_image_id(image.response['location'])
        cls.images.append(image_id)

        if 'wait_until' in kwargs:
            waiters.wait_for_image_status(cls.images_client,
                                          image_id, kwargs['wait_until'])
            image = cls.images_client.show_image(image_id)

            if kwargs['wait_until'] == 'ACTIVE':
                if kwargs.get('wait_for_server', True):
                    waiters.wait_for_server_status(cls.servers_client,
                                                   server_id, 'ACTIVE')
        return image
开发者ID:Juraci,项目名称:tempest,代码行数:20,代码来源:base.py


示例16: test_volume_upload

    def test_volume_upload(self):
        # NOTE(gfidente): the volume uploaded in Glance comes from setUpClass,
        # it is shared with the other tests. After it is uploaded in Glance,
        # there is no way to delete it from Cinder, so we delete it from Glance
        # using the Glance images_client and from Cinder via tearDownClass.
        image_name = data_utils.rand_name(self.__class__.__name__ + '-Image')
        body = self.volumes_client.upload_volume(
            self.volume['id'], image_name=image_name,
            disk_format=CONF.volume.disk_format)['os-volume_upload_image']
        image_id = body["image_id"]
        self.addCleanup(test_utils.call_and_ignore_notfound_exc,
                        self.images_client.delete_image,
                        image_id)
        waiters.wait_for_image_status(self.images_client, image_id, 'active')
        waiters.wait_for_volume_resource_status(self.volumes_client,
                                                self.volume['id'], 'available')

        image_info = self.images_client.show_image(image_id)
        self.assertEqual(image_name, image_info['name'])
        self.assertEqual(CONF.volume.disk_format, image_info['disk_format'])
开发者ID:Juniper,项目名称:tempest,代码行数:20,代码来源:test_volumes_actions.py


示例17: create_image_from_server

    def create_image_from_server(cls, server_id, **kwargs):
        """Wrapper utility that returns an image created from the server."""
        name = kwargs.pop('name',
                          data_utils.rand_name(cls.__name__ + "-image"))
        wait_until = kwargs.pop('wait_until', None)
        wait_for_server = kwargs.pop('wait_for_server', True)

        image = cls.compute_images_client.create_image(server_id, name=name,
                                                       **kwargs)
        image_id = data_utils.parse_image_id(image.response['location'])
        cls.images.append(image_id)

        if wait_until is not None:
            try:
                waiters.wait_for_image_status(cls.compute_images_client,
                                              image_id, wait_until)
            except lib_exc.NotFound:
                if wait_until.upper() == 'ACTIVE':
                    # If the image is not found after create_image returned
                    # that means the snapshot failed in nova-compute and nova
                    # deleted the image. There should be a compute fault
                    # recorded with the server in that case, so get the server
                    # and dump some details.
                    server = (
                        cls.servers_client.show_server(server_id)['server'])
                    if 'fault' in server:
                        raise exceptions.SnapshotNotFoundException(
                            server['fault'], image_id=image_id)
                    else:
                        raise exceptions.SnapshotNotFoundException(
                            image_id=image_id)
                else:
                    raise
            image = cls.compute_images_client.show_image(image_id)['image']

            if wait_until.upper() == 'ACTIVE':
                if wait_for_server:
                    waiters.wait_for_server_status(cls.servers_client,
                                                   server_id, 'ACTIVE')
        return image
开发者ID:vedujoshi,项目名称:tempest,代码行数:40,代码来源:base.py


示例18: resource_setup

    def resource_setup(cls):
        super(ImagesMetadataTestJSON, cls).resource_setup()
        cls.image_id = None

        name = data_utils.rand_name('image')
        if CONF.image_feature_enabled.api_v1:
            kwargs = dict(is_public=False)
        else:
            kwargs = dict(visibility='private')
        body = cls.glance_client.create_image(name=name,
                                              container_format='bare',
                                              disk_format='raw',
                                              **kwargs)
        body = body['image'] if 'image' in body else body
        cls.image_id = body['id']
        cls.images.append(cls.image_id)
        image_file = six.StringIO(('*' * 1024))
        if CONF.image_feature_enabled.api_v1:
            cls.glance_client.update_image(cls.image_id, data=image_file)
        else:
            cls.glance_client.store_image_file(cls.image_id, data=image_file)
        waiters.wait_for_image_status(cls.client, cls.image_id, 'ACTIVE')
开发者ID:devfaz,项目名称:tempest,代码行数:22,代码来源:test_image_metadata.py


示例19: wait_for_image_status

 def wait_for_image_status(self, image_id, status):
     """Waits for an image to reach a given status."""
     waiters.wait_for_image_status(self, image_id, status)
开发者ID:Dynavisor,项目名称:tempest,代码行数:3,代码来源:images_client.py


示例20: create_image_from_server

    def create_image_from_server(cls, server_id, **kwargs):
        """Wrapper utility that returns an image created from the server.

        If compute microversion >= 2.36, the returned image response will
        be from the image service API rather than the compute image proxy API.
        """
        name = kwargs.pop('name',
                          data_utils.rand_name(cls.__name__ + "-image"))
        wait_until = kwargs.pop('wait_until', None)
        wait_for_server = kwargs.pop('wait_for_server', True)

        image = cls.compute_images_client.create_image(server_id, name=name,
                                                       **kwargs)
        if api_version_utils.compare_version_header_to_response(
            "OpenStack-API-Version", "compute 2.45", image.response, "lt"):
            image_id = image['image_id']
        else:
            image_id = data_utils.parse_image_id(image.response['location'])

        # The compute image proxy APIs were deprecated in 2.35 so
        # use the images client directly if the API microversion being
        # used is >=2.36.
        if not cls.is_requested_microversion_compatible('2.35'):
            client = cls.images_client
        else:
            client = cls.compute_images_client
        cls.addClassResourceCleanup(test_utils.call_and_ignore_notfound_exc,
                                    client.delete_image, image_id)

        if wait_until is not None:
            try:
                wait_until = wait_until.upper()
                if not cls.is_requested_microversion_compatible('2.35'):
                    wait_until = wait_until.lower()
                waiters.wait_for_image_status(client, image_id, wait_until)
            except lib_exc.NotFound:
                if wait_until.upper() == 'ACTIVE':
                    # If the image is not found after create_image returned
                    # that means the snapshot failed in nova-compute and nova
                    # deleted the image. There should be a compute fault
                    # recorded with the server in that case, so get the server
                    # and dump some details.
                    server = (
                        cls.servers_client.show_server(server_id)['server'])
                    if 'fault' in server:
                        raise exceptions.SnapshotNotFoundException(
                            server['fault'], image_id=image_id)
                    else:
                        raise exceptions.SnapshotNotFoundException(
                            image_id=image_id)
                else:
                    raise
            image = client.show_image(image_id)
            # Compute image client returns response wrapped in 'image' element
            # which is not the case with Glance image client.
            if 'image' in image:
                image = image['image']

            if wait_until.upper() == 'ACTIVE':
                if wait_for_server:
                    waiters.wait_for_server_status(cls.servers_client,
                                                   server_id, 'ACTIVE')
        return image
开发者ID:openstack,项目名称:tempest,代码行数:63,代码来源:base.py



注:本文中的tempest.common.waiters.wait_for_image_status函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python waiters.wait_for_server_status函数代码示例发布时间:2022-05-27
下一篇:
Python misc.find_test_caller函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap