summaryrefslogtreecommitdiff
path: root/openstackclient/volume/v1
diff options
context:
space:
mode:
authorzhiyong.dai <zhiyong.dai@easystack.cn>2016-12-01 02:20:23 +0800
committerzhiyong.dai <zhiyong.dai@easystack.cn>2017-02-23 21:49:11 +0800
commit40ec7a9c96f4ce4071e47e5bf0c249aa77b5b2ee (patch)
treefa08254e4e9c9bc5c2b0ca12881feffad713ec68 /openstackclient/volume/v1
parent3b562ffa904ebb23396c2d6c7398a520cd535238 (diff)
downloadpython-openstackclient-40ec7a9c96f4ce4071e47e5bf0c249aa77b5b2ee.tar.gz
Support --no-property in "volume set" command
Add "--no-property" option to "volume set" command in v1 and v2 and update the test cases. Change-Id: Id5660f23b3b2d9aa72f4c16b19ce83f3f7ed2fa4
Diffstat (limited to 'openstackclient/volume/v1')
-rw-r--r--openstackclient/volume/v1/volume.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/openstackclient/volume/v1/volume.py b/openstackclient/volume/v1/volume.py
index 739484df..8e1097f5 100644
--- a/openstackclient/volume/v1/volume.py
+++ b/openstackclient/volume/v1/volume.py
@@ -440,6 +440,15 @@ class SetVolume(command.Command):
help=_('Extend volume size in GB'),
)
parser.add_argument(
+ "--no-property",
+ dest="no_property",
+ action="store_true",
+ help=_("Remove all properties from <volume> "
+ "(specify both --no-property and --property to "
+ "remove the current properties before setting "
+ "new properties.)"),
+ )
+ parser.add_argument(
'--property',
metavar='<key=value>',
action=parseractions.KeyValueAction,
@@ -489,6 +498,15 @@ class SetVolume(command.Command):
except Exception as e:
LOG.error(_("Failed to set volume size: %s"), e)
result += 1
+
+ if parsed_args.no_property:
+ try:
+ volume_client.volumes.delete_metadata(
+ volume.id, volume.metadata.keys())
+ except Exception as e:
+ LOG.error(_("Failed to clean volume properties: %s"), e)
+ result += 1
+
if parsed_args.property:
try:
volume_client.volumes.set_metadata(