Enable client V2 to update/delete tags for a given image.

Added the CLI option image-tag-update to associate a tag to an image via API V2.
Added the CLI option image-tag-delete to delete a tag associated with an image via API V2.

Related to bp glance-client-v2

Change-Id: I76060e1982223770a6c2c0bd9376d568af0df456
This commit is contained in:
Venkatesh Sampath
2013-06-25 17:58:42 +05:30
parent 62579fbb21
commit b9c1df8dfc
5 changed files with 206 additions and 4 deletions
+28
View File
@@ -133,3 +133,31 @@ def do_image_download(gc, args):
def do_image_delete(gc, args):
"""Delete specified image."""
gc.images.delete(args.id)
@utils.arg('image_id', metavar='<IMAGE_ID>',
help='Image to be updated with the given tag')
@utils.arg('tag_value', metavar='<TAG_VALUE>',
help='Value of the tag')
def do_image_tag_update(gc, args):
"""Update an image with the given tag."""
if not (args.image_id and args.tag_value):
utils.exit('Unable to update tag. Specify image_id and tag_value')
else:
gc.image_tags.update(args.image_id, args.tag_value)
image = gc.images.get(args.image_id)
image = [image]
columns = ['ID', 'Tags']
utils.print_list(image, columns)
@utils.arg('image_id', metavar='<IMAGE_ID>',
help='Image whose tag to be deleted')
@utils.arg('tag_value', metavar='<TAG_VALUE>',
help='Value of the tag')
def do_image_tag_delete(gc, args):
"""Delete the tag associated with the given image."""
if not (args.image_id and args.tag_value):
utils.exit('Unable to delete tag. Specify image_id and tag_value')
else:
gc.image_tags.delete(args.image_id, args.tag_value)