本文整理汇总了Python中tempest.common.waiters.wait_for_volume_resource_status函数的典型用法代码示例。如果您正苦于以下问题:Python wait_for_volume_resource_status函数的具体用法?Python wait_for_volume_resource_status怎么用?Python wait_for_volume_resource_status使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wait_for_volume_resource_status函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_reset_snapshot_status
def test_reset_snapshot_status(self):
# Reset snapshot status to creating
status = 'creating'
self.admin_snapshots_client.reset_snapshot_status(
self.snapshot['id'], status)
waiters.wait_for_volume_resource_status(self.snapshots_client,
self.snapshot['id'], status)
示例2: delete_snapshot
def delete_snapshot(snapshot_id):
waiters.wait_for_volume_resource_status(self.snapshots_client,
snapshot_id,
'available')
# Delete snapshot
self.snapshots_client.delete_snapshot(snapshot_id)
self.snapshots_client.wait_for_resource_deletion(snapshot_id)
示例3: test_force_detach_volume
def test_force_detach_volume(self):
# Create a server and a volume
server_id = self.create_server()['id']
volume_id = self.create_volume()['id']
# Attach volume
self.volumes_client.attach_volume(
volume_id,
instance_uuid=server_id,
mountpoint='/dev/%s' % CONF.compute.volume_device_name)
waiters.wait_for_volume_resource_status(self.volumes_client,
volume_id, 'in-use')
self.addCleanup(waiters.wait_for_volume_resource_status,
self.volumes_client, volume_id, 'available')
self.addCleanup(self.volumes_client.detach_volume, volume_id)
attachment = self.volumes_client.show_volume(
volume_id)['volume']['attachments'][0]
# Reset volume's status to error
self.admin_volume_client.reset_volume_status(volume_id, status='error')
# Force detach volume
self.admin_volume_client.force_detach_volume(
volume_id, connector=None,
attachment_id=attachment['attachment_id'])
waiters.wait_for_volume_resource_status(self.volumes_client,
volume_id, 'available')
vol_info = self.volumes_client.show_volume(volume_id)['volume']
self.assertIn('attachments', vol_info)
self.assertEmpty(vol_info['attachments'])
示例4: test_create_group_from_group
def test_create_group_from_group(self):
# Create volume type
volume_type = self.create_volume_type()
# Create group type
group_type = self.create_group_type()
# Create Group
grp = self._create_group(group_type, volume_type)
# Create volume
self.create_volume(volume_type=volume_type['id'], group_id=grp['id'])
# Create Group from Group
grp_name2 = data_utils.rand_name('Group_from_grp')
grp2 = self.groups_client.create_group_from_source(
source_group_id=grp['id'], name=grp_name2)['group']
self.addCleanup(self._delete_group, grp2['id'])
self.assertEqual(grp_name2, grp2['name'])
vols = self.volumes_client.list_volumes(detail=True)['volumes']
for vol in vols:
if vol['group_id'] == grp2['id']:
waiters.wait_for_volume_resource_status(
self.volumes_client, vol['id'], 'available')
waiters.wait_for_volume_resource_status(
self.groups_client, grp2['id'], 'available')
示例5: nova_volume_detach
def nova_volume_detach(self, server, volume):
self.servers_client.detach_volume(server['id'], volume['id'])
waiters.wait_for_volume_resource_status(self.volumes_client,
volume['id'], 'available')
volume = self.volumes_client.show_volume(volume['id'])['volume']
self.assertEqual('available', volume['status'])
示例6: attach_volume
def attach_volume(self, server, volume, device=None, tag=None):
"""Attaches volume to server and waits for 'in-use' volume status.
The volume will be detached when the test tears down.
:param server: The server to which the volume will be attached.
:param volume: The volume to attach.
:param device: Optional mountpoint for the attached volume. Note that
this is not guaranteed for all hypervisors and is not recommended.
:param tag: Optional device role tag to apply to the volume.
"""
attach_kwargs = dict(volumeId=volume['id'])
if device:
attach_kwargs['device'] = device
if tag:
attach_kwargs['tag'] = tag
attachment = self.servers_client.attach_volume(
server['id'], **attach_kwargs)['volumeAttachment']
# On teardown detach the volume and wait for it to be available. This
# is so we don't error out when trying to delete the volume during
# teardown.
self.addCleanup(waiters.wait_for_volume_resource_status,
self.volumes_client, volume['id'], 'available')
# Ignore 404s on detach in case the server is deleted or the volume
# is already detached.
self.addCleanup(self._detach_volume, server, volume)
waiters.wait_for_volume_resource_status(self.volumes_client,
volume['id'], 'in-use')
return attachment
示例7: create_volume
def create_volume(self, size=None, name=None, snapshot_id=None,
imageRef=None, volume_type=None):
if size is None:
size = CONF.volume.volume_size
if imageRef:
image = self.compute_images_client.show_image(imageRef)['image']
min_disk = image.get('minDisk')
size = max(size, min_disk)
if name is None:
name = data_utils.rand_name(self.__class__.__name__ + "-volume")
kwargs = {'display_name': name,
'snapshot_id': snapshot_id,
'imageRef': imageRef,
'volume_type': volume_type,
'size': size}
volume = self.volumes_client.create_volume(**kwargs)['volume']
self.addCleanup(self.volumes_client.wait_for_resource_deletion,
volume['id'])
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.volumes_client.delete_volume, volume['id'])
# NOTE(e0ne): Cinder API v2 uses name instead of display_name
if 'display_name' in volume:
self.assertEqual(name, volume['display_name'])
else:
self.assertEqual(name, volume['name'])
waiters.wait_for_volume_resource_status(self.volumes_client,
volume['id'], 'available')
# The volume retrieved on creation has a non-up-to-date status.
# Retrieval after it becomes active ensures correct details.
volume = self.volumes_client.show_volume(volume['id'])['volume']
return volume
示例8: test_get_volume_attachment
def test_get_volume_attachment(self):
# Create a server
server = self.create_server()
# Verify that a volume's attachment information is retrieved
self.volumes_client.attach_volume(self.volume['id'],
instance_uuid=server['id'],
mountpoint='/dev/%s' %
CONF.compute.volume_device_name)
waiters.wait_for_volume_resource_status(self.volumes_client,
self.volume['id'],
'in-use')
self.addCleanup(waiters.wait_for_volume_resource_status,
self.volumes_client,
self.volume['id'], 'available')
self.addCleanup(self.volumes_client.detach_volume, self.volume['id'])
volume = self.volumes_client.show_volume(self.volume['id'])['volume']
self.assertIn('attachments', volume)
attachment = volume['attachments'][0]
self.assertEqual('/dev/%s' %
CONF.compute.volume_device_name,
attachment['device'])
self.assertEqual(server['id'], attachment['server_id'])
self.assertEqual(self.volume['id'], attachment['id'])
self.assertEqual(self.volume['id'], attachment['volume_id'])
示例9: test_create_list_delete_volume_transfer
def test_create_list_delete_volume_transfer(self):
# Create a volume first
volume = self.create_volume()
self.addCleanup(self.delete_volume,
self.adm_volumes_client,
volume['id'])
# Create a volume transfer
transfer_id = self.client.create_volume_transfer(
volume_id=volume['id'])['transfer']['id']
waiters.wait_for_volume_resource_status(
self.volumes_client, volume['id'], 'awaiting-transfer')
# List all volume transfers with details, check the detail-specific
# elements, and look for the created transfer.
transfers = self.client.list_volume_transfers(detail=True)['transfers']
self.assertNotEmpty(transfers)
for transfer in transfers:
self.assertIn('created_at', transfer)
volume_list = [transfer['volume_id'] for transfer in transfers]
self.assertIn(volume['id'], volume_list,
'Transfer not found for volume %s' % volume['id'])
# Delete a volume transfer
self.client.delete_volume_transfer(transfer_id)
waiters.wait_for_volume_resource_status(
self.volumes_client, volume['id'], 'available')
示例10: test_consistencygroup_cgsnapshot_create_delete
def test_consistencygroup_cgsnapshot_create_delete(self):
# Create volume type
name = data_utils.rand_name("volume-type")
volume_type = self.admin_volume_types_client.create_volume_type(
name=name)['volume_type']
# Create CG
cg_name = data_utils.rand_name('CG')
create_consistencygroup = (
self.consistencygroups_adm_client.create_consistencygroup)
cg = create_consistencygroup(volume_type['id'],
name=cg_name)['consistencygroup']
vol_name = data_utils.rand_name("volume")
params = {'name': vol_name,
'volume_type': volume_type['id'],
'consistencygroup_id': cg['id'],
'size': CONF.volume.volume_size}
# Create volume
volume = self.admin_volume_client.create_volume(**params)['volume']
waiters.wait_for_volume_resource_status(self.admin_volume_client,
volume['id'], 'available')
self.consistencygroups_adm_client.wait_for_consistencygroup_status(
cg['id'], 'available')
self.assertEqual(cg_name, cg['name'])
# Create cgsnapshot
cgsnapshot_name = data_utils.rand_name('cgsnapshot')
create_cgsnapshot = (
self.consistencygroups_adm_client.create_cgsnapshot)
cgsnapshot = create_cgsnapshot(cg['id'],
name=cgsnapshot_name)['cgsnapshot']
snapshots = self.admin_snapshots_client.list_snapshots(
detail=True)['snapshots']
for snap in snapshots:
if volume['id'] == snap['volume_id']:
waiters.wait_for_volume_resource_status(
self.admin_snapshots_client, snap['id'], 'available')
self.consistencygroups_adm_client.wait_for_cgsnapshot_status(
cgsnapshot['id'], 'available')
self.assertEqual(cgsnapshot_name, cgsnapshot['name'])
# Get a given CG snapshot
cgsnapshot = self.consistencygroups_adm_client.show_cgsnapshot(
cgsnapshot['id'])['cgsnapshot']
self.assertEqual(cgsnapshot_name, cgsnapshot['name'])
# Get all CG snapshots with detail
cgsnapshots = self.consistencygroups_adm_client.list_cgsnapshots(
detail=True)['cgsnapshots']
self.assertIn((cgsnapshot['name'], cgsnapshot['id']),
[(m['name'], m['id']) for m in cgsnapshots])
# Clean up
self._delete_cgsnapshot(cgsnapshot['id'], cg['id'])
self._delete_consistencygroup(cg['id'])
self.admin_volume_types_client.delete_volume_type(volume_type['id'])
示例11: tearDown
def tearDown(self):
# Set snapshot's status to available after test
status = 'available'
snapshot_id = self.snapshot['id']
self.admin_snapshots_client.reset_snapshot_status(snapshot_id,
status)
waiters.wait_for_volume_resource_status(self.snapshots_client,
snapshot_id, status)
super(SnapshotsActionsTest, self).tearDown()
示例12: test_volume_extend
def test_volume_extend(self):
# Extend Volume Test.
volume = self.create_volume()
extend_size = volume['size'] + 1
self.volumes_client.extend_volume(volume['id'],
new_size=extend_size)
waiters.wait_for_volume_resource_status(self.volumes_client,
volume['id'], 'available')
volume = self.volumes_client.show_volume(volume['id'])['volume']
self.assertEqual(volume['size'], extend_size)
示例13: _create_reset_and_force_delete_temp_volume
def _create_reset_and_force_delete_temp_volume(self, status=None):
# Create volume, reset volume status, and force delete temp volume
temp_volume = self.create_volume()
if status:
self.admin_volume_client.reset_volume_status(
temp_volume['id'], status=status)
waiters.wait_for_volume_resource_status(
self.volumes_client, temp_volume['id'], status)
self.admin_volume_client.force_delete_volume(temp_volume['id'])
self.volumes_client.wait_for_resource_deletion(temp_volume['id'])
示例14: _attach_volume_to_server
def _attach_volume_to_server(self):
self._volume = self.create_test_volume()
self._server, _ = self.create_test_server(wait_until='ACTIVE')
self.volumes_client.attach_volume(self._volume['id'],
instance_uuid=self._server['id'],
mountpoint='/dev/vdc')
waiters.wait_for_volume_resource_status(self.volumes_client,
self._volume['id'], 'in-use')
示例15: nova_volume_attach
def nova_volume_attach(self, server, volume_to_attach):
volume = self.servers_client.attach_volume(
server['id'], volumeId=volume_to_attach['id'], device='/dev/%s'
% CONF.compute.volume_device_name)['volumeAttachment']
self.assertEqual(volume_to_attach['id'], volume['id'])
waiters.wait_for_volume_resource_status(self.volumes_client,
volume['id'], 'in-use')
# Return the updated volume after the attachment
return self.volumes_client.show_volume(volume['id'])['volume']