From c0d368360831cd29affa47e77eba4e81e4c6f0f8 Mon Sep 17 00:00:00 2001 From: Spyros Trigazis Date: Wed, 2 Oct 2019 14:16:53 +0000 Subject: [PATCH] Allow cluster config for any cluster state Similar to what the certificates api does, it doesn't make sense to disallow cluster config. story: 2006651 task: 36891 Change-Id: Ia57e95e4570d04c2a20f7674d1ae3e21b8dd8efb Signed-off-by: Spyros Trigazis --- magnumclient/osc/v1/clusters.py | 8 ++++---- magnumclient/tests/osc/unit/v1/test_clusters.py | 12 ------------ magnumclient/tests/v1/test_bays_shell.py | 9 --------- magnumclient/tests/v1/test_clusters_shell.py | 11 ----------- magnumclient/v1/bays_shell.py | 4 ++-- magnumclient/v1/clusters_shell.py | 5 ++--- 6 files changed, 8 insertions(+), 41 deletions(-) diff --git a/magnumclient/osc/v1/clusters.py b/magnumclient/osc/v1/clusters.py index 16ae66db..3cf77d40 100644 --- a/magnumclient/osc/v1/clusters.py +++ b/magnumclient/osc/v1/clusters.py @@ -382,10 +382,10 @@ class ConfigCluster(command.Command): parsed_args.dir = os.path.abspath(parsed_args.dir) cluster = mag_client.clusters.get(parsed_args.cluster) - if cluster.status not in ('CREATE_COMPLETE', 'UPDATE_COMPLETE', - 'ROLLBACK_COMPLETE'): - raise exceptions.CommandError("cluster in status %s" % - cluster.status) + if cluster.api_address is None: + self.log.warning("WARNING: The cluster's api_address is" + " not known yet.") + cluster_template = mag_client.cluster_templates.get( cluster.cluster_template_id) opts = { diff --git a/magnumclient/tests/osc/unit/v1/test_clusters.py b/magnumclient/tests/osc/unit/v1/test_clusters.py index 4af65cb5..2530796d 100644 --- a/magnumclient/tests/osc/unit/v1/test_clusters.py +++ b/magnumclient/tests/osc/unit/v1/test_clusters.py @@ -468,18 +468,6 @@ export KUBECONFIG={}/config self.clusters_mock.get.assert_called_with('fake-cluster') - def test_cluster_config_with_in_progress_status(self): - self._cluster.status = 'CREATE_IN_PROGRESS' - - arglist = ['fake-cluster-1'] - verifylist = [ - ('cluster', 'fake-cluster-1') - ] - - parsed_args = self.check_parser(self.cmd, arglist, verifylist) - self.assertRaises(exceptions.CommandError, - self.cmd.take_action, parsed_args) - class TestClusterResize(TestCluster): diff --git a/magnumclient/tests/v1/test_bays_shell.py b/magnumclient/tests/v1/test_bays_shell.py index e9a3a47f..60f512ff 100644 --- a/magnumclient/tests/v1/test_bays_shell.py +++ b/magnumclient/tests/v1/test_bays_shell.py @@ -329,15 +329,6 @@ class ShellTest(shell_test_base.TestCommandLineArgument): self._test_arg_success('bay-config --dir /tmp --force xxx') mock_bay.assert_called_with('xxx') - @mock.patch('magnumclient.v1.baymodels.BayModelManager.get') - @mock.patch('magnumclient.v1.bays.BayManager.get') - def test_bay_config_failure_wrong_status(self, mock_bay, mock_baymodel): - mock_bay.return_value = FakeBay(status='CREATE_IN_PROGRESS') - self.assertRaises(exceptions.CommandError, - self._test_arg_failure, - 'bay-config xxx', - ['.*?^Bay in status: ']) - @mock.patch('magnumclient.v1.bays.BayManager.get') def test_bay_config_failure_no_arg(self, mock_bay): self._test_arg_failure('bay-config', self._few_argument_error) diff --git a/magnumclient/tests/v1/test_clusters_shell.py b/magnumclient/tests/v1/test_clusters_shell.py index 244132c2..43d81d14 100644 --- a/magnumclient/tests/v1/test_clusters_shell.py +++ b/magnumclient/tests/v1/test_clusters_shell.py @@ -447,17 +447,6 @@ class ShellTest(shell_test_base.TestCommandLineArgument): self._test_arg_success('cluster-config --dir /tmp --force xxx') mock_cluster.assert_called_with('xxx') - @mock.patch('magnumclient.v1.cluster_templates.ClusterTemplateManager.get') - @mock.patch('magnumclient.v1.clusters.ClusterManager.get') - def test_cluster_config_failure_wrong_status(self, - mock_cluster, - mock_clustertemplate): - mock_cluster.return_value = FakeCluster(status='CREATE_IN_PROGRESS') - self.assertRaises(exceptions.CommandError, - self._test_arg_failure, - 'cluster-config xxx', - ['.*?^Cluster in status: ']) - @mock.patch('magnumclient.v1.clusters.ClusterManager.get') def test_cluster_config_failure_no_arg(self, mock_cluster): self._test_arg_failure('cluster-config', self._few_argument_error) diff --git a/magnumclient/v1/bays_shell.py b/magnumclient/v1/bays_shell.py index 689e84ff..d2c865fe 100644 --- a/magnumclient/v1/bays_shell.py +++ b/magnumclient/v1/bays_shell.py @@ -228,8 +228,8 @@ def do_bay_config(cs, args): """ args.dir = os.path.abspath(args.dir) bay = cs.bays.get(args.bay) - if bay.status not in ('CREATE_COMPLETE', 'UPDATE_COMPLETE'): - raise exceptions.CommandError("Bay in status %s" % bay.status) + if (hasattr(bay, 'api_address') and bay.api_address is None): + print("WARNING: The bay's api_address is not known yet.") baymodel = cs.baymodels.get(bay.baymodel_id) opts = { 'cluster_uuid': bay.uuid, diff --git a/magnumclient/v1/clusters_shell.py b/magnumclient/v1/clusters_shell.py index 81e77e7d..e46b3f94 100644 --- a/magnumclient/v1/clusters_shell.py +++ b/magnumclient/v1/clusters_shell.py @@ -262,9 +262,8 @@ def do_cluster_config(cs, args): """ args.dir = os.path.abspath(args.dir) cluster = cs.clusters.get(args.cluster) - if cluster.status not in ('CREATE_COMPLETE', 'UPDATE_COMPLETE', - 'ROLLBACK_COMPLETE'): - raise exceptions.CommandError("cluster in status %s" % cluster.status) + if (hasattr(cluster, 'api_address') and cluster.api_address is None): + print("WARNING: The cluster's api_address is not known yet.") cluster_template = cs.cluster_templates.get(cluster.cluster_template_id) opts = { 'cluster_uuid': cluster.uuid,