diff options
| author | Zuul <zuul@review.opendev.org> | 2022-07-06 00:34:31 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2022-07-06 00:34:31 +0000 |
| commit | cb1de327d9a4c5506e5681d9f6581b8195c3f904 (patch) | |
| tree | 154a363d85108613cdd0bb84bf89eca3e4760de0 /openstackclient/common | |
| parent | b559122bc67688e4cf80782fb884f33e0bec3762 (diff) | |
| parent | dd06a4c475a1813dc72bf439bfdcb47deec89049 (diff) | |
| download | python-openstackclient-stable/victoria.tar.gz | |
Merge "Remove None valued network quota entries" into stable/victoriastable/victoria
Diffstat (limited to 'openstackclient/common')
| -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 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" |
