do reset state if failed to detached

Change-Id: Id4e3b9c866b867f9e9a1f03d05d22ac53c270b86
This commit is contained in:
Eyal 2018-04-16 09:27:52 +03:00
parent 6dcaaa2c07
commit 3b51d5479a
1 changed files with 7 additions and 4 deletions

View File

@ -29,13 +29,16 @@ def create_volume_and_attach(name, size, instance_id, mount_point):
def delete_all_volumes():
volumes = TempestClients.cinder().volumes.list()
cinder = TempestClients.cinder()
volumes = cinder.volumes.list()
for volume in volumes:
try:
TempestClients.cinder().volumes.detach(volume)
TempestClients.cinder().volumes.force_delete(volume)
cinder.volumes.detach(volume)
cinder.volumes.force_delete(volume)
except Exception:
TempestClients.cinder().volumes.force_delete(volume)
cinder.volumes.reset_state(volume, state='available',
attach_status='detached')
cinder.volumes.force_delete(volume)
wait_for_status(30, _check_num_volumes, num_volumes=0)
time.sleep(2)