Merge "Allow zun exec to take arbitrary number of arguments"

This commit is contained in:
Jenkins 2017-01-24 04:08:03 +00:00 committed by Gerrit Code Review
commit a172d5977b
2 changed files with 6 additions and 2 deletions

View File

@ -10,6 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import argparse
import logging
from osc_lib.command import command
@ -337,13 +338,14 @@ class ExecContainer(command.Command):
parser.add_argument(
'command',
metavar='<command>',
nargs=argparse.REMAINDER,
help='The command to execute.')
return parser
def take_action(self, parsed_args):
client = _get_client(self, parsed_args)
container = parsed_args.container
command = getattr(parsed_args, 'command')
command = ' '.join(parsed_args.command)
output = client.containers.execute(container, command)
print(output)

View File

@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import argparse
import json
from zunclient.common import cliutils as utils
@ -293,10 +294,11 @@ def do_logs(cs, args):
help='ID or name of the container to execute command in.')
@utils.arg('command',
metavar='<command>',
nargs=argparse.REMAINDER,
help='The command to execute in a container')
def do_exec(cs, args):
"""Execute command in a container."""
output = cs.containers.execute(args.container, args.command)
output = cs.containers.execute(args.container, ' '.join(args.command))
print(output)