diff options
| author | Terry Howe <terrylhowe@gmail.com> | 2014-08-14 20:56:36 -0600 |
|---|---|---|
| committer | Terry Howe <terrylhowe@gmail.com> | 2014-09-06 16:23:55 -0600 |
| commit | b725b5017ad2bb6a1e52bb0c32e4c864e18d124b (patch) | |
| tree | cbb3bc425f20e824bc4a9eba62daeb6a8adf7994 /openstackclient/object/v1/object.py | |
| parent | dc9ce6d6081867137c91cee235bceaf35906bc87 (diff) | |
| download | python-openstackclient-b725b5017ad2bb6a1e52bb0c32e4c864e18d124b.tar.gz | |
Multiple args for object and container commands
Have object and container create and delete handle multiple
arguments.
Change-Id: I389358c13ac2d99655ca26e784e3d299286c0af3
Diffstat (limited to 'openstackclient/object/v1/object.py')
| -rw-r--r-- | openstackclient/object/v1/object.py | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/openstackclient/object/v1/object.py b/openstackclient/object/v1/object.py index 812ad6e1..f1da6be4 100644 --- a/openstackclient/object/v1/object.py +++ b/openstackclient/object/v1/object.py @@ -27,7 +27,7 @@ from openstackclient.common import utils from openstackclient.object.v1.lib import object as lib_object -class CreateObject(show.ShowOne): +class CreateObject(lister.Lister): """Upload an object to a container""" log = logging.getLogger(__name__ + '.CreateObject') @@ -40,23 +40,32 @@ class CreateObject(show.ShowOne): help='Container to store new object', ) parser.add_argument( - 'object', + 'objects', metavar='<object-name>', - help='Local path of object to upload', + nargs="+", + help='Local path of object(s) to upload', ) return parser def take_action(self, parsed_args): self.log.debug('take_action(%s)', parsed_args) - data = lib_object.create_object( - self.app.client_manager.session, - self.app.client_manager.object_store.endpoint, - parsed_args.container, - parsed_args.object, - ) + results = [] + for obj in parsed_args.objects: + data = lib_object.create_object( + self.app.client_manager.session, + self.app.client_manager.object_store.endpoint, + parsed_args.container, + obj, + ) + results.append(data) - return zip(*sorted(six.iteritems(data))) + columns = ("object", "container", "etag") + return (columns, + (utils.get_dict_properties( + s, columns, + formatters={}, + ) for s in results)) class DeleteObject(command.Command): @@ -72,21 +81,24 @@ class DeleteObject(command.Command): help='Container that stores the object to delete', ) parser.add_argument( - 'object', + 'objects', metavar='<object-name>', - help='Object to delete', + nargs="+", + help='Object(s) to delete', ) return parser def take_action(self, parsed_args): self.log.debug('take_action(%s)', parsed_args) - lib_object.delete_object( - self.app.client_manager.session, - self.app.client_manager.object_store.endpoint, - parsed_args.container, - parsed_args.object, - ) + for obj in parsed_args.objects: + lib_object.delete_object( + self.app.restapi, + self.app.client_manager.session, + self.app.client_manager.object_store.endpoint, + parsed_args.container, + obj, + ) class ListObject(lister.Lister): |
