From e9bd4ef007153e4f2e2d69f3bcb94eef8e8983c2 Mon Sep 17 00:00:00 2001 From: asarfaty Date: Sun, 16 Aug 2020 09:23:56 +0200 Subject: 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 --- openstackclient/common/quota.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'openstackclient/common') 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" -- cgit v1.2.1