From 84916acf84652835f80e9aa492f13b40b127adf7 Mon Sep 17 00:00:00 2001 From: yanyanhu Date: Mon, 13 Jun 2016 04:32:16 -0400 Subject: [PATCH] Fix openstack cluster resize User should be allowed to resize cluster without changing its size. This patch removes incorrect constraint defined in openstack cluster resize implementation. Change-Id: I7592f76d23a583bcc696a86dc75ada41be6b0f9d --- senlinclient/tests/unit/v1/test_cluster.py | 18 ++++++++++++------ senlinclient/v1/cluster.py | 5 ----- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/senlinclient/tests/unit/v1/test_cluster.py b/senlinclient/tests/unit/v1/test_cluster.py index 6495ea06..bb741df4 100644 --- a/senlinclient/tests/unit/v1/test_cluster.py +++ b/senlinclient/tests/unit/v1/test_cluster.py @@ -425,14 +425,20 @@ class TestClusterResize(TestCluster): self.assertEqual("Only one of 'capacity', 'adjustment' " "and 'percentage' can be specified.", str(error)) - def test_cluster_resize_none_params(self): + def test_cluster_resize_only_constraints(self): arglist = ['--min-size', '1', '--max-size', '20', 'my_cluster'] parsed_args = self.check_parser(self.cmd, arglist, []) - error = self.assertRaises(exc.CommandError, - self.cmd.take_action, - parsed_args) - self.assertEqual("At least one of 'capacity', 'adjustment' and " - "'percentage' should be specified.", str(error)) + self.cmd.take_action(parsed_args) + kwargs = { + 'min_size': 1, + 'max_size': 20, + 'adjustment_type': None, + 'min_step': None, + 'number': None, + 'strict': False + } + self.mock_client.cluster_resize.assert_called_with('my_cluster', + **kwargs) def test_cluster_resize_capacity(self): arglist = ['--capacity', '2', '--min-size', '1', '--max-size', '20', diff --git a/senlinclient/v1/cluster.py b/senlinclient/v1/cluster.py index ebb0a6dc..3ceef5f4 100644 --- a/senlinclient/v1/cluster.py +++ b/senlinclient/v1/cluster.py @@ -405,11 +405,6 @@ class ResizeCluster(command.Command): raise exc.CommandError(_("Only one of 'capacity', 'adjustment' and" " 'percentage' can be specified.")) - if sum(v is None for v in (capacity, adjustment, percentage)) == 3: - raise exc.CommandError(_("At least one of 'capacity', " - "'adjustment' and 'percentage' " - "should be specified.")) - action_args['adjustment_type'] = None action_args['number'] = None