diff options
| author | Rui Chen <chenrui.momo@gmail.com> | 2016-07-11 09:55:22 +0800 |
|---|---|---|
| committer | Rui Chen <chenrui.momo@gmail.com> | 2016-09-13 17:23:22 +0800 |
| commit | 6f326acd260d035cb024f0c5e3ef2237277d8b37 (patch) | |
| tree | 7bd0696e6069eee7f3be06338c0d04a02469ee26 | |
| parent | 320ed017749f6a7ffba8d11a1d415fd869bfecb0 (diff) | |
| download | python-openstackclient-6f326acd260d035cb024f0c5e3ef2237277d8b37.tar.gz | |
Support fetching network project default quota
Neutron server and openstacksdk had supported to fetch
network project default quota, this patch add the CLI
support in openstackclient.
Change-Id: If0ef74c268c41a866c62156da0603a40ae4e6e31
Closes-Bug: #1204956
Depends-On: I6a4e2a146351dd1e7d652442511f1ef2c279da42
| -rw-r--r-- | openstackclient/common/quota.py | 9 | ||||
| -rw-r--r-- | openstackclient/tests/functional/common/test_quota.py | 11 | ||||
| -rw-r--r-- | openstackclient/tests/unit/common/test_quota.py | 9 | ||||
| -rw-r--r-- | releasenotes/notes/bug-1204956-af47c7f34ecc19c3.yaml | 5 |
4 files changed, 32 insertions, 2 deletions
diff --git a/openstackclient/common/quota.py b/openstackclient/common/quota.py index 8ae6f7d4..aabfa5d5 100644 --- a/openstackclient/common/quota.py +++ b/openstackclient/common/quota.py @@ -247,11 +247,16 @@ class ShowQuota(command.ShowOne): return quota._info def get_network_quota(self, parsed_args): - if parsed_args.quota_class or parsed_args.default: + if parsed_args.quota_class: return {} if self.app.client_manager.is_network_endpoint_enabled(): project = self._get_project(parsed_args) - return self.app.client_manager.network.get_quota(project) + client = self.app.client_manager.network + if parsed_args.default: + network_quota = client.get_quota_default(project) + else: + network_quota = client.get_quota(project) + return network_quota else: return {} diff --git a/openstackclient/tests/functional/common/test_quota.py b/openstackclient/tests/functional/common/test_quota.py index fd45be38..9687cdb0 100644 --- a/openstackclient/tests/functional/common/test_quota.py +++ b/openstackclient/tests/functional/common/test_quota.py @@ -17,6 +17,7 @@ class QuotaTests(base.TestCase): """Functional tests for quota. """ # Test quota information for compute, network and volume. EXPECTED_FIELDS = ['instances', 'networks', 'volumes'] + EXPECTED_CLASS_FIELDS = ['instances', 'volumes'] PROJECT_NAME = None @classmethod @@ -40,3 +41,13 @@ class QuotaTests(base.TestCase): raw_output = self.openstack('quota show') for expected_field in self.EXPECTED_FIELDS: self.assertIn(expected_field, raw_output) + + def test_quota_show_with_default_option(self): + raw_output = self.openstack('quota show --default') + for expected_field in self.EXPECTED_FIELDS: + self.assertIn(expected_field, raw_output) + + def test_quota_show_with_class_option(self): + raw_output = self.openstack('quota show --class') + for expected_field in self.EXPECTED_CLASS_FIELDS: + self.assertIn(expected_field, raw_output) diff --git a/openstackclient/tests/unit/common/test_quota.py b/openstackclient/tests/unit/common/test_quota.py index cbe4cb80..ac03cb60 100644 --- a/openstackclient/tests/unit/common/test_quota.py +++ b/openstackclient/tests/unit/common/test_quota.py @@ -383,6 +383,8 @@ class TestQuotaShow(TestQuota): ) self.network = self.app.client_manager.network self.network.get_quota = mock.Mock(return_value=network_fakes.QUOTA) + self.network.get_quota_default = mock.Mock( + return_value=network_fakes.QUOTA) self.cmd = quota.ShowQuota(self.app, None) @@ -403,6 +405,7 @@ class TestQuotaShow(TestQuota): identity_fakes.project_id) self.network.get_quota.assert_called_once_with( identity_fakes.project_id) + self.assertNotCalled(self.network.get_quota_default) def test_quota_show_with_default(self): arglist = [ @@ -422,6 +425,9 @@ class TestQuotaShow(TestQuota): identity_fakes.project_id) self.volume_quotas_mock.defaults.assert_called_once_with( identity_fakes.project_id) + self.network.get_quota_default.assert_called_once_with( + identity_fakes.project_id) + self.assertNotCalled(self.network.get_quota) def test_quota_show_with_class(self): arglist = [ @@ -441,6 +447,8 @@ class TestQuotaShow(TestQuota): identity_fakes.project_id) self.volume_quotas_class_mock.get.assert_called_once_with( identity_fakes.project_id) + self.assertNotCalled(self.network.get_quota) + self.assertNotCalled(self.network.get_quota_default) def test_quota_show_no_project(self): parsed_args = self.check_parser(self.cmd, [], []) @@ -452,3 +460,4 @@ class TestQuotaShow(TestQuota): identity_fakes.project_id) self.network.get_quota.assert_called_once_with( identity_fakes.project_id) + self.assertNotCalled(self.network.get_quota_default) diff --git a/releasenotes/notes/bug-1204956-af47c7f34ecc19c3.yaml b/releasenotes/notes/bug-1204956-af47c7f34ecc19c3.yaml new file mode 100644 index 00000000..65def078 --- /dev/null +++ b/releasenotes/notes/bug-1204956-af47c7f34ecc19c3.yaml @@ -0,0 +1,5 @@ +--- +features: + - Supported to fetch network project default quota with command + ``quota show --default``. + [Bug `1204956 <https://bugs.launchpad.net/neutron/+bug/1204956>`_] |
