diff --git a/zunclient/osc/v1/containers.py b/zunclient/osc/v1/containers.py index c0de0ade..a44f3564 100644 --- a/zunclient/osc/v1/containers.py +++ b/zunclient/osc/v1/containers.py @@ -865,17 +865,22 @@ class TopContainer(command.Command): metavar='', help='ID or name of the container to display processes.') parser.add_argument( - 'ps_args', - metavar='', - nargs=argparse.REMAINDER, - help='The args of the ps command.') + '--pid', + metavar='', + action='append', default=[], + help='The args of the ps id.') return parser def take_action(self, parsed_args): client = _get_client(self, parsed_args) - container = parsed_args.container - ps = ' '.join(parsed_args.ps_args) - output = client.containers.top(container, ps) + if parsed_args.pid: + # List container single ps id top result + output = client.containers.top(parsed_args.container, + ' '.join(parsed_args.pid)) + else: + # List container all processes top result + output = client.containers.top(parsed_args.container) + for titles in output['Titles']: print("%-20s") % titles, if output['Processes']: diff --git a/zunclient/v1/containers_shell.py b/zunclient/v1/containers_shell.py index 65eddbde..0849c380 100644 --- a/zunclient/v1/containers_shell.py +++ b/zunclient/v1/containers_shell.py @@ -735,13 +735,19 @@ def do_attach(cs, args): @utils.arg('container', metavar='', help='ID or name of the container to display processes.') -@utils.arg('ps_args', - metavar='', - nargs=argparse.REMAINDER, - help='The args of the ps command.') +@utils.arg('--pid', + metavar='', + action='append', default=[], + help='The args of the ps id.') def do_top(cs, args): """Display the running processes inside the container.""" - output = cs.containers.top(args.container, ' '.join(args.ps_args)) + + if args.pid: + # List container single ps id top result + output = cs.containers.top(args.container, ' '.join(args.pid)) + else: + # List container all processes top result + output = cs.containers.top(args.container) for titles in output['Titles']: print("%-20s") % titles, for process in output['Processes']: