Return the exit code of the executed command
On the container exec command, return the same exit code of the command being executed in the container. This would be useful for users to retrieve the exit code as they did in Docker CLI. Change-Id: I2aa0b4d9e7994a125f54e93d36efc854db66fe25 Depends-On: I20cc48da20bdc3784ec8fce4e38a98baf388a0ca Closes-Bug: #1645044
This commit is contained in:
parent
4c8b9a6ed1
commit
e69ea37845
@ -386,8 +386,11 @@ class ExecContainer(command.Command):
|
||||
client = _get_client(self, parsed_args)
|
||||
container = parsed_args.container
|
||||
command = ' '.join(parsed_args.command)
|
||||
output = client.containers.execute(container, command)
|
||||
response = client.containers.execute(container, command)
|
||||
output = response['output']
|
||||
exit_code = response['exit_code']
|
||||
print(output)
|
||||
return exit_code
|
||||
|
||||
|
||||
class LogsContainer(command.Command):
|
||||
|
@ -573,7 +573,7 @@ class OpenStackZunShell(object):
|
||||
endpoint_type=endpoint_type,
|
||||
insecure=insecure)
|
||||
|
||||
args.func(self.cs, args)
|
||||
return args.func(self.cs, args)
|
||||
|
||||
def _dump_timings(self, timings):
|
||||
class Tyme(object):
|
||||
@ -631,8 +631,8 @@ class OpenStackHelpFormatter(argparse.HelpFormatter):
|
||||
|
||||
def main():
|
||||
try:
|
||||
OpenStackZunShell().main(map(encodeutils.safe_decode, sys.argv[1:]))
|
||||
|
||||
return OpenStackZunShell().main(
|
||||
map(encodeutils.safe_decode, sys.argv[1:]))
|
||||
except Exception as e:
|
||||
logger.debug(e, exc_info=1)
|
||||
print("ERROR: %s" % encodeutils.safe_encode(six.text_type(e)),
|
||||
@ -641,4 +641,4 @@ def main():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
sys.exit(main())
|
||||
|
@ -359,8 +359,11 @@ def do_logs(cs, args):
|
||||
help='The command to execute in a container')
|
||||
def do_exec(cs, args):
|
||||
"""Execute command in a container."""
|
||||
output = cs.containers.execute(args.container, ' '.join(args.command))
|
||||
response = cs.containers.execute(args.container, ' '.join(args.command))
|
||||
output = response['output']
|
||||
exit_code = response['exit_code']
|
||||
print(output)
|
||||
return exit_code
|
||||
|
||||
|
||||
@utils.arg('containers',
|
||||
|
Loading…
x
Reference in New Issue
Block a user