summaryrefslogtreecommitdiff
path: root/openstackclient/common/quota.py
diff options
context:
space:
mode:
authorasarfaty <asarfaty@vmware.com>2020-08-16 09:23:56 +0200
committerAdit Sarfaty <asarfaty@vmware.com>2020-09-22 05:12:09 +0000
commite9bd4ef007153e4f2e2d69f3bcb94eef8e8983c2 (patch)
treeecf172ce5a2c04479038373ac3bbd90b96f51264 /openstackclient/common/quota.py
parent51aee432d96c0291d01419c3db2248114d176fdd (diff)
downloadpython-openstackclient-e9bd4ef007153e4f2e2d69f3bcb94eef8e8983c2.tar.gz
Remove None valued network quota entries
Since the openstack SDK still has the neutron-lbaas entries in the network quota, but those are already deprecated [1], the 'opentack quota show' command shows those as None value. This fix removes those empty deprecated values from the output. [1] https://review.opendev.org/#/c/658494/ Change-Id: I8dbdba2a029ea8e6a268ddf29627e1466a7e3a8a
Diffstat (limited to 'openstackclient/common/quota.py')
-rw-r--r--openstackclient/common/quota.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/openstackclient/common/quota.py b/openstackclient/common/quota.py
index 11de986b..643cb4e4 100644
--- a/openstackclient/common/quota.py
+++ b/openstackclient/common/quota.py
@@ -161,6 +161,13 @@ class BaseQuota(object):
raise
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):
quota_class = (
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
if default:
network_quota = client.get_quota_default(project)
- if type(network_quota) is not dict:
- network_quota = network_quota.to_dict()
+ network_quota = self._network_quota_to_dict(network_quota)
else:
network_quota = client.get_quota(project,
details=detail)
- if type(network_quota) is not dict:
- network_quota = network_quota.to_dict()
+ network_quota = self._network_quota_to_dict(network_quota)
if detail:
# NOTE(slaweq): Neutron returns values with key "used" but
# Nova for example returns same data with key "in_use"