Merge "Multiple args for object and container commands"
This commit is contained in:
commit
2306059c8e
@ -27,7 +27,7 @@ from openstackclient.common import utils
|
|||||||
from openstackclient.object.v1.lib import container as lib_container
|
from openstackclient.object.v1.lib import container as lib_container
|
||||||
|
|
||||||
|
|
||||||
class CreateContainer(show.ShowOne):
|
class CreateContainer(lister.Lister):
|
||||||
"""Create a container"""
|
"""Create a container"""
|
||||||
|
|
||||||
log = logging.getLogger(__name__ + '.CreateContainer')
|
log = logging.getLogger(__name__ + '.CreateContainer')
|
||||||
@ -35,22 +35,31 @@ class CreateContainer(show.ShowOne):
|
|||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
parser = super(CreateContainer, self).get_parser(prog_name)
|
parser = super(CreateContainer, self).get_parser(prog_name)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'container',
|
'containers',
|
||||||
metavar='<container>',
|
metavar='<container>',
|
||||||
help='New container name',
|
nargs="+",
|
||||||
|
help='Container name(s) to create',
|
||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('take_action(%s)', parsed_args)
|
self.log.debug('take_action(%s)', parsed_args)
|
||||||
|
|
||||||
data = lib_container.create_container(
|
results = []
|
||||||
self.app.client_manager.session,
|
for container in parsed_args.containers:
|
||||||
self.app.client_manager.object_store.endpoint,
|
data = lib_container.create_container(
|
||||||
parsed_args.container,
|
self.app.client_manager.session,
|
||||||
)
|
self.app.client_manager.object_store.endpoint,
|
||||||
|
container,
|
||||||
|
)
|
||||||
|
results.append(data)
|
||||||
|
|
||||||
return zip(*sorted(six.iteritems(data)))
|
columns = ("account", "container", "x-trans-id")
|
||||||
|
return (columns,
|
||||||
|
(utils.get_dict_properties(
|
||||||
|
s, columns,
|
||||||
|
formatters={},
|
||||||
|
) for s in results))
|
||||||
|
|
||||||
|
|
||||||
class DeleteContainer(command.Command):
|
class DeleteContainer(command.Command):
|
||||||
@ -61,20 +70,22 @@ class DeleteContainer(command.Command):
|
|||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
parser = super(DeleteContainer, self).get_parser(prog_name)
|
parser = super(DeleteContainer, self).get_parser(prog_name)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'container',
|
'containers',
|
||||||
metavar='<container>',
|
metavar='<container>',
|
||||||
help='Container name to delete',
|
nargs="+",
|
||||||
|
help='Container name(s) to delete',
|
||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('take_action(%s)', parsed_args)
|
self.log.debug('take_action(%s)', parsed_args)
|
||||||
|
|
||||||
lib_container.delete_container(
|
for container in parsed_args.containers:
|
||||||
self.app.client_manager.session,
|
lib_container.delete_container(
|
||||||
self.app.client_manager.object_store.endpoint,
|
self.app.client_manager.session,
|
||||||
parsed_args.container,
|
self.app.client_manager.object_store.endpoint,
|
||||||
)
|
container,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ListContainer(lister.Lister):
|
class ListContainer(lister.Lister):
|
||||||
|
@ -27,7 +27,7 @@ from openstackclient.common import utils
|
|||||||
from openstackclient.object.v1.lib import object as lib_object
|
from openstackclient.object.v1.lib import object as lib_object
|
||||||
|
|
||||||
|
|
||||||
class CreateObject(show.ShowOne):
|
class CreateObject(lister.Lister):
|
||||||
"""Upload an object to a container"""
|
"""Upload an object to a container"""
|
||||||
|
|
||||||
log = logging.getLogger(__name__ + '.CreateObject')
|
log = logging.getLogger(__name__ + '.CreateObject')
|
||||||
@ -40,23 +40,32 @@ class CreateObject(show.ShowOne):
|
|||||||
help='Container to store new object',
|
help='Container to store new object',
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'object',
|
'objects',
|
||||||
metavar='<object-name>',
|
metavar='<object-name>',
|
||||||
help='Local path of object to upload',
|
nargs="+",
|
||||||
|
help='Local path of object(s) to upload',
|
||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('take_action(%s)', parsed_args)
|
self.log.debug('take_action(%s)', parsed_args)
|
||||||
|
|
||||||
data = lib_object.create_object(
|
results = []
|
||||||
self.app.client_manager.session,
|
for obj in parsed_args.objects:
|
||||||
self.app.client_manager.object_store.endpoint,
|
data = lib_object.create_object(
|
||||||
parsed_args.container,
|
self.app.client_manager.session,
|
||||||
parsed_args.object,
|
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):
|
class DeleteObject(command.Command):
|
||||||
@ -72,21 +81,24 @@ class DeleteObject(command.Command):
|
|||||||
help='Container that stores the object to delete',
|
help='Container that stores the object to delete',
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'object',
|
'objects',
|
||||||
metavar='<object-name>',
|
metavar='<object-name>',
|
||||||
help='Object to delete',
|
nargs="+",
|
||||||
|
help='Object(s) to delete',
|
||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('take_action(%s)', parsed_args)
|
self.log.debug('take_action(%s)', parsed_args)
|
||||||
|
|
||||||
lib_object.delete_object(
|
for obj in parsed_args.objects:
|
||||||
self.app.client_manager.session,
|
lib_object.delete_object(
|
||||||
self.app.client_manager.object_store.endpoint,
|
self.app.restapi,
|
||||||
parsed_args.container,
|
self.app.client_manager.session,
|
||||||
parsed_args.object,
|
self.app.client_manager.object_store.endpoint,
|
||||||
)
|
parsed_args.container,
|
||||||
|
obj,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ListObject(lister.Lister):
|
class ListObject(lister.Lister):
|
||||||
|
Loading…
Reference in New Issue
Block a user