summaryrefslogtreecommitdiff
path: root/openstackclient/volume
diff options
context:
space:
mode:
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 af29b777..3c06fa5a 100644
--- a/openstackclient/volume/v2/volume_snapshot.py
+++ b/openstackclient/volume/v2/volume_snapshot.py
@@ -286,6 +286,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,
@@ -311,6 +320,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(