"is_resource_deleted" fails to verify delete

Is resource deleted in images_client.py isn't adequate
for admin role because when checking for deleted images
the admin role returns a value whether the image is active or deleted.
This causes an endless loop if a call is waiting on a response of true.

Change-Id: I4e6937c992398cfc7db5391cfabb101aaefdb7e6
Closes-Bug: #1557088
Closes-Bug: #1564661
Closes-Bug: #1564614
This commit is contained in:
Joshua White 2016-04-11 06:17:42 -07:00
parent a16bf19ea9
commit 95dcef21f7
3 changed files with 6 additions and 3 deletions

View File

@ -131,8 +131,10 @@ class ImagesClient(base_compute_client.BaseComputeClient):
return rest_client.ResponseBody(resp, body) return rest_client.ResponseBody(resp, body)
def is_resource_deleted(self, id): def is_resource_deleted(self, id):
# Added status check for user with admin role
try: try:
self.show_image(id) if self.show_image(id)['image']['status'] == 'DELETED':
return True
except lib_exc.NotFound: except lib_exc.NotFound:
return True return True
return False return False

View File

@ -213,7 +213,8 @@ class ImagesClient(rest_client.RestClient):
def is_resource_deleted(self, id): def is_resource_deleted(self, id):
try: try:
self.get_image_meta(id) if self.get_image_meta(id)['status'] == 'deleted':
return True
except lib_exc.NotFound: except lib_exc.NotFound:
return True return True
return False return False

View File

@ -186,7 +186,7 @@ class TestImagesClient(base.BaseComputeServiceTest):
def _test_resource_deleted(self, bytes_body=False): def _test_resource_deleted(self, bytes_body=False):
params = {"id": self.FAKE_IMAGE_ID} params = {"id": self.FAKE_IMAGE_ID}
expected_op = self.FAKE_IMAGE_DATA['show']['image'] expected_op = self.FAKE_IMAGE_DATA['show']
self.useFixture(mockpatch.Patch('tempest.lib.services.compute' self.useFixture(mockpatch.Patch('tempest.lib.services.compute'
'.images_client.ImagesClient.show_image', '.images_client.ImagesClient.show_image',
side_effect=lib_exc.NotFound)) side_effect=lib_exc.NotFound))