Add image delete to zunclient OSC

Change-Id: Ic51e865c628e09447d2f1e1dfde407b0a7eee97e
This commit is contained in:
caishan
2018-03-14 08:34:55 -07:00
parent e625e07d4b
commit 1f95e1e3e4
2 changed files with 26 additions and 0 deletions

View File

@@ -56,6 +56,7 @@ openstack.container.v1 =
appcontainer_stats = zunclient.osc.v1.containers:StatsContainer
appcontainer_commit = zunclient.osc.v1.containers:CommitContainer
appcontainer_add_security_group = zunclient.osc.v1.containers:AddSecurityGroup
appcontainer_image_delete = zunclient.osc.v1.images:DeleteImage
appcontainer_image_list = zunclient.osc.v1.images:ListImage
appcontainer_image_pull = zunclient.osc.v1.images:PullImage
appcontainer_host_list = zunclient.osc.v1.hosts:ListHost

View File

@@ -147,3 +147,28 @@ class ShowImage(command.ShowOne):
image = client.images.get(**opts)
columns = _image_columns(image)
return columns, utils.get_item_properties(image, columns)
class DeleteImage(command.Command):
"""Delete specified image"""
log = logging.getlogger(__name__ + ".DeleteImage")
def get_parser(self, prog_name):
parser = super(DeleteImage, self).get_parser(prog_name)
parser.add_argument(
'uuid',
metavar='<uuid>',
help='UUID of image to describe')
return parser
def take_action(self, parsed_args):
client = _get_client(self, parsed_args)
img_id = parsed_args.uuid
try:
client.images.delete(img_id)
print(_('Request to delete image %s has been accepted.')
% img_id)
except Exception as e:
print("Delete for image %(image)s failed: %(e)s" %
{'image': img_id, 'e': e})