Merge "Change container execute top return"
This commit is contained in:
commit
520ad0b4ff
@ -865,17 +865,22 @@ class TopContainer(command.Command):
|
||||
metavar='<container>',
|
||||
help='ID or name of the container to display processes.')
|
||||
parser.add_argument(
|
||||
'ps_args',
|
||||
metavar='<ps_args>',
|
||||
nargs=argparse.REMAINDER,
|
||||
help='The args of the ps command.')
|
||||
'--pid',
|
||||
metavar='<pid>',
|
||||
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']:
|
||||
|
@ -735,13 +735,19 @@ def do_attach(cs, args):
|
||||
@utils.arg('container',
|
||||
metavar='<container>',
|
||||
help='ID or name of the container to display processes.')
|
||||
@utils.arg('ps_args',
|
||||
metavar='<ps_args>',
|
||||
nargs=argparse.REMAINDER,
|
||||
help='The args of the ps command.')
|
||||
@utils.arg('--pid',
|
||||
metavar='<pid>',
|
||||
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']:
|
||||
|
Loading…
x
Reference in New Issue
Block a user