From f7745ff996c54fa7cf247ad7f709a37025658f70 Mon Sep 17 00:00:00 2001 From: Sergey Reshetnyak Date: Tue, 25 Oct 2016 16:13:29 +0300 Subject: [PATCH] Fix check cinder quotas This patch adds check that cinder endpoint exists in catalog when checking cinder quotas. Change-Id: I2faa39b2fa1e5648a9924980ca0b0384b14b4540 Closes-bug: #1636496 --- sahara/service/quotas.py | 3 ++- sahara/tests/unit/service/test_quotas.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/sahara/service/quotas.py b/sahara/service/quotas.py index 1c6d384c..563cfe45 100644 --- a/sahara/service/quotas.py +++ b/sahara/service/quotas.py @@ -126,7 +126,8 @@ def _get_avail_limits(): limits = _get_zero_limits() limits.update(_get_nova_limits()) limits.update(_get_neutron_limits()) - limits.update(_get_cinder_limits()) + if cinder_client.check_cinder_exists(): + limits.update(_get_cinder_limits()) return limits diff --git a/sahara/tests/unit/service/test_quotas.py b/sahara/tests/unit/service/test_quotas.py index af8684dd..7f58cbf0 100644 --- a/sahara/tests/unit/service/test_quotas.py +++ b/sahara/tests/unit/service/test_quotas.py @@ -246,13 +246,15 @@ class TestQuotas(base.SaharaTestCase): 'security_groups': 1516}, quotas._get_neutron_limits()) + @mock.patch("sahara.utils.openstack.cinder.check_cinder_exists", + return_value=True) @mock.patch('sahara.utils.openstack.nova.client', return_value=FakeNovaClient(nova_limits)) @mock.patch('sahara.utils.openstack.cinder.client', return_value=FakeCinderClient(cinder_limits)) @mock.patch('sahara.utils.openstack.neutron.client', return_value=FakeNeutronClient(neutron_limits)) - def test_limits_for_cluster(self, p1, p2, p3): + def test_limits_for_cluster(self, p1, p2, p3, p4): ng = [FakeNodeGroup(1, False, 0, 0, None, 'id1', [1, 2, 3])] quotas.check_cluster(FakeCluster(ng))