Merge "Support profile-only to cluster update"

This commit is contained in:
Jenkins 2017-04-03 02:23:06 +00:00 committed by Gerrit Code Review
commit 39c943bb77
4 changed files with 24 additions and 0 deletions

View File

@ -263,6 +263,7 @@ class TestClusterUpdate(TestCluster):
},
"name": 'new_cluster',
"profile_id": 'new_profile',
"profile_only": False,
"timeout": "30"
}

View File

@ -988,6 +988,7 @@ class ShellTest(testtools.TestCase):
service = mock.Mock()
args = {
'profile': 'test_profile',
'profile_only': 'false',
'name': 'CLUSTER1',
'metadata': ['user=demo'],
'timeout': 100,
@ -995,6 +996,7 @@ class ShellTest(testtools.TestCase):
attrs = copy.deepcopy(args)
attrs['metadata'] = {'user': 'demo'}
attrs['profile_id'] = 'test_profile'
attrs['profile_only'] = False
del attrs['profile']
args = self._make_args(args)
args.id = 'CID'

View File

@ -234,6 +234,15 @@ class UpdateCluster(command.ShowOne):
metavar='<profile>',
help=_('ID or name of new profile to use')
)
parser.add_argument(
'--profile-only',
default=False, metavar='<boolean>',
help=_("Whether the cluster should be updated profile only. "
"If false, it will be applied to all existing nodes. "
"If true, any newly created nodes will use the new profile,"
"but existing nodes will not be changed. Default is False.")
)
parser.add_argument(
'--timeout',
metavar='<timeout>',
@ -270,6 +279,10 @@ class UpdateCluster(command.ShowOne):
attrs = {
'name': parsed_args.name,
'profile_id': parsed_args.profile,
'profile_only': strutils.bool_from_string(
parsed_args.profile_only,
strict=True,
),
'metadata': senlin_utils.format_parameters(parsed_args.metadata),
'timeout': parsed_args.timeout,
}

View File

@ -794,6 +794,11 @@ def do_cluster_run(service, args):
@utils.arg('-p', '--profile', metavar='<PROFILE>',
help=_('ID or name of new profile to use.'))
@utils.arg('-P', '--profile-only', metavar='<BOOLEAN>', default=False,
help=_("Whether the cluster should be updated profile only. "
"If false, it will be applied to all existing nodes. "
"If true, any newly created nodes will use the new profile, "
"but existing nodes will not be changed. Default is False."))
@utils.arg('-t', '--timeout', metavar='<TIMEOUT>',
help=_('New timeout (in seconds) value for the cluster.'))
@utils.arg('-M', '--metadata', metavar='<"KEY1=VALUE1;KEY2=VALUE2...">',
@ -813,6 +818,9 @@ def do_cluster_update(service, args):
attrs = {
'name': args.name,
'profile_id': args.profile,
'profile_only': strutils.bool_from_string(
args.profile_only, strict=True
),
'metadata': utils.format_parameters(args.metadata),
'timeout': args.timeout,
}