Remove a redundant wait_for_backup_deletion()

The rest_client module has a basic function wait_for_resource_deletion()
and it is enough to implement a small function is_resource_deleted()
in each service client for the same function.
This patch removes the wait_for_backup_deletion() and implement the
is_resource_deleted() for the code cleanup.

Partially implements blueprint consistent-service-method-names

Change-Id: I7c07f1cdde86be850f50825db01eb35c62497820
This commit is contained in:
Ken'ichi Ohmichi 2016-08-03 14:35:46 -07:00
parent 563363b00a
commit 153b3d9207
2 changed files with 7 additions and 12 deletions

View File

@ -43,7 +43,7 @@ class VolumesBackupsAdminV2Test(base.BaseVolumeAdminTest):
def _delete_backup(self, backup_id): def _delete_backup(self, backup_id):
self.admin_backups_client.delete_backup(backup_id) self.admin_backups_client.delete_backup(backup_id)
self.admin_backups_client.wait_for_backup_deletion(backup_id) self.admin_backups_client.wait_for_resource_deletion(backup_id)
def _decode_url(self, backup_url): def _decode_url(self, backup_url):
return json.loads(base64.decodestring(backup_url)) return json.loads(base64.decodestring(backup_url))

View File

@ -116,14 +116,9 @@ class BaseBackupsClient(rest_client.RestClient):
self.build_timeout)) self.build_timeout))
raise exceptions.TimeoutException(message) raise exceptions.TimeoutException(message)
def wait_for_backup_deletion(self, backup_id): def is_resource_deleted(self, id):
"""Waits for backup deletion""" try:
start_time = int(time.time()) self.show_backup(id)
while True: except lib_exc.NotFound:
try: return True
self.show_backup(backup_id) return False
except lib_exc.NotFound:
return
if int(time.time()) - start_time >= self.build_timeout:
raise exceptions.TimeoutException
time.sleep(self.build_interval)