From c09366627f34ba125c530230c99feeb93327111d Mon Sep 17 00:00:00 2001 From: Feng Shengqin Date: Wed, 19 Apr 2017 14:03:19 +0800 Subject: [PATCH] Combine tty and stdin_open in server side Change-Id: Ie51ebded052ca64da826358cb2c02edc69e10e39 Closes-Bug: #1683951 --- zunclient/osc/v1/containers.py | 16 +++++++--------- zunclient/v1/containers.py | 2 +- zunclient/v1/containers_shell.py | 16 +++++++--------- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/zunclient/osc/v1/containers.py b/zunclient/osc/v1/containers.py index 963786df..717e1345 100644 --- a/zunclient/osc/v1/containers.py +++ b/zunclient/osc/v1/containers.py @@ -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) diff --git a/zunclient/v1/containers.py b/zunclient/v1/containers.py index 61b3b32f..6feb1307 100644 --- a/zunclient/v1/containers.py +++ b/zunclient/v1/containers.py @@ -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): diff --git a/zunclient/v1/containers_shell.py b/zunclient/v1/containers_shell.py index 3a16a720..9660be14 100644 --- a/zunclient/v1/containers_shell.py +++ b/zunclient/v1/containers_shell.py @@ -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)