diff --git a/zunclient/v1/containers.py b/zunclient/v1/containers.py index 77ef96dc..670a8d4e 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'] + 'restart_policy', 'tty', 'stdin_open'] class Container(base.Resource): diff --git a/zunclient/v1/containers_shell.py b/zunclient/v1/containers_shell.py index 74c051b6..971b9c79 100644 --- a/zunclient/v1/containers_shell.py +++ b/zunclient/v1/containers_shell.py @@ -97,6 +97,16 @@ def _check_restart_policy(policy): metavar='', help='Restart policy to apply when a container exits' '(no, on-failure[:max-retry], always, unless-stopped)') +@utils.arg('-t', '--tty', + dest='tty', + action='store_true', + default=False, + help='Allocate a pseudo-TTY') +@utils.arg('-i', '--interactive', + dest='stdin_open', + action='store_true', + default=False, + help='Keep STDIN open even if not attached') def do_create(cs, args): """Create a container.""" opts = {} @@ -111,6 +121,10 @@ def do_create(cs, args): opts['image_pull_policy'] = args.image_pull_policy if args.restart: opts['restart_policy'] = _check_restart_policy(args.restart) + if args.tty: + opts['tty'] = True + if args.stdin_open: + opts['stdin_open'] = True _show_container(cs.containers.create(**opts)) @@ -350,6 +364,16 @@ def do_kill(cs, args): metavar='', help='Restart policy to apply when a container exits' '(no, on-failure[:max-retry], always, unless-stopped)') +@utils.arg('-t', '--tty', + dest='tty', + action='store_true', + default=False, + help='Allocate a pseudo-TTY') +@utils.arg('-i', '--interactive', + dest='stdin_open', + action='store_true', + default=False, + help='Keep STDIN open even if not attached') def do_run(cs, args): """Run a command in a new container""" opts = {} @@ -364,6 +388,10 @@ def do_run(cs, args): opts['image_pull_policy'] = args.image_pull_policy if args.restart: opts['restart_policy'] = _check_restart_policy(args.restart) + if args.tty: + opts['tty'] = True + if args.stdin_open: + opts['stdin_open'] = True _show_container(cs.containers.run(**opts))