diff --git a/zunclient/osc/v1/containers.py b/zunclient/osc/v1/containers.py index 313bc9cb..8c99533d 100644 --- a/zunclient/osc/v1/containers.py +++ b/zunclient/osc/v1/containers.py @@ -168,6 +168,12 @@ class CreateContainer(command.ShowOne): metavar='', default=None, help='The availability zone of the container.') + parser.add_argument( + '--auto-heal', + dest='auto_heal', + action='store_true', + default=False, + help='The flag of healing non-existent container in docker') return parser def take_action(self, parsed_args): @@ -199,6 +205,7 @@ class CreateContainer(command.ShowOne): opts['hostname'] = parsed_args.hostname opts['disk'] = parsed_args.disk opts['availability_zone'] = parsed_args.availability_zone + opts['auto_heal'] = parsed_args.auto_heal opts = zun_utils.remove_null_parms(**opts) container = client.containers.create(**opts) @@ -734,6 +741,12 @@ class RunContainer(command.ShowOne): metavar='', default=None, help='The availability zone of the container.') + parser.add_argument( + '--auto-heal', + dest='auto_heal', + action='store_true', + default=False, + help='The flag of healing non-existent container in docker') return parser def take_action(self, parsed_args): @@ -765,6 +778,7 @@ class RunContainer(command.ShowOne): opts['hostname'] = parsed_args.hostname opts['disk'] = parsed_args.disk opts['availability_zone'] = parsed_args.availability_zone + opts['auto_heal'] = parsed_args.auto_heal 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 e0f17746..3870cfb2 100644 --- a/zunclient/tests/unit/v1/test_containers.py +++ b/zunclient/tests/unit/v1/test_containers.py @@ -36,6 +36,7 @@ CONTAINER1 = {'id': '1234', 'runtime': 'runc', 'hostname': 'testhost', 'disk': '20', + 'auto_heal': False } CONTAINER2 = {'id': '1235', @@ -54,7 +55,8 @@ CONTAINER2 = {'id': '1235', 'security_groups': ['test'], 'auto_remove': False, 'runtime': 'runc', - 'hostname': 'testhost' + 'hostname': 'testhost', + 'auto_heal': False } CREATE_CONTAINER1 = copy.deepcopy(CONTAINER1) diff --git a/zunclient/tests/unit/v1/test_containers_shell.py b/zunclient/tests/unit/v1/test_containers_shell.py index 0f8af85c..cab39ad2 100644 --- a/zunclient/tests/unit/v1/test_containers_shell.py +++ b/zunclient/tests/unit/v1/test_containers_shell.py @@ -21,6 +21,7 @@ from zunclient.v1 import containers_shell def _get_container_args(**kwargs): default_args = { + 'auto_heal': False, 'auto_remove': False, 'environment': {}, 'hints': {}, diff --git a/zunclient/v1/containers.py b/zunclient/v1/containers.py index edb0d58f..aee7870f 100644 --- a/zunclient/v1/containers.py +++ b/zunclient/v1/containers.py @@ -24,7 +24,7 @@ CREATION_ATTRIBUTES = ['name', 'image', 'command', 'cpu', 'memory', 'restart_policy', 'interactive', 'image_driver', 'security_groups', 'hints', 'nets', 'auto_remove', 'runtime', 'hostname', 'mounts', 'disk', - 'availability_zone'] + 'availability_zone', 'auto_heal'] class Container(base.Resource): diff --git a/zunclient/v1/containers_shell.py b/zunclient/v1/containers_shell.py index f1197360..35c707cf 100644 --- a/zunclient/v1/containers_shell.py +++ b/zunclient/v1/containers_shell.py @@ -133,6 +133,10 @@ def _show_container(container): metavar='', default=None, help='The availability zone of the container.') +@utils.arg('--auto-heal', + action='store_true', + default=False, + help='The flag of healing non-existent container in docker.') def do_create(cs, args): """Create a container.""" opts = {} @@ -153,6 +157,7 @@ def do_create(cs, args): opts['hostname'] = args.hostname opts['disk'] = args.disk opts['availability_zone'] = args.availability_zone + opts['auto_heal'] = args.auto_heal if args.security_group: opts['security_groups'] = args.security_group @@ -559,6 +564,10 @@ def do_kill(cs, args): metavar='', default=None, help='The availability zone of the container.') +@utils.arg('--auto-heal', + action='store_true', + default=False, + help='The flag of healing non-existent container in docker.') def do_run(cs, args): """Run a command in a new container.""" opts = {} @@ -579,6 +588,7 @@ def do_run(cs, args): opts['hostname'] = args.hostname opts['disk'] = args.disk opts['availability_zone'] = args.availability_zone + opts['auto_heal'] = args.auto_heal if args.security_group: opts['security_groups'] = args.security_group