Merge "Remove None valued network quota entries"
This commit is contained in:
commit
30828112cf
@ -161,6 +161,13 @@ class BaseQuota(object):
|
|||||||
raise
|
raise
|
||||||
return quota._info
|
return quota._info
|
||||||
|
|
||||||
|
def _network_quota_to_dict(self, network_quota):
|
||||||
|
if type(network_quota) is not dict:
|
||||||
|
dict_quota = network_quota.to_dict()
|
||||||
|
else:
|
||||||
|
dict_quota = network_quota
|
||||||
|
return {k: v for k, v in dict_quota.items() if v is not None}
|
||||||
|
|
||||||
def get_network_quota(self, parsed_args):
|
def get_network_quota(self, parsed_args):
|
||||||
quota_class = (
|
quota_class = (
|
||||||
parsed_args.quota_class if 'quota_class' in parsed_args else False)
|
parsed_args.quota_class if 'quota_class' in parsed_args else False)
|
||||||
@ -174,13 +181,11 @@ class BaseQuota(object):
|
|||||||
client = self.app.client_manager.network
|
client = self.app.client_manager.network
|
||||||
if default:
|
if default:
|
||||||
network_quota = client.get_quota_default(project)
|
network_quota = client.get_quota_default(project)
|
||||||
if type(network_quota) is not dict:
|
network_quota = self._network_quota_to_dict(network_quota)
|
||||||
network_quota = network_quota.to_dict()
|
|
||||||
else:
|
else:
|
||||||
network_quota = client.get_quota(project,
|
network_quota = client.get_quota(project,
|
||||||
details=detail)
|
details=detail)
|
||||||
if type(network_quota) is not dict:
|
network_quota = self._network_quota_to_dict(network_quota)
|
||||||
network_quota = network_quota.to_dict()
|
|
||||||
if detail:
|
if detail:
|
||||||
# NOTE(slaweq): Neutron returns values with key "used" but
|
# NOTE(slaweq): Neutron returns values with key "used" but
|
||||||
# Nova for example returns same data with key "in_use"
|
# Nova for example returns same data with key "in_use"
|
||||||
|
@ -1087,3 +1087,26 @@ class TestQuotaShow(TestQuota):
|
|||||||
identity_fakes.project_id, details=False
|
identity_fakes.project_id, details=False
|
||||||
)
|
)
|
||||||
self.assertNotCalled(self.network.get_quota_default)
|
self.assertNotCalled(self.network.get_quota_default)
|
||||||
|
|
||||||
|
def test_network_quota_show_remove_empty(self):
|
||||||
|
arglist = [
|
||||||
|
self.projects[0].name,
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('project', self.projects[0].name),
|
||||||
|
]
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
# First check that all regular values are returned
|
||||||
|
result = self.cmd.get_network_quota(parsed_args)
|
||||||
|
self.assertEqual(len(network_fakes.QUOTA), len(result))
|
||||||
|
|
||||||
|
# set 1 of the values to None, and verify it is not returned
|
||||||
|
orig_get_quota = self.network.get_quota
|
||||||
|
network_quotas = copy.copy(network_fakes.QUOTA)
|
||||||
|
network_quotas['healthmonitor'] = None
|
||||||
|
self.network.get_quota = mock.Mock(return_value=network_quotas)
|
||||||
|
result = self.cmd.get_network_quota(parsed_args)
|
||||||
|
self.assertEqual(len(network_fakes.QUOTA) - 1, len(result))
|
||||||
|
# Go back to default mock
|
||||||
|
self.network.get_quota = orig_get_quota
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
other:
|
||||||
|
- |
|
||||||
|
Remove deprecated neutron-lbaas results from ``quota show`` command.
|
Loading…
x
Reference in New Issue
Block a user