diff options
| author | zhiyong.dai <zhiyong.dai@easystack.cn> | 2017-01-02 17:55:32 +0800 |
|---|---|---|
| committer | Dean Troyer <dtroyer@gmail.com> | 2017-01-25 17:32:58 -0600 |
| commit | 26d50be79a401322f4e74b94c066257ddf0f287c (patch) | |
| tree | aeae1d1b5d451458e806b7a32ee4816c14afa17a /openstackclient/volume/v1 | |
| parent | d5745eaaa79491728da656baee0451b861723cce (diff) | |
| download | python-openstackclient-26d50be79a401322f4e74b94c066257ddf0f287c.tar.gz | |
Support "--no-property" option in volume snapshot set
Supporting "--no-property" option will apply user a convenient
way to clean all properties of volume snapshot in a short command,
and this kind of behavior is the recommended way to devref.
The patch adds "--no-property" option in "volume snapshot set" command,
and update related test cases and devref document.
Change-Id: I5f10cc2b5814553699920c4343995b2e11416e4e
Implements: blueprint allow-overwrite-set-options
Diffstat (limited to 'openstackclient/volume/v1')
| -rw-r--r-- | openstackclient/volume/v1/volume_snapshot.py | 20 |
1 files changed, 20 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( |
