diff --git a/zunclient/osc/v1/containers.py b/zunclient/osc/v1/containers.py index 4b7a061b..fb6dfe66 100644 --- a/zunclient/osc/v1/containers.py +++ b/zunclient/osc/v1/containers.py @@ -158,8 +158,13 @@ class CreateContainer(command.ShowOne): parser.add_argument( '--hostname', metavar='', - help='Container host name' - ) + help='Container host name') + parser.add_argument( + '--disk', + metavar='', + type=int, + default=None, + help='The disk size in GiB for per container.') return parser def take_action(self, parsed_args): @@ -189,6 +194,7 @@ class CreateContainer(command.ShowOne): opts['mounts'] = zun_utils.parse_mounts(parsed_args.mount) opts['runtime'] = parsed_args.runtime opts['hostname'] = parsed_args.hostname + opts['disk'] = parsed_args.disk opts = zun_utils.remove_null_parms(**opts) container = client.containers.create(**opts) @@ -713,8 +719,13 @@ class RunContainer(command.ShowOne): parser.add_argument( '--hostname', metavar='', - help='Container host name' - ) + help='Container host name') + parser.add_argument( + '--disk', + metavar='', + type=int, + default=None, + help='The disk size in GiB for per container.') return parser def take_action(self, parsed_args): @@ -744,6 +755,7 @@ class RunContainer(command.ShowOne): opts['mounts'] = zun_utils.parse_mounts(parsed_args.mount) opts['runtime'] = parsed_args.runtime opts['hostname'] = parsed_args.hostname + opts['disk'] = parsed_args.disk opts = zun_utils.remove_null_parms(**opts) container = client.containers.run(**opts) diff --git a/zunclient/tests/unit/v1/test_containers.py b/zunclient/tests/unit/v1/test_containers.py index 7853f0ec..6bac6954 100644 --- a/zunclient/tests/unit/v1/test_containers.py +++ b/zunclient/tests/unit/v1/test_containers.py @@ -35,6 +35,7 @@ CONTAINER1 = {'id': '1234', 'auto_remove': True, 'runtime': 'runc', 'hostname': 'testhost', + 'disk': '20', } CONTAINER2 = {'id': '1235', diff --git a/zunclient/v1/containers.py b/zunclient/v1/containers.py index ee0bddfc..21d67053 100644 --- a/zunclient/v1/containers.py +++ b/zunclient/v1/containers.py @@ -23,7 +23,7 @@ CREATION_ATTRIBUTES = ['name', 'image', 'command', 'cpu', 'memory', 'environment', 'workdir', 'labels', 'image_pull_policy', 'restart_policy', 'interactive', 'image_driver', 'security_groups', 'hints', 'nets', 'auto_remove', - 'runtime', 'hostname', 'mounts'] + 'runtime', 'hostname', 'mounts', 'disk'] class Container(base.Resource): diff --git a/zunclient/v1/containers_shell.py b/zunclient/v1/containers_shell.py index f632e92d..7e446e4d 100644 --- a/zunclient/v1/containers_shell.py +++ b/zunclient/v1/containers_shell.py @@ -126,6 +126,11 @@ def _show_container(container): metavar='', default=None, help='Container host name') +@utils.arg('--disk', + metavar='', + type=int, + default=None, + help='The disk size in GiB for per container.') def do_create(cs, args): """Create a container.""" opts = {} @@ -144,6 +149,7 @@ def do_create(cs, args): opts['mounts'] = zun_utils.parse_mounts(args.mount) opts['runtime'] = args.runtime opts['hostname'] = args.hostname + opts['disk'] = args.disk if args.security_group: opts['security_groups'] = args.security_group @@ -527,6 +533,11 @@ def do_kill(cs, args): metavar='', default=None, help='Container hostname') +@utils.arg('--disk', + metavar='', + type=int, + default=None, + help='The disk size in GiB for per container.') def do_run(cs, args): """Run a command in a new container.""" opts = {} @@ -545,6 +556,7 @@ def do_run(cs, args): opts['mounts'] = zun_utils.parse_mounts(args.mount) opts['runtime'] = args.runtime opts['hostname'] = args.hostname + opts['disk'] = args.disk if args.security_group: opts['security_groups'] = args.security_group