commit 00b1248ea57e87217588734eab78763baa019a11
Author: Stavros Sachtouris <saxtouri@admin.grnet.gr>
Date:   Mon Nov 18 18:56:01 2013 +0200

    Apply naming conventions to 1st level image cmds
    
    Refs: #4583

diff --git a/kamaki/cli/commands/image.py b/kamaki/cli/commands/image.py
index b028a6d..90e9e77 100644
--- a/kamaki/cli/commands/image.py
+++ b/kamaki/cli/commands/image.py
@@ -284,18 +284,8 @@ class image_list(_init_image, _optional_json, _name_filter, _id_filter):
 
 
 @command(image_cmds)
-class image_meta(_init_image):
-    """Manage image metadata and custom properties"""
-
-
-@command(image_cmds)
 class image_info(_init_image, _optional_json):
-    """Get image metadata
-    Image metadata include:
-    - image file information (location, size, etc.)
-    - image information (id, name, etc.)
-    - image os properties (os, fs, etc.)
-    """
+    """Get image metadata"""
 
     @errors.generic.all
     @errors.plankton.connection
@@ -312,47 +302,41 @@ class image_info(_init_image, _optional_json):
 
 
 @command(image_cmds)
-class image_meta_set(_init_image, _optional_output_cmd):
+class image_modify(_init_image, _optional_json):
     """Add / update metadata and properties for an image
     The original image preserves the values that are not affected
     """
 
     arguments = dict(
-        name=ValueArgument('Set a new name', ('--name')),
-        disk_format=ValueArgument('Set a new disk format', ('--disk-format')),
+        image_name=ValueArgument('Change name', '--name'),
+        disk_format=ValueArgument('Change disk format', '--disk-format'),
         container_format=ValueArgument(
-            'Set a new container format', ('--container-format')),
-        status=ValueArgument('Set a new status', ('--status')),
-        publish=FlagArgument('publish the image', ('--publish')),
-        unpublish=FlagArgument('unpublish the image', ('--unpublish')),
-        properties=KeyValueArgument(
+            'Change container format', '--container-format'),
+        status=ValueArgument('Change status', '--status'),
+        publish=FlagArgument('Publish the image', '--publish'),
+        unpublish=FlagArgument('Unpublish the image', '--unpublish'),
+        property_to_set=KeyValueArgument(
             'set property in key=value form (can be repeated)',
-            ('-p', '--property'))
+            ('-p', '--property-set')),
+        property_to_del=RepeatableArgument(
+            'Delete property by key (can be repeated)', '--property-del')
     )
-
-    def _check_empty(self):
-        for term in (
-                'name', 'disk_format', 'container_format', 'status', 'publish',
-                'unpublish', 'properties'):
-            if self[term]:
-                if self['publish'] and self['unpublish']:
-                    raiseCLIError(
-                        '--publish and --unpublish are mutually exclusive')
-                return
-        raiseCLIError(
-            'Nothing to update, please use arguments (-h for a list)')
+    required = [
+        'image_name', 'disk_format', 'container_format', 'status', 'publish',
+        'unpublish', 'property_to_set']
 
     @errors.generic.all
     @errors.plankton.connection
     @errors.plankton.id
     def _run(self, image_id):
-        self._check_empty()
         meta = self.client.get_meta(image_id)
-        for k, v in self['properties'].items():
+        for k, v in self['property_to_set'].items():
             meta['properties'][k.upper()] = v
+        for k in self['property_to_del']:
+            meta['properties'][k.upper()] = None
         self._optional_output(self.client.update_image(
             image_id,
-            name=self['name'],
+            name=self['image_name'],
             disk_format=self['disk_format'],
             container_format=self['container_format'],
             status=self['status'],
@@ -365,46 +349,6 @@ class image_meta_set(_init_image, _optional_output_cmd):
 
 
 @command(image_cmds)
-class image_meta_delete(_init_image, _optional_output_cmd):
-    """Remove/empty image metadata and/or custom properties"""
-
-    arguments = dict(
-        disk_format=FlagArgument('Empty disk format', ('--disk-format')),
-        container_format=FlagArgument(
-            'Empty container format', ('--container-format')),
-        status=FlagArgument('Empty status', ('--status')),
-        properties=RepeatableArgument(
-            'Property keys to remove', ('-p', '--property'))
-    )
-
-    def _check_empty(self):
-        for t in ('disk_format', 'container_format', 'status', 'properties'):
-            if self[t]:
-                return
-        raiseCLIError(
-            'Nothing to update, please use arguments (-h for a list)')
-
-    @errors.generic.all
-    @errors.plankton.connection
-    @errors.plankton.id
-    def _run(self, image_id):
-        self._check_empty()
-        meta = self.client.get_meta(image_id)
-        for k in self['properties']:
-            meta['properties'].pop(k.upper(), None)
-        self._optional_output(self.client.update_image(
-            image_id,
-            disk_format='' if self['disk_format'] else None,
-            container_format='' if self['container_format'] else None,
-            status='' if self['status'] else None,
-            **meta['properties']))
-
-    def main(self, image_id):
-        super(self.__class__, self)._run()
-        self._run(image_id=image_id)
-
-
-@command(image_cmds)
 class image_register(_init_image, _optional_json):
     """(Re)Register an image file to an Image service
     The image file must be stored at a pithos repository
