From 06b91c77128957d3fccccfb613dce2e989f868b3 Mon Sep 17 00:00:00 2001 From: chohoor Date: Tue, 21 Feb 2017 15:49:09 +0800 Subject: [PATCH] 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 --- senlinclient/tests/unit/v1/test_cluster.py | 1 + senlinclient/tests/unit/v1/test_shell.py | 2 ++ senlinclient/v1/cluster.py | 13 +++++++++++++ senlinclient/v1/shell.py | 8 ++++++++ 4 files changed, 24 insertions(+) diff --git a/senlinclient/tests/unit/v1/test_cluster.py b/senlinclient/tests/unit/v1/test_cluster.py index d2a5e53..7e6cd9c 100644 --- a/senlinclient/tests/unit/v1/test_cluster.py +++ b/senlinclient/tests/unit/v1/test_cluster.py @@ -263,6 +263,7 @@ class TestClusterUpdate(TestCluster): }, "name": 'new_cluster', "profile_id": 'new_profile', + "profile_only": False, "timeout": "30" } diff --git a/senlinclient/tests/unit/v1/test_shell.py b/senlinclient/tests/unit/v1/test_shell.py index 50c5964..8989dcc 100644 --- a/senlinclient/tests/unit/v1/test_shell.py +++ b/senlinclient/tests/unit/v1/test_shell.py @@ -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' diff --git a/senlinclient/v1/cluster.py b/senlinclient/v1/cluster.py index b576c52..91019fb 100644 --- a/senlinclient/v1/cluster.py +++ b/senlinclient/v1/cluster.py @@ -235,6 +235,15 @@ class UpdateCluster(command.ShowOne): metavar='', help=_('ID or name of new profile to use') ) + parser.add_argument( + '--profile-only', + default=False, metavar='', + 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='', @@ -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, } diff --git a/senlinclient/v1/shell.py b/senlinclient/v1/shell.py index a8b8462..0cc25aa 100644 --- a/senlinclient/v1/shell.py +++ b/senlinclient/v1/shell.py @@ -794,6 +794,11 @@ def do_cluster_run(service, args): @utils.arg('-p', '--profile', metavar='', help=_('ID or name of new profile to use.')) +@utils.arg('-P', '--profile-only', metavar='', 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='', 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, }