def test_find_image_by_name_or_id(self): """Tests the find_image_by_name_or_id function.""" img_id = str(uuid.uuid4()) img_name = 'myfakeimage' self.my_image.id = img_id self.my_image.name = img_name self.glance_client.images.get.side_effect = [ self.my_image, exc.HTTPNotFound(), exc.HTTPNotFound(), exc.HTTPNotFound() ] self.glance_client.images.list.side_effect = [[self.my_image], [], [ self.my_image, self.my_image ]] self.assertEqual(img_id, self.glance_plugin.find_image_by_name_or_id(img_id)) self.assertEqual(img_id, self.glance_plugin.find_image_by_name_or_id(img_name)) self.assertRaises(exceptions.NotFound, self.glance_plugin.find_image_by_name_or_id, 'noimage') self.assertRaises(exceptions.NoUniqueMatch, self.glance_plugin.find_image_by_name_or_id, 'myfakeimage')
def test__get_validated_image_exceptions(self, mock_glance_image): mock_glance_image.return_value.pre_process.return_value = "image_id" clients = mock.Mock() clients.glance().images.get.side_effect = glance_exc.HTTPNotFound("") e = self.assertRaises( validators.validation.ValidationError, self.validator._get_validated_image, config, clients, "image") self.assertEqual("Image '%s' not found" % config["args"]["image"], e.message) mock_glance_image.assert_called_once_with( context={"admin": {"credential": clients.credential}}) mock_glance_image.return_value.pre_process.assert_called_once_with( config["args"]["image"], config={}) clients.glance().images.get.assert_called_with("image_id") mock_glance_image.return_value.pre_process.reset_mock() clients.side_effect = exceptions.InvalidScenarioArgument("") e = self.assertRaises( validators.validation.ValidationError, self.validator._get_validated_image, config, clients, "image") self.assertEqual("Image '%s' not found" % config["args"]["image"], e.message) mock_glance_image.return_value.pre_process.assert_called_once_with( config["args"]["image"], config={}) clients.glance().images.get.assert_called_with("image_id")
def get(self, image): image_id = utils.get_id(image) for i in FAKE_IMAGES: if i.id == image_id: return i raise glance_exc.HTTPNotFound()
def test__get_validated_image_not_found(self, mock_transform): clients = mock.MagicMock() clients.glance().images.get.side_effect = glance_exc.HTTPNotFound("") result = validation._get_validated_image({"args": { "a": "test" }}, clients, "a") self.assertFalse(result[0].is_valid, result[0].msg)
def test_validator_image_not_in_context(self, mock_glance_image_transform): config = { "args": { "image": "fake_image" }, "context": { "images": { "fake_image_name": "foo" } } } clients = self.credentials["openstack"]["users"][ 0].get.return_value.clients.return_value clients.glance().images.get = mock.Mock() result = self.validator.validate(config, self.credentials, None, None) self.assertIsNone(result) mock_glance_image_transform.assert_called_once_with( clients=clients, resource_config=config["args"]["image"]) clients.glance().images.get.assert_called_with("image_id") exs = [exceptions.InvalidScenarioArgument(), glance_exc.HTTPNotFound()] for ex in exs: clients.glance().images.get.side_effect = ex result = self.validator.validate(config, credentials, None, None) self.assertEqual("Image 'fake_image' not found", result.msg)
def update_location(self, image_id, url, metadata): """Update an existing location entry in an image's list of locations. The URL specified must be already present in the image's list of locations. :param image_id: ID of image whose location is to be updated. :param url: URL of the location to update. :param metadata: Metadata associated with the location. :returns: The updated image """ image = self._get_image_with_locations_or_fail(image_id) url_map = dict([(l['url'], l) for l in image.locations]) if url not in url_map: raise exc.HTTPNotFound('Unknown URL: %s, the URL must be one of' ' existing locations of current image' % url) if url_map[url]['metadata'] == metadata: return image url_map[url]['metadata'] = metadata patches = [{ 'op': 'replace', 'path': '/locations', 'value': list(url_map.values()) }] response = self._send_image_update_request(image_id, patches) # Get request id from the above update request and pass the same to # following get request req_id_hdr = {'x-openstack-request-id': response.request_ids[0]} return self._get(image_id, req_id_hdr)
def test_validator_image_not_in_context(self, mock_glance_image_transform): config = { "args": { "image": "fake_image" }, "contexts": { "images": { "fake_image_name": "foo" } } } clients = self.context["users"][0]["credential"].clients.return_value clients.glance().images.get = mock.Mock() result = self.validator.validate(self.context, config, None, None) self.assertIsNone(result) mock_glance_image_transform.assert_called_once_with( clients=clients, resource_config=config["args"]["image"]) clients.glance().images.get.assert_called_with("image_id") exs = [exceptions.InvalidScenarioArgument(), glance_exc.HTTPNotFound()] for ex in exs: clients.glance().images.get.side_effect = ex e = self.assertRaises(validators.validation.ValidationError, self.validator.validate, self.context, config, None, None) self.assertEqual("Image 'fake_image' not found", e.message)
def test__get_validated_image_exceptions(self, mock_glance_image_transform): clients = mock.Mock() clients.glance().images.get.return_value = "image" clients.glance().images.get.side_effect = glance_exc.HTTPNotFound("") result = self.validator._get_validated_image(config, clients, "image") self.assertIsInstance(result[0], validators.ValidationResult) self.assertFalse(result[0].is_valid) self.assertEqual(result[0].msg, "Image '%s' not found" % config["args"]["image"]) self.assertIsNone(result[1]) mock_glance_image_transform.assert_called_once_with( clients=clients, resource_config=config["args"]["image"]) clients.glance().images.get.assert_called_with("image_id") clients.side_effect = exceptions.InvalidScenarioArgument("") result = self.validator._get_validated_image(config, clients, "image") self.assertIsInstance(result[0], validators.ValidationResult) self.assertFalse(result[0].is_valid) self.assertEqual(result[0].msg, "Image '%s' not found" % config["args"]["image"]) self.assertIsNone(result[1]) mock_glance_image_transform.assert_called_with( clients=clients, resource_config=config["args"]["image"]) clients.glance().images.get.assert_called_with("image_id")
def update_location(self, image_id, url, metadata): """Update an existing location entry in an image's list of locations. The URL specified must be already present in the image's list of locations. :param image_id: ID of image whose location is to be updated. :param url: URL of the location to update. :param metadata: Metadata associated with the location. :returns: The updated image """ image = self._get_image_with_locations_or_fail(image_id) url_map = dict([(l['url'], l) for l in image.locations]) if url not in url_map: raise exc.HTTPNotFound('Unknown URL: %s' % url) if url_map[url]['metadata'] == metadata: return image # NOTE: The server (as of now) doesn't support modifying individual # location entries. So we must: # 1. Empty existing list of locations. # 2. Send another request to set 'locations' to the new list # of locations. url_map[url]['metadata'] = metadata patches = [{'op': 'replace', 'path': '/locations', 'value': p} for p in ([], list(url_map.values()))] self._send_image_update_request(image_id, patches) return self.get(image_id)
def test_image_handle_delete(self): self.resource_id = None self.assertIsNone(self.my_image.handle_delete()) image_id = '41f0e60c-ebb4-4375-a2b4-845ae8b9c995' self.my_image.resource_id = image_id self.images.delete.return_value = None self.assertIsNone(self.my_image.handle_delete()) self.images.delete.side_effect = glance_exceptions.HTTPNotFound(404) self.assertIsNone(self.my_image.handle_delete())
def test_version_update_fail_image_not_found(self, mock_glance_client): mock_glance_client.return_value.images.get = Mock( side_effect=glance_exceptions.HTTPNotFound()) body = {"image": "non-existent-image-id"} self.assertRaisesRegex(exception.ImageNotFound, "Image non-existent-image-id cannot be found.", self.version_controller.edit, self.req, body, self.tenant_id, self.ds_version2.id)
def test_image_handle_update_tags_delete_not_found(self): self.my_image.resource_id = '477e8273-60a7-4c41-b683-fdb0bc7cd151' self.my_image.t['Properties']['tags'] = ['tag1'] prop_diff = {'tags': ['tag2']} self.image_tags.delete.side_effect = exc.HTTPNotFound() self._handle_update_tags(prop_diff)
def delete(self, image): image_id = utils.get_id(image) image_index = 0 for image in FAKE_IMAGES: if image.id != image_id: image_index += 1 continue del FAKE_IMAGES[image_index] return True raise glance_exc.HTTPNotFound()
def test_image_handle_update_tags_delete_not_found(self): self.my_image.resource_id = '477e8273-60a7-4c41-b683-fdb0bc7cd151' props = self.stack.t.t['resources']['my_image']['properties'].copy() props['tags'] = ['tag1'] self.my_image.t = self.my_image.t.freeze(properties=props) self.my_image.reparse() prop_diff = {'tags': ['tag2']} self.image_tags.delete.side_effect = exc.HTTPNotFound() self._handle_update_tags(prop_diff)
def test_get_image_id_not_found(self): """Tests the get_image_id function while image is not found.""" img_name = str(uuid.uuid4()) self.glance_client.images.get.side_effect = [ glance_exceptions.HTTPNotFound()] self.glance_client.images.list.return_value = [] self.assertRaises(exception.ImageNotFound, self.glance_plugin.get_image_id, img_name) self.glance_client.images.get.assert_called_once_with(img_name) self.glance_client.images.list.assert_called_once_with( filters={'name': img_name})
def test_get_image_id_by_name_in_uuid(self): """Tests the get_image_id function by name in uuid.""" img_id = str(uuid.uuid4()) img_name = str(uuid.uuid4()) self.my_image.id = img_id self.my_image.name = img_name self.glance_client.images.get.side_effect = [ glance_exceptions.HTTPNotFound()] self.glance_client.images.list.return_value = [self.my_image] self.assertEqual(img_id, self.glance_plugin.get_image_id(img_name)) self.glance_client.images.get.assert_called_once_with(img_name) self.glance_client.images.list.assert_called_once_with( filters={'name': img_name})
def test_fail_image_not_found_version_create(self, mock_glance_client): mock_glance_client.return_value.images.get = Mock( side_effect=glance_exceptions.HTTPNotFound()) body = {"version": { "datastore_name": "test_ds", "name": "test_vr", "datastore_manager": "mysql", "image": "image-id", "packages": "test-pkg", "active": True, "default": True}} self.assertRaisesRegex( exception.ImageNotFound, "Image image-id cannot be found.", self.version_controller.create, self.req, body, self.tenant_id)
def test_get_image_id_not_found(self): """Tests the get_image_id function while image is not found.""" my_image = self.m.CreateMockAnything() img_name = str(uuid.uuid4()) my_image.name = img_name self.glance_client.images = self.m.CreateMockAnything() self.glance_client.images.get(img_name).AndRaise( glance_exceptions.HTTPNotFound()) filters = {'name': img_name} self.glance_client.images.list( filters=filters).MultipleTimes().AndReturn([]) self.m.ReplayAll() self.assertRaises(exception.ImageNotFound, self.glance_plugin.get_image_id, img_name) self.m.VerifyAll()
def test_get_image_id_by_name_in_uuid(self): """Tests the get_image_id function by name in uuid.""" my_image = self.m.CreateMockAnything() img_id = str(uuid.uuid4()) img_name = str(uuid.uuid4()) my_image.id = img_id my_image.name = img_name self.glance_client.images = self.m.CreateMockAnything() self.glance_client.images.get(img_name).AndRaise( glance_exceptions.HTTPNotFound()) filters = {'name': img_name} self.glance_client.images.list( filters=filters).MultipleTimes().AndReturn([my_image]) self.m.ReplayAll() self.assertEqual(img_id, self.glance_plugin.get_image_id(img_name)) self.m.VerifyAll()
def test_create_image_notfound(self, mock_create_client): image_id = self.random_uuid() ver_name = self.random_name('dsversion') body = { "version": { "datastore_name": self.ds_name, "name": ver_name, "datastore_manager": "mysql", "image": image_id, "active": True, "default": False } } mock_client = Mock() mock_client.images.get.side_effect = [glance_exceptions.HTTPNotFound()] mock_create_client.return_value = mock_client self.assertRaises(exception.ImageNotFound, self.version_controller.create, MagicMock(), body, mock.ANY)
def delete_locations(self, image_id, url_set): """Remove one or more location entries of an image. :param image_id: ID of image from which locations are to be removed. :param url_set: set of URLs of location entries to remove. :returns: None """ image = self._get_image_with_locations_or_fail(image_id) current_urls = [l['url'] for l in image.locations] missing_locs = url_set.difference(set(current_urls)) if missing_locs: raise exc.HTTPNotFound('Unknown URL(s): %s' % list(missing_locs)) # NOTE: warlock doesn't generate the most efficient patch for remove # operations (it shifts everything up and deletes the tail elements) so # we do it ourselves. url_indices = [current_urls.index(url) for url in url_set] url_indices.sort(reverse=True) patches = [{'op': 'remove', 'path': '/locations/%s' % url_idx} for url_idx in url_indices] self._send_image_update_request(image_id, patches)
def test__get_validated_image_exceptions(self, mock_glance_image_transform): clients = mock.Mock() clients.glance().images.get.return_value = "image" clients.glance().images.get.side_effect = glance_exc.HTTPNotFound("") e = self.assertRaises(validators.validation.ValidationError, self.validator._get_validated_image, config, clients, "image") self.assertEqual("Image '%s' not found" % config["args"]["image"], e.message) mock_glance_image_transform.assert_called_once_with( clients=clients, resource_config=config["args"]["image"]) clients.glance().images.get.assert_called_with("image_id") clients.side_effect = exceptions.InvalidScenarioArgument("") e = self.assertRaises(validators.validation.ValidationError, self.validator._get_validated_image, config, clients, "image") self.assertEqual("Image '%s' not found" % config["args"]["image"], e.message) mock_glance_image_transform.assert_called_with( clients=clients, resource_config=config["args"]["image"]) clients.glance().images.get.assert_called_with("image_id")
class TestIsNotFound(common.HeatTestCase): scenarios = [ ('ceilometer_not_found', dict( is_not_found=True, is_over_limit=False, is_client_exception=True, is_conflict=False, plugin='ceilometer', exception=lambda: ceil_exc.HTTPNotFound(details='gone'), )), ('ceilometer_not_found_apiclient', dict( is_not_found=True, is_over_limit=False, is_client_exception=True, is_conflict=False, plugin='ceilometer', exception=lambda: c_a_exc.NotFound(details='gone'), )), ('ceilometer_exception', dict( is_not_found=False, is_over_limit=False, is_client_exception=False, is_conflict=False, plugin='ceilometer', exception=lambda: Exception() )), ('ceilometer_overlimit', dict( is_not_found=False, is_over_limit=True, is_client_exception=True, is_conflict=False, plugin='ceilometer', exception=lambda: ceil_exc.HTTPOverLimit(details='over'), )), ('ceilometer_conflict', dict( is_not_found=False, is_over_limit=False, is_client_exception=True, is_conflict=True, plugin='ceilometer', exception=lambda: ceil_exc.HTTPConflict(), )), ('cinder_not_found', dict( is_not_found=True, is_over_limit=False, is_client_exception=True, is_conflict=False, plugin='cinder', exception=lambda: cinder_exc.NotFound(code=404), )), ('cinder_exception', dict( is_not_found=False, is_over_limit=False, is_client_exception=False, is_conflict=False, plugin='cinder', exception=lambda: Exception() )), ('cinder_overlimit', dict( is_not_found=False, is_over_limit=True, is_client_exception=True, is_conflict=False, plugin='cinder', exception=lambda: cinder_exc.OverLimit(code=413), )), ('cinder_conflict', dict( is_not_found=False, is_over_limit=False, is_client_exception=True, is_conflict=True, plugin='cinder', exception=lambda: cinder_exc.ClientException(code=409), )), ('glance_not_found', dict( is_not_found=True, is_over_limit=False, is_client_exception=True, is_conflict=False, plugin='glance', exception=lambda: glance_exc.HTTPNotFound(details='gone'), )), ('glance_exception', dict( is_not_found=False, is_over_limit=False, is_client_exception=False, is_conflict=False, plugin='glance', exception=lambda: Exception() )), ('glance_overlimit', dict( is_not_found=False, is_over_limit=True, is_client_exception=True, is_conflict=False, plugin='glance', exception=lambda: glance_exc.HTTPOverLimit(details='over'), )), ('glance_conflict', dict( is_not_found=False, is_over_limit=False, is_client_exception=True, is_conflict=True, plugin='glance', exception=lambda: glance_exc.HTTPConflict(), )), ('heat_not_found', dict( is_not_found=True, is_over_limit=False, is_client_exception=True, is_conflict=False, plugin='heat', exception=lambda: heat_exc.HTTPNotFound(message='gone'), )), ('heat_exception', dict( is_not_found=False, is_over_limit=False, is_client_exception=False, is_conflict=False, plugin='heat', exception=lambda: Exception() )), ('heat_overlimit', dict( is_not_found=False, is_over_limit=True, is_client_exception=True, is_conflict=False, plugin='heat', exception=lambda: heat_exc.HTTPOverLimit(message='over'), )), ('heat_conflict', dict( is_not_found=False, is_over_limit=False, is_client_exception=True, is_conflict=True, plugin='heat', exception=lambda: heat_exc.HTTPConflict(), )), ('keystone_not_found', dict( is_not_found=True, is_over_limit=False, is_client_exception=True, is_conflict=False, plugin='keystone', exception=lambda: keystone_exc.NotFound(details='gone'), )), ('keystone_exception', dict( is_not_found=False, is_over_limit=False, is_client_exception=False, is_conflict=False, plugin='keystone', exception=lambda: Exception() )), ('keystone_overlimit', dict( is_not_found=False, is_over_limit=True, is_client_exception=True, is_conflict=False, plugin='keystone', exception=lambda: keystone_exc.RequestEntityTooLarge( details='over'), )), ('keystone_conflict', dict( is_not_found=False, is_over_limit=False, is_client_exception=True, is_conflict=True, plugin='keystone', exception=lambda: keystone_exc.Conflict( message='Conflict'), )), ('neutron_not_found', dict( is_not_found=True, is_over_limit=False, is_client_exception=True, is_conflict=False, plugin='neutron', exception=lambda: neutron_exc.NotFound, )), ('neutron_network_not_found', dict( is_not_found=True, is_over_limit=False, is_client_exception=True, is_conflict=False, plugin='neutron', exception=lambda: neutron_exc.NetworkNotFoundClient(), )), ('neutron_port_not_found', dict( is_not_found=True, is_over_limit=False, is_client_exception=True, is_conflict=False, plugin='neutron', exception=lambda: neutron_exc.PortNotFoundClient(), )), ('neutron_status_not_found', dict( is_not_found=True, is_over_limit=False, is_client_exception=True, is_conflict=False, plugin='neutron', exception=lambda: neutron_exc.NeutronClientException( status_code=404), )), ('neutron_exception', dict( is_not_found=False, is_over_limit=False, is_client_exception=False, is_conflict=False, plugin='neutron', exception=lambda: Exception() )), ('neutron_overlimit', dict( is_not_found=False, is_over_limit=True, is_client_exception=True, is_conflict=False, plugin='neutron', exception=lambda: neutron_exc.NeutronClientException( status_code=413), )), ('neutron_conflict', dict( is_not_found=False, is_over_limit=False, is_client_exception=True, is_conflict=True, plugin='neutron', exception=lambda: neutron_exc.Conflict(), )), ('nova_not_found', dict( is_not_found=True, is_over_limit=False, is_client_exception=True, is_conflict=False, is_unprocessable_entity=False, plugin='nova', exception=lambda: fakes_nova.fake_exception(), )), ('nova_exception', dict( is_not_found=False, is_over_limit=False, is_client_exception=False, is_conflict=False, is_unprocessable_entity=False, plugin='nova', exception=lambda: Exception() )), ('nova_overlimit', dict( is_not_found=False, is_over_limit=True, is_client_exception=True, is_conflict=False, is_unprocessable_entity=False, plugin='nova', exception=lambda: fakes_nova.fake_exception(413), )), ('nova_unprocessable_entity', dict( is_not_found=False, is_over_limit=False, is_client_exception=True, is_conflict=False, is_unprocessable_entity=True, plugin='nova', exception=lambda: fakes_nova.fake_exception(422), )), ('nova_conflict', dict( is_not_found=False, is_over_limit=False, is_client_exception=True, is_conflict=True, is_unprocessable_entity=False, plugin='nova', exception=lambda: fakes_nova.fake_exception(409), )), ('swift_not_found', dict( is_not_found=True, is_over_limit=False, is_client_exception=True, is_conflict=False, plugin='swift', exception=lambda: swift_exc.ClientException( msg='gone', http_status=404), )), ('swift_exception', dict( is_not_found=False, is_over_limit=False, is_client_exception=False, is_conflict=False, plugin='swift', exception=lambda: Exception() )), ('swift_overlimit', dict( is_not_found=False, is_over_limit=True, is_client_exception=True, is_conflict=False, plugin='swift', exception=lambda: swift_exc.ClientException( msg='ouch', http_status=413), )), ('swift_conflict', dict( is_not_found=False, is_over_limit=False, is_client_exception=True, is_conflict=True, plugin='swift', exception=lambda: swift_exc.ClientException( msg='conflict', http_status=409), )), ('trove_not_found', dict( is_not_found=True, is_over_limit=False, is_client_exception=True, is_conflict=False, plugin='trove', exception=lambda: troveclient.exceptions.NotFound(message='gone'), )), ('trove_exception', dict( is_not_found=False, is_over_limit=False, is_client_exception=False, is_conflict=False, plugin='trove', exception=lambda: Exception() )), ('trove_overlimit', dict( is_not_found=False, is_over_limit=True, is_client_exception=True, is_conflict=False, plugin='trove', exception=lambda: troveclient.exceptions.RequestEntityTooLarge( message='over'), )), ('trove_conflict', dict( is_not_found=False, is_over_limit=False, is_client_exception=True, is_conflict=True, plugin='trove', exception=lambda: troveclient.exceptions.Conflict( message='Conflict'), )), ('sahara_not_found', dict( is_not_found=True, is_over_limit=False, is_client_exception=True, is_conflict=False, plugin='sahara', exception=lambda: sahara_base.APIException( error_message='gone1', error_code=404), )), ('sahara_exception', dict( is_not_found=False, is_over_limit=False, is_client_exception=False, is_conflict=False, plugin='sahara', exception=lambda: Exception() )), ('sahara_overlimit', dict( is_not_found=False, is_over_limit=True, is_client_exception=True, is_conflict=False, plugin='sahara', exception=lambda: sahara_base.APIException( error_message='over1', error_code=413), )), ('sahara_conflict', dict( is_not_found=False, is_over_limit=False, is_client_exception=True, is_conflict=True, plugin='sahara', exception=lambda: sahara_base.APIException( error_message='conflict1', error_code=409), )), ] def test_is_not_found(self): con = mock.Mock() c = clients.Clients(con) client_plugin = c.client_plugin(self.plugin) try: raise self.exception() except Exception as e: if self.is_not_found != client_plugin.is_not_found(e): raise def test_ignore_not_found(self): con = mock.Mock() c = clients.Clients(con) client_plugin = c.client_plugin(self.plugin) try: exp = self.exception() exp_class = exp.__class__ raise exp except Exception as e: if self.is_not_found: client_plugin.ignore_not_found(e) else: self.assertRaises(exp_class, client_plugin.ignore_not_found, e) def test_ignore_conflict_and_not_found(self): con = mock.Mock() c = clients.Clients(con) client_plugin = c.client_plugin(self.plugin) try: exp = self.exception() exp_class = exp.__class__ raise exp except Exception as e: if self.is_conflict or self.is_not_found: client_plugin.ignore_conflict_and_not_found(e) else: self.assertRaises(exp_class, client_plugin.ignore_conflict_and_not_found, e) def test_is_over_limit(self): con = mock.Mock() c = clients.Clients(con) client_plugin = c.client_plugin(self.plugin) try: raise self.exception() except Exception as e: if self.is_over_limit != client_plugin.is_over_limit(e): raise def test_is_client_exception(self): con = mock.Mock() c = clients.Clients(con) client_plugin = c.client_plugin(self.plugin) try: raise self.exception() except Exception as e: ice = self.is_client_exception actual = client_plugin.is_client_exception(e) if ice != actual: raise def test_is_conflict(self): con = mock.Mock() c = clients.Clients(con) client_plugin = c.client_plugin(self.plugin) try: raise self.exception() except Exception as e: if self.is_conflict != client_plugin.is_conflict(e): raise def test_is_unprocessable_entity(self): con = mock.Mock() c = clients.Clients(con) # only 'nova' client plugin need to check this exception if self.plugin == 'nova': client_plugin = c.client_plugin(self.plugin) try: raise self.exception() except Exception as e: iue = self.is_unprocessable_entity if iue != client_plugin.is_unprocessable_entity(e): raise
def get(self, image_id): raise glance_exc.HTTPNotFound(image_id)
def get(self, resource_uuid): image = self.cache.get(resource_uuid, None) if image is not None: return image raise exc.HTTPNotFound("Image %s not found" % (resource_uuid))