54
53
return self.client.get_images_detailed()
56
def show(self, context, id):
55
def show(self, context, image_id):
58
57
Returns a dict containing image data for the given opaque image id.
60
image = self.client.get_image_meta(id)
63
raise exception.NotFound
65
def create(self, context, data):
60
image = self.client.get_image_meta(image_id)
61
except glance_exception.NotFound:
62
raise exception.NotFound
65
def show_by_name(self, context, name):
67
Returns a dict containing image data for the given name.
69
# TODO(vish): replace this with more efficient call when glance
71
images = self.detail(context)
73
for cantidate in images:
74
if name == cantidate.get('name'):
78
raise exception.NotFound
81
def get(self, context, image_id, data):
83
Calls out to Glance for metadata and data and writes data.
86
metadata, image_chunks = self.client.get_image(image_id)
87
except glance_exception.NotFound:
88
raise exception.NotFound
89
for chunk in image_chunks:
93
def create(self, context, metadata, data=None):
67
95
Store the image data and return the new image id.
69
97
:raises AlreadyExists if the image already exist.
72
return self.client.add_image(image_meta=data)
100
return self.client.add_image(metadata, data)
74
def update(self, context, image_id, data):
102
def update(self, context, image_id, metadata, data=None):
75
103
"""Replace the contents of the given image with the new data.
77
105
:raises NotFound if the image does not exist.
80
return self.client.update_image(image_id, data)
109
result = self.client.update_image(image_id, metadata, data)
110
except glance_exception.NotFound:
111
raise exception.NotFound
82
114
def delete(self, context, image_id):