summaryrefslogtreecommitdiff
path: root/openstackclient/volume
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-01-26 06:38:31 +0000
committerGerrit Code Review <review@openstack.org>2017-01-26 06:38:31 +0000
commitda2a820d2f4e5589671f494edcd8e8b3e69b7cb0 (patch)
tree741b3f26bfc312ddcc546da63a306984ad6462d2 /openstackclient/volume
parentd189e807fdfc7222b18844a56db2e43412f49abb (diff)
parent26d50be79a401322f4e74b94c066257ddf0f287c (diff)
downloadpython-openstackclient-da2a820d2f4e5589671f494edcd8e8b3e69b7cb0.tar.gz
Merge "Support "--no-property" option in volume snapshot set"
Diffstat (limited to 'openstackclient/volume')
-rw-r--r--openstackclient/volume/v1/volume_snapshot.py20
-rw-r--r--openstackclient/volume/v2/volume_snapshot.py20
2 files changed, 40 insertions, 0 deletions
diff --git a/openstackclient/volume/v1/volume_snapshot.py b/openstackclient/volume/v1/volume_snapshot.py
index 45bd30c0..f22c338b 100644
--- a/openstackclient/volume/v1/volume_snapshot.py
+++ b/openstackclient/volume/v1/volume_snapshot.py
@@ -240,6 +240,15 @@ class SetVolumeSnapshot(command.Command):
help=_('New snapshot description')
)
parser.add_argument(
+ "--no-property",
+ dest="no_property",
+ action="store_true",
+ help=_("Remove all properties from <snapshot> "
+ "(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,
@@ -254,6 +263,17 @@ class SetVolumeSnapshot(command.Command):
parsed_args.snapshot)
result = 0
+ if parsed_args.no_property:
+ try:
+ key_list = snapshot.metadata.keys()
+ volume_client.volume_snapshots.delete_metadata(
+ snapshot.id,
+ list(key_list),
+ )
+ except Exception as e:
+ LOG.error(_("Failed to clean snapshot properties: %s"), e)
+ result += 1
+
if parsed_args.property:
try:
volume_client.volume_snapshots.set_metadata(
diff --git a/openstackclient/volume/v2/volume_snapshot.py b/openstackclient/volume/v2/volume_snapshot.py
index 3283bb53..f12cfed9 100644
--- a/openstackclient/volume/v2/volume_snapshot.py
+++ b/openstackclient/volume/v2/volume_snapshot.py
@@ -306,6 +306,15 @@ class SetVolumeSnapshot(command.Command):
help=_('New snapshot description')
)
parser.add_argument(
+ "--no-property",
+ dest="no_property",
+ action="store_true",
+ help=_("Remove all properties from <snapshot> "
+ "(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,
@@ -331,6 +340,17 @@ class SetVolumeSnapshot(command.Command):
parsed_args.snapshot)
result = 0
+ if parsed_args.no_property:
+ try:
+ key_list = snapshot.metadata.keys()
+ volume_client.volume_snapshots.delete_metadata(
+ snapshot.id,
+ list(key_list),
+ )
+ except Exception as e:
+ LOG.error(_("Failed to clean snapshot properties: %s"), e)
+ result += 1
+
if parsed_args.property:
try:
volume_client.volume_snapshots.set_metadata(