Merge "Support to update auto_heal of container"

This commit is contained in:
Zuul
2018-08-05 15:50:37 +00:00
committed by Gerrit Code Review
2 changed files with 29 additions and 1 deletions

View File

@@ -914,7 +914,17 @@ class UpdateContainer(command.ShowOne):
'--name',
metavar='<name>',
help='The new name of container to update')
auto_heal_value = parser.add_mutually_exclusive_group()
auto_heal_value.add_argument(
'--auto-heal',
required=False,
action='store_true',
help='Automatic recovery the status of contaier')
auto_heal_value.add_argument(
'--no-auto-heal',
required=False,
action='store_true',
help='Needless recovery the status of contaier')
return parser
def take_action(self, parsed_args):
@@ -924,6 +934,10 @@ class UpdateContainer(command.ShowOne):
opts['memory'] = parsed_args.memory
opts['cpu'] = parsed_args.cpu
opts['name'] = parsed_args.name
if 'auto_heal' in parsed_args and parsed_args.auto_heal:
opts['auto_heal'] = True
if 'no_auto_heal' in parsed_args and parsed_args.no_auto_heal:
opts['auto_heal'] = False
opts = zun_utils.remove_null_parms(**opts)
if not opts:
raise exc.CommandError("You must update at least one property")

View File

@@ -698,12 +698,26 @@ def do_run(cs, args):
@utils.arg('--name',
metavar='<name>',
help='The new name for the container')
@utils.exclusive_arg(
'auto_heal_value',
'--auto-heal',
required=False, action='store_true',
help='Automatic recovery the status of contaier')
@utils.exclusive_arg(
'auto_heal_value',
'--no-auto-heal',
required=False, action='store_true',
help='Needless recovery the status of contaier')
def do_update(cs, args):
"""Update one or more attributes of the container."""
opts = {}
opts['memory'] = args.memory
opts['cpu'] = args.cpu
opts['name'] = args.name
if 'auto_heal' in args and args.auto_heal:
opts['auto_heal'] = True
if 'no_auto_heal' in args and args.no_auto_heal:
opts['auto_heal'] = False
opts = zun_utils.remove_null_parms(**opts)
if not opts:
raise exc.CommandError("You must update at least one property")