| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
import warlock |
| 17 |
|
| 18 |
from glanceclient.common import utils |
| 19 |
from glanceclient.v2 import schemas |
| 20 |
|
| 21 |
|
| 22 |
class Controller(object): |
| 23 |
def __init__(self, http_client, schema_client): |
| 24 |
self.http_client = http_client |
| 25 |
self.schema_client = schema_client |
| 26 |
|
| 27 |
@utils.memoized_property |
| 28 |
def model(self): |
| 29 |
schema = self.schema_client.get('image') |
| 30 |
return warlock.model_factory(schema.raw(), |
| 31 |
base_class=schemas.SchemaBasedModel) |
| 32 |
|
| 33 |
@utils.add_req_id_to_object() |
| 34 |
def update(self, image_id, tag_value): |
| 35 |
"""Update an image with the given tag. |
| 36 |
|
| 37 |
:param image_id: image to be updated with the given tag. |
| 38 |
:param tag_value: value of the tag. |
| 39 |
""" |
| 40 |
url = '/v2/images/%s/tags/%s' % (image_id, tag_value) |
| 41 |
resp, body = self.http_client.put(url) |
| 42 |
return (resp, body), resp |
| 43 |
|
| 44 |
@utils.add_req_id_to_object() |
| 45 |
def delete(self, image_id, tag_value): |
| 46 |
"""Delete the tag associated with the given image. |
| 47 |
|
| 48 |
:param image_id: Image whose tag to be deleted. |
| 49 |
:param tag_value: tag value to be deleted. |
| 50 |
""" |
| 51 |
url = '/v2/images/%s/tags/%s' % (image_id, tag_value) |
| 52 |
resp, body = self.http_client.delete(url) |
| 53 |
return (resp, body), resp |