diff options
| author | xiexs <xiexs@cn.fujitsu.com> | 2015-11-04 10:22:39 -0500 |
|---|---|---|
| committer | xiexs <xiexs@cn.fujitsu.com> | 2015-11-04 10:22:46 -0500 |
| commit | 7d8bb331a0ab516aaa3721b9b200a388214a22cb (patch) | |
| tree | d36f2c465e4ee90e6c2c4baa7588018d9dc059e0 /openstackclient/common | |
| parent | 266ecf57f508b7dab2e005aecff9dc66bb81a6d1 (diff) | |
| download | python-openstackclient-7d8bb331a0ab516aaa3721b9b200a388214a22cb.tar.gz | |
Add project-name/-id validation for the OSC "openstack quota set"
The quota info would be set into DB, even though the project actually
does not exist.
This patch tried to add a validation to forbid this undesirable behavior.
Change-Id: Ia2d8c96527820e25b074e6486d3f39c5ad7eae60
Closes-Bug: #1512638
Diffstat (limited to 'openstackclient/common')
| -rw-r--r-- | openstackclient/common/quota.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/openstackclient/common/quota.py b/openstackclient/common/quota.py index e092feff..b5d4eb87 100644 --- a/openstackclient/common/quota.py +++ b/openstackclient/common/quota.py @@ -94,6 +94,7 @@ class SetQuota(command.Command): @utils.log_method(log) def take_action(self, parsed_args): + identity_client = self.app.client_manager.identity compute_client = self.app.client_manager.compute volume_client = self.app.client_manager.volume @@ -115,23 +116,29 @@ class SetQuota(command.Command): sys.stderr.write("No quotas updated") return + if parsed_args.project: + project = utils.find_resource( + identity_client.projects, + parsed_args.project, + ) + if parsed_args.quota_class: if compute_kwargs: compute_client.quota_classes.update( - parsed_args.project, + project.id, **compute_kwargs) if volume_kwargs: volume_client.quota_classes.update( - parsed_args.project, + project.id, **volume_kwargs) else: if compute_kwargs: compute_client.quotas.update( - parsed_args.project, + project.id, **compute_kwargs) if volume_kwargs: volume_client.quotas.update( - parsed_args.project, + project.id, **volume_kwargs) |
