summaryrefslogtreecommitdiff
path: root/openstackclient/volume
diff options
context:
space:
mode:
authorHuanxuan Ao <huanxuan.ao@easystack.cn>2016-09-06 15:15:01 +0800
committerHuanxuan Ao <huanxuan.ao@easystack.cn>2016-09-11 11:00:09 +0800
commitcb6c11b0a87ba99e01eff52204b2406e8517aeaa (patch)
tree15e2a7890ca3d692b9c361da1a9b68650c8852de /openstackclient/volume
parent676a0e9696ba7550132e4501bdbf3160608faed6 (diff)
downloadpython-openstackclient-cb6c11b0a87ba99e01eff52204b2406e8517aeaa.tar.gz
Multi REST API calls error handling of "volume unset" command
Support multi REST API calls error handling for "volume unset" command follow the rule in doc/source/command-errors.rst. Also add a unit test for testing the error handling Change-Id: I2de7a7bd5a7a5e39817ed5cf6952abf4afba75e4
Diffstat (limited to 'openstackclient/volume')
-rw-r--r--openstackclient/volume/v2/volume.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/openstackclient/volume/v2/volume.py b/openstackclient/volume/v2/volume.py
index bd201e00..0f85b5d4 100644
--- a/openstackclient/volume/v2/volume.py
+++ b/openstackclient/volume/v2/volume.py
@@ -511,9 +511,23 @@ class UnsetVolume(command.Command):
volume = utils.find_resource(
volume_client.volumes, parsed_args.volume)
+ result = 0
if parsed_args.property:
- volume_client.volumes.delete_metadata(
- volume.id, parsed_args.property)
+ try:
+ volume_client.volumes.delete_metadata(
+ volume.id, parsed_args.property)
+ except Exception as e:
+ LOG.error(_("Failed to unset volume property: %s"), e)
+ result += 1
+
if parsed_args.image_property:
- volume_client.volumes.delete_image_metadata(
- volume.id, parsed_args.image_property)
+ try:
+ volume_client.volumes.delete_image_metadata(
+ volume.id, parsed_args.image_property)
+ except Exception as e:
+ LOG.error(_("Failed to unset image property: %s"), e)
+ result += 1
+
+ if result > 0:
+ raise exceptions.CommandError(_("One or more of the "
+ "unset operations failed"))