diff options
| author | asarfaty <asarfaty@vmware.com> | 2020-08-16 09:23:56 +0200 |
|---|---|---|
| committer | Adit Sarfaty <asarfaty@vmware.com> | 2021-02-17 04:55:31 +0000 |
| commit | b948e74b88befca67eab57573444e81f44eb75c9 (patch) | |
| tree | 39f68ef465d99f7c3d847414468825275b69c589 /openstackclient/common/quota.py | |
| parent | 54bf2c054d7b8287de5cb20dfbf03af0383c29c9 (diff) | |
| download | python-openstackclient-b948e74b88befca67eab57573444e81f44eb75c9.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
(cherry picked from commit e9bd4ef007153e4f2e2d69f3bcb94eef8e8983c2)
Diffstat (limited to 'openstackclient/common/quota.py')
| -rw-r--r-- | openstackclient/common/quota.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/openstackclient/common/quota.py b/openstackclient/common/quota.py index fb4e8603..314ff8b5 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" |
