diff --git a/zunclient/osc/v1/containers.py b/zunclient/osc/v1/containers.py index 442f2a45..37f823e6 100644 --- a/zunclient/osc/v1/containers.py +++ b/zunclient/osc/v1/containers.py @@ -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): diff --git a/zunclient/shell.py b/zunclient/shell.py index a5b4ea4e..38a2fb10 100644 --- a/zunclient/shell.py +++ b/zunclient/shell.py @@ -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()) diff --git a/zunclient/v1/containers_shell.py b/zunclient/v1/containers_shell.py index 38bd0944..2d111931 100644 --- a/zunclient/v1/containers_shell.py +++ b/zunclient/v1/containers_shell.py @@ -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',