summaryrefslogtreecommitdiff
path: root/openstackclient/common
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2020-12-01 13:51:20 +0000
committerGerrit Code Review <review@openstack.org>2020-12-01 13:51:20 +0000
commit30828112cf2aec63657b1565cfeddc83a0fdba81 (patch)
tree816c8cc03072b1d9826f5c27501b41e6a4b6c451 /openstackclient/common
parentc7a43773c94367e457310a9b3127ba93ee5d1419 (diff)
parente9bd4ef007153e4f2e2d69f3bcb94eef8e8983c2 (diff)
downloadpython-openstackclient-30828112cf2aec63657b1565cfeddc83a0fdba81.tar.gz
Merge "Remove None valued network quota entries"
Diffstat (limited to 'openstackclient/common')
-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"