本文整理汇总了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函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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)
示例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
示例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)
示例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
示例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
示例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'])
示例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")
示例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')
示例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')
示例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
示例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
示例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
示例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
示例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