Support profile-only to cluster update

This path revises cluster-update command.
The command could support 'profile-only' parameter.
partial-blueprint: add-profile-only-to-cluster-update

Change-Id: Ibf2e4d67abe76b92a508a3e22e5c528d53cde5a4
Signed-off-by: chohoor <chohoor@gmail.com>
This commit is contained in:
chohoor 2017-02-21 15:49:09 +08:00
parent b1aed80475
commit 06b91c7712
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

@ -235,6 +235,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>',
@ -271,6 +280,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,
}