Add the parameter interactive in ExecContainer
Change-Id: I050c8273975da97c4b8f673be9636963d0b9533c
This commit is contained in:
@@ -399,17 +399,32 @@ class ExecContainer(command.Command):
|
|||||||
metavar='<command>',
|
metavar='<command>',
|
||||||
nargs=argparse.REMAINDER,
|
nargs=argparse.REMAINDER,
|
||||||
help='The command to execute.')
|
help='The command to execute.')
|
||||||
|
parser.add_argument(
|
||||||
|
'--interactive',
|
||||||
|
dest='interactive',
|
||||||
|
action='store_true',
|
||||||
|
default=False,
|
||||||
|
help='Keep STDIN open and allocate a pseudo-TTY for interactive')
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
client = _get_client(self, parsed_args)
|
client = _get_client(self, parsed_args)
|
||||||
container = parsed_args.container
|
container = parsed_args.container
|
||||||
command = zun_utils.parse_command(parsed_args.command)
|
opts = {}
|
||||||
response = client.containers.execute(container, command=command)
|
opts['command'] = zun_utils.parse_command(parsed_args.command)
|
||||||
output = response['output']
|
if parsed_args.interactive:
|
||||||
exit_code = response['exit_code']
|
opts['interactive'] = True
|
||||||
print(output)
|
opts['run'] = False
|
||||||
return exit_code
|
response = client.containers.execute(container, **opts)
|
||||||
|
if parsed_args.interactive:
|
||||||
|
exec_id = response['exec_id']
|
||||||
|
url = response['url']
|
||||||
|
websocketclient.do_exec(client, url, container, exec_id, "~", 0.5)
|
||||||
|
else:
|
||||||
|
output = response['output']
|
||||||
|
exit_code = response['exit_code']
|
||||||
|
print(output)
|
||||||
|
return exit_code
|
||||||
|
|
||||||
|
|
||||||
class LogsContainer(command.Command):
|
class LogsContainer(command.Command):
|
||||||
|
Reference in New Issue
Block a user