Heal non existent containers in docker
Change-Id: If2569baa3d47cb992d421f7756584a99d91b56a3 Partial-Implement: blueprint heal-non-existent-containers-in-docker
This commit is contained in:
@@ -168,6 +168,12 @@ class CreateContainer(command.ShowOne):
|
|||||||
metavar='<availability_zone>',
|
metavar='<availability_zone>',
|
||||||
default=None,
|
default=None,
|
||||||
help='The availability zone of the container.')
|
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
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
@@ -199,6 +205,7 @@ class CreateContainer(command.ShowOne):
|
|||||||
opts['hostname'] = parsed_args.hostname
|
opts['hostname'] = parsed_args.hostname
|
||||||
opts['disk'] = parsed_args.disk
|
opts['disk'] = parsed_args.disk
|
||||||
opts['availability_zone'] = parsed_args.availability_zone
|
opts['availability_zone'] = parsed_args.availability_zone
|
||||||
|
opts['auto_heal'] = parsed_args.auto_heal
|
||||||
|
|
||||||
opts = zun_utils.remove_null_parms(**opts)
|
opts = zun_utils.remove_null_parms(**opts)
|
||||||
container = client.containers.create(**opts)
|
container = client.containers.create(**opts)
|
||||||
@@ -734,6 +741,12 @@ class RunContainer(command.ShowOne):
|
|||||||
metavar='<availability_zone>',
|
metavar='<availability_zone>',
|
||||||
default=None,
|
default=None,
|
||||||
help='The availability zone of the container.')
|
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
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
@@ -765,6 +778,7 @@ class RunContainer(command.ShowOne):
|
|||||||
opts['hostname'] = parsed_args.hostname
|
opts['hostname'] = parsed_args.hostname
|
||||||
opts['disk'] = parsed_args.disk
|
opts['disk'] = parsed_args.disk
|
||||||
opts['availability_zone'] = parsed_args.availability_zone
|
opts['availability_zone'] = parsed_args.availability_zone
|
||||||
|
opts['auto_heal'] = parsed_args.auto_heal
|
||||||
|
|
||||||
opts = zun_utils.remove_null_parms(**opts)
|
opts = zun_utils.remove_null_parms(**opts)
|
||||||
container = client.containers.run(**opts)
|
container = client.containers.run(**opts)
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ CONTAINER1 = {'id': '1234',
|
|||||||
'runtime': 'runc',
|
'runtime': 'runc',
|
||||||
'hostname': 'testhost',
|
'hostname': 'testhost',
|
||||||
'disk': '20',
|
'disk': '20',
|
||||||
|
'auto_heal': False
|
||||||
}
|
}
|
||||||
|
|
||||||
CONTAINER2 = {'id': '1235',
|
CONTAINER2 = {'id': '1235',
|
||||||
@@ -54,7 +55,8 @@ CONTAINER2 = {'id': '1235',
|
|||||||
'security_groups': ['test'],
|
'security_groups': ['test'],
|
||||||
'auto_remove': False,
|
'auto_remove': False,
|
||||||
'runtime': 'runc',
|
'runtime': 'runc',
|
||||||
'hostname': 'testhost'
|
'hostname': 'testhost',
|
||||||
|
'auto_heal': False
|
||||||
}
|
}
|
||||||
|
|
||||||
CREATE_CONTAINER1 = copy.deepcopy(CONTAINER1)
|
CREATE_CONTAINER1 = copy.deepcopy(CONTAINER1)
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ from zunclient.v1 import containers_shell
|
|||||||
|
|
||||||
def _get_container_args(**kwargs):
|
def _get_container_args(**kwargs):
|
||||||
default_args = {
|
default_args = {
|
||||||
|
'auto_heal': False,
|
||||||
'auto_remove': False,
|
'auto_remove': False,
|
||||||
'environment': {},
|
'environment': {},
|
||||||
'hints': {},
|
'hints': {},
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ CREATION_ATTRIBUTES = ['name', 'image', 'command', 'cpu', 'memory',
|
|||||||
'restart_policy', 'interactive', 'image_driver',
|
'restart_policy', 'interactive', 'image_driver',
|
||||||
'security_groups', 'hints', 'nets', 'auto_remove',
|
'security_groups', 'hints', 'nets', 'auto_remove',
|
||||||
'runtime', 'hostname', 'mounts', 'disk',
|
'runtime', 'hostname', 'mounts', 'disk',
|
||||||
'availability_zone']
|
'availability_zone', 'auto_heal']
|
||||||
|
|
||||||
|
|
||||||
class Container(base.Resource):
|
class Container(base.Resource):
|
||||||
|
|||||||
@@ -133,6 +133,10 @@ def _show_container(container):
|
|||||||
metavar='<availability_zone>',
|
metavar='<availability_zone>',
|
||||||
default=None,
|
default=None,
|
||||||
help='The availability zone of the container.')
|
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):
|
def do_create(cs, args):
|
||||||
"""Create a container."""
|
"""Create a container."""
|
||||||
opts = {}
|
opts = {}
|
||||||
@@ -153,6 +157,7 @@ def do_create(cs, args):
|
|||||||
opts['hostname'] = args.hostname
|
opts['hostname'] = args.hostname
|
||||||
opts['disk'] = args.disk
|
opts['disk'] = args.disk
|
||||||
opts['availability_zone'] = args.availability_zone
|
opts['availability_zone'] = args.availability_zone
|
||||||
|
opts['auto_heal'] = args.auto_heal
|
||||||
|
|
||||||
if args.security_group:
|
if args.security_group:
|
||||||
opts['security_groups'] = args.security_group
|
opts['security_groups'] = args.security_group
|
||||||
@@ -559,6 +564,10 @@ def do_kill(cs, args):
|
|||||||
metavar='<availability_zone>',
|
metavar='<availability_zone>',
|
||||||
default=None,
|
default=None,
|
||||||
help='The availability zone of the container.')
|
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):
|
def do_run(cs, args):
|
||||||
"""Run a command in a new container."""
|
"""Run a command in a new container."""
|
||||||
opts = {}
|
opts = {}
|
||||||
@@ -579,6 +588,7 @@ def do_run(cs, args):
|
|||||||
opts['hostname'] = args.hostname
|
opts['hostname'] = args.hostname
|
||||||
opts['disk'] = args.disk
|
opts['disk'] = args.disk
|
||||||
opts['availability_zone'] = args.availability_zone
|
opts['availability_zone'] = args.availability_zone
|
||||||
|
opts['auto_heal'] = args.auto_heal
|
||||||
|
|
||||||
if args.security_group:
|
if args.security_group:
|
||||||
opts['security_groups'] = args.security_group
|
opts['security_groups'] = args.security_group
|
||||||
|
|||||||
Reference in New Issue
Block a user