Combine tty and stdin_open in server side
Change-Id: Ie51ebded052ca64da826358cb2c02edc69e10e39 Closes-Bug: #1683951
This commit is contained in:
parent
f48cbe14cc
commit
c09366627f
@ -102,7 +102,7 @@ class CreateContainer(command.ShowOne):
|
||||
'"glance": pull the image from Glance. ')
|
||||
parser.add_argument(
|
||||
'--interactive',
|
||||
dest='stdin_open',
|
||||
dest='interactive',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='Keep STDIN open even if not attached, allocate a pseudo-TTY')
|
||||
@ -130,9 +130,8 @@ class CreateContainer(command.ShowOne):
|
||||
if parsed_args.restart:
|
||||
opts['restart_policy'] = \
|
||||
zun_utils.check_restart_policy(parsed_args.restart)
|
||||
if parsed_args.stdin_open:
|
||||
opts['stdin_open'] = True
|
||||
opts['tty'] = True
|
||||
if parsed_args.interactive:
|
||||
opts['interactive'] = True
|
||||
|
||||
opts = zun_utils.remove_null_parms(**opts)
|
||||
container = client.containers.create(**opts)
|
||||
@ -567,7 +566,7 @@ class RunContainer(command.ShowOne):
|
||||
'"glance": pull the image from Glance. ')
|
||||
parser.add_argument(
|
||||
'--interactive',
|
||||
dest='stdin_open',
|
||||
dest='interactive',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='Keep STDIN open even if not attached, allocate a pseudo-TTY')
|
||||
@ -595,15 +594,14 @@ class RunContainer(command.ShowOne):
|
||||
if parsed_args.restart:
|
||||
opts['restart_policy'] = \
|
||||
zun_utils.check_restart_policy(parsed_args.restart)
|
||||
if parsed_args.stdin_open:
|
||||
opts['stdin_open'] = True
|
||||
opts['tty'] = True
|
||||
if parsed_args.interactive:
|
||||
opts['interactive'] = True
|
||||
|
||||
opts = zun_utils.remove_null_parms(**opts)
|
||||
container = client.containers.run(**opts)
|
||||
columns = _container_columns(container)
|
||||
container_uuid = getattr(container, 'uuid', None)
|
||||
if parsed_args.tty and parsed_args.stdin_open:
|
||||
if parsed_args.interactive:
|
||||
ready_for_attach = False
|
||||
while True:
|
||||
container = client.containers.get(container_uuid)
|
||||
|
@ -21,7 +21,7 @@ from zunclient import exceptions
|
||||
|
||||
CREATION_ATTRIBUTES = ['name', 'image', 'command', 'cpu', 'memory',
|
||||
'environment', 'workdir', 'labels', 'image_pull_policy',
|
||||
'restart_policy', 'tty', 'stdin_open', 'image_driver']
|
||||
'restart_policy', 'interactive', 'image_driver']
|
||||
|
||||
|
||||
class Container(base.Resource):
|
||||
|
@ -71,7 +71,7 @@ def _show_container(container):
|
||||
help='Restart policy to apply when a container exits'
|
||||
'(no, on-failure[:max-retry], always, unless-stopped)')
|
||||
@utils.arg('-i', '--interactive',
|
||||
dest='stdin_open',
|
||||
dest='interactive',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='Keep STDIN open even if not attached, allocate a pseudo-TTY')
|
||||
@ -101,9 +101,8 @@ def do_create(cs, args):
|
||||
opts['command'] = ' '.join(args.command)
|
||||
if args.restart:
|
||||
opts['restart_policy'] = zun_utils.check_restart_policy(args.restart)
|
||||
if args.stdin_open:
|
||||
opts['stdin_open'] = True
|
||||
opts['tty'] = True
|
||||
if args.interactive:
|
||||
opts['interactive'] = True
|
||||
opts = zun_utils.remove_null_parms(**opts)
|
||||
_show_container(cs.containers.create(**opts))
|
||||
|
||||
@ -387,7 +386,7 @@ def do_kill(cs, args):
|
||||
help='Restart policy to apply when a container exits'
|
||||
'(no, on-failure[:max-retry], always, unless-stopped)')
|
||||
@utils.arg('-i', '--interactive',
|
||||
dest='stdin_open',
|
||||
dest='interactive',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='Keep STDIN open even if not attached, allocate a pseudo-TTY')
|
||||
@ -417,14 +416,13 @@ def do_run(cs, args):
|
||||
opts['command'] = ' '.join(args.command)
|
||||
if args.restart:
|
||||
opts['restart_policy'] = zun_utils.check_restart_policy(args.restart)
|
||||
if args.stdin_open:
|
||||
opts['stdin_open'] = True
|
||||
opts['tty'] = True
|
||||
if args.interactive:
|
||||
opts['interactive'] = True
|
||||
opts = zun_utils.remove_null_parms(**opts)
|
||||
container = cs.containers.run(**opts)
|
||||
_show_container(container)
|
||||
container_uuid = getattr(container, 'uuid', None)
|
||||
if args.stdin_open:
|
||||
if args.interactive:
|
||||
ready_for_attach = False
|
||||
while True:
|
||||
container = cs.containers.get(container_uuid)
|
||||
|
Loading…
x
Reference in New Issue
Block a user