diff options
| author | Huanxuan Ao <huanxuan.ao@easystack.cn> | 2017-01-15 14:37:49 +0800 |
|---|---|---|
| committer | Huanxuan Ao <huanxuan.ao@easystack.cn> | 2017-01-15 20:00:53 +0800 |
| commit | 0340275fa9b48cda5a5f4015534ca8cbca23b3d2 (patch) | |
| tree | ace9fe0de450309fd2ffc15cbd00a4bf267c726f /openstackclient/common | |
| parent | b860ba0e42b942a1a5fb01b55d35a2edf062bf65 (diff) | |
| download | python-openstackclient-0340275fa9b48cda5a5f4015534ca8cbca23b3d2.tar.gz | |
Fix quota set command error for SDK > 0.9.10
A bug in OpenStack SDK 0.9.11 and 0.9.12 that causes
quota set command to fail. This can be removed when
the proposed SDK fix (https://review.openstack.org/#/c/419911/)
is released and in the minimum SDK version in global requirements.
Closes-Bug: #1655445
Change-Id: I63132f5f762f0120282f8b92e72512763063e3c6
Diffstat (limited to 'openstackclient/common')
| -rw-r--r-- | openstackclient/common/quota.py | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/openstackclient/common/quota.py b/openstackclient/common/quota.py index fa6c5765..d86aec58 100644 --- a/openstackclient/common/quota.py +++ b/openstackclient/common/quota.py @@ -182,9 +182,36 @@ class SetQuota(command.Command): project, **volume_kwargs) if network_kwargs: - network_client.update_quota( - project, - **network_kwargs) + if hasattr(_quota.Quota, 'allow_get'): + # TODO(huanxuan): Remove this block once the fixed + # SDK Quota class is the minimum required version. + # This is expected to be SDK release 0.9.13 + res = network_client._get_resource( + _quota.Quota, project, **network_kwargs) + if any([res._body.dirty, res._header.dirty]): + request = res._prepare_request(prepend_key=True) + # remove the id in the body + if 'id' in request.body[res.resource_key]: + del request.body[res.resource_key]['id'] + if res.patch_update: + response = network_client.session.patch( + request.uri, + endpoint_filter=res.service, + json=request.body, + headers=request.headers + ) + else: + response = network_client.session.put( + request.uri, + endpoint_filter=res.service, + json=request.body, + headers=request.headers + ) + res._translate_response(response, has_body=True) + else: + network_client.update_quota( + project, + **network_kwargs) class ShowQuota(command.ShowOne): |
