本文整理汇总了Python中tempest.common.utils.data_utils.random_bytes函数的典型用法代码示例。如果您正苦于以下问题:Python random_bytes函数的具体用法?Python random_bytes怎么用?Python random_bytes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了random_bytes函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_update_image
def test_update_image(self):
# Updates an image by image_id
# Create image
image_name = data_utils.rand_name('image')
container_format = CONF.image.container_formats[0]
disk_format = CONF.image.disk_formats[0]
body = self.client.create_image(name=image_name,
container_format=container_format,
disk_format=disk_format,
visibility='private')
self.addCleanup(self.client.delete_image, body['id'])
self.assertEqual('queued', body['status'])
image_id = body['id']
# Now try uploading an image file
image_file = moves.cStringIO(data_utils.random_bytes())
self.client.store_image_file(image_id, image_file)
# Update Image
new_image_name = data_utils.rand_name('new-image')
body = self.client.update_image(image_id, [
dict(replace='/name', value=new_image_name)])
# Verifying updating
body = self.client.show_image(image_id)
self.assertEqual(image_id, body['id'])
self.assertEqual(new_image_name, body['name'])
开发者ID:Hybrid-Cloud,项目名称:tempest,代码行数:29,代码来源:test_images.py
示例2: _create_image
def _create_image(self):
image_file = StringIO.StringIO(data_utils.random_bytes())
resp, image = self.create_image(container_format='bare',
disk_format='raw',
is_public=False,
data=image_file)
self.assertEqual(201, resp.status)
image_id = image['id']
return image_id
开发者ID:hkumarmk,项目名称:tempest,代码行数:9,代码来源:base.py
示例3: _create_standard_image
def _create_standard_image(cls, name, container_format,
disk_format, size):
"""Create a new standard image and return newly-registered image-id"""
image_file = six.BytesIO(data_utils.random_bytes(size))
name = 'New Standard Image %s' % name
image = cls.create_image(name=name,
container_format=container_format,
disk_format=disk_format,
is_public=False, data=image_file,
properties={'key1': 'value1'})
return image['id']
开发者ID:redhat-openstack,项目名称:tempest,代码行数:12,代码来源:test_images.py
示例4: _create_standard_image
def _create_standard_image(cls, name, container_format, disk_format, size):
"""
Create a new standard image and return the ID of the newly-registered
image. Note that the size of the new image is a random number between
1024 and 4096
"""
image_file = StringIO.StringIO(data_utils.random_bytes(size))
name = "New Standard Image %s" % name
image = cls.create_image(
name=name, container_format=container_format, disk_format=disk_format, is_public=False, data=image_file
)
image_id = image["id"]
return image_id
开发者ID:CiscoSystems,项目名称:tempest,代码行数:13,代码来源:test_images.py
示例5: _create_standard_image
def _create_standard_image(cls, container_format, disk_format):
"""Create a new standard image and return the newly-registered image-id
Note that the size of the new image is a random number between
1024 and 4096
"""
size = random.randint(1024, 4096)
image_file = six.BytesIO(data_utils.random_bytes(size))
image = cls.create_image(container_format=container_format,
disk_format=disk_format,
visibility='private')
cls.client.store_image_file(image['id'], data=image_file)
return image['id']
开发者ID:Tesora,项目名称:tesora-tempest,代码行数:14,代码来源:test_images.py
示例6: _create_standard_image
def _create_standard_image(cls, container_format, disk_format):
"""Create a new standard image and return the newly-registered image-id
Note that the size of the new image is a random number between
1024 and 4096
"""
size = random.randint(1024, 4096)
image_file = moves.cStringIO(data_utils.random_bytes(size))
name = data_utils.rand_name('image')
body = cls.create_image(name=name,
container_format=container_format,
disk_format=disk_format,
visibility='private')
image_id = body['id']
cls.client.store_image_file(image_id, data=image_file)
return image_id
开发者ID:Hybrid-Cloud,项目名称:tempest,代码行数:17,代码来源:test_images.py
示例7: test_register_then_upload
def test_register_then_upload(self):
# Register, then upload an image
properties = {"prop1": "val1"}
body = self.create_image(
name="New Name", container_format="bare", disk_format="raw", is_public=False, properties=properties
)
self.assertIn("id", body)
image_id = body.get("id")
self.assertEqual("New Name", body.get("name"))
self.assertFalse(body.get("is_public"))
self.assertEqual("queued", body.get("status"))
for key, val in properties.items():
self.assertEqual(val, body.get("properties")[key])
# Now try uploading an image file
image_file = StringIO.StringIO(data_utils.random_bytes())
body = self.client.update_image(image_id, data=image_file)
self.assertIn("size", body)
self.assertEqual(1024, body.get("size"))
开发者ID:CiscoSystems,项目名称:tempest,代码行数:19,代码来源:test_images.py
示例8: test_register_then_upload
def test_register_then_upload(self):
# Register, then upload an image
properties = {'prop1': 'val1'}
container_format, disk_format = get_container_and_disk_format()
image = self.create_image(name='New Name',
container_format=container_format,
disk_format=disk_format,
is_public=False,
properties=properties)
self.assertEqual('New Name', image.get('name'))
self.assertFalse(image.get('is_public'))
self.assertEqual('queued', image.get('status'))
for key, val in properties.items():
self.assertEqual(val, image.get('properties')[key])
# Now try uploading an image file
image_file = six.BytesIO(data_utils.random_bytes())
body = self.client.update_image(image['id'], data=image_file)['image']
self.assertIn('size', body)
self.assertEqual(1024, body.get('size'))
开发者ID:redhat-openstack,项目名称:tempest,代码行数:20,代码来源:test_images.py
示例9: test_register_upload_get_image_file
def test_register_upload_get_image_file(self):
"""Here we test these functionalities
Register image, upload the image file, get image and get image
file api's
"""
uuid = '00000000-1111-2222-3333-444455556666'
image_name = data_utils.rand_name('image')
container_format = CONF.image.container_formats[0]
disk_format = CONF.image.disk_formats[0]
body = self.create_image(name=image_name,
container_format=container_format,
disk_format=disk_format,
visibility='private',
ramdisk_id=uuid)
self.assertIn('id', body)
image_id = body.get('id')
self.assertIn('name', body)
self.assertEqual(image_name, body['name'])
self.assertIn('visibility', body)
self.assertEqual('private', body['visibility'])
self.assertIn('status', body)
self.assertEqual('queued', body['status'])
# Now try uploading an image file
file_content = data_utils.random_bytes()
image_file = moves.cStringIO(file_content)
self.client.store_image_file(image_id, image_file)
# Now try to get image details
body = self.client.show_image(image_id)
self.assertEqual(image_id, body['id'])
self.assertEqual(image_name, body['name'])
self.assertEqual(uuid, body['ramdisk_id'])
self.assertIn('size', body)
self.assertEqual(1024, body.get('size'))
# Now try get image file
body = self.client.show_image_file(image_id)
self.assertEqual(file_content, body.data)
开发者ID:Hybrid-Cloud,项目名称:tempest,代码行数:41,代码来源:test_images.py
示例10: test_register_then_upload
def test_register_then_upload(self):
# Register, then upload an image
properties = {'prop1': 'val1'}
_, body = self.create_image(name='New Name',
container_format='bare',
disk_format='raw',
is_public=False,
properties=properties)
self.assertIn('id', body)
image_id = body.get('id')
self.assertEqual('New Name', body.get('name'))
self.assertFalse(body.get('is_public'))
self.assertEqual('queued', body.get('status'))
for key, val in properties.items():
self.assertEqual(val, body.get('properties')[key])
# Now try uploading an image file
image_file = StringIO.StringIO(data_utils.random_bytes())
_, body = self.client.update_image(image_id, data=image_file)
self.assertIn('size', body)
self.assertEqual(1024, body.get('size'))
开发者ID:cameron-r,项目名称:tempest-configuration,代码行数:21,代码来源:test_images.py
注:本文中的tempest.common.utils.data_utils.random_bytes函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论