summaryrefslogtreecommitdiff
path: root/openstackclient/volume
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2019-03-06 00:58:17 +0000
committerGerrit Code Review <review@openstack.org>2019-03-06 00:58:17 +0000
commit303cb4735d99fdc93e88a599b76016e75264d09a (patch)
treeef6b21ecd85751392d74f017a1cfd6fa004c93b1 /openstackclient/volume
parent3599ebe9333e618028c5ae2946e42a10fdb3621f (diff)
parente776a4f0260af1d2ae66439e647794395d470578 (diff)
downloadpython-openstackclient-303cb4735d99fdc93e88a599b76016e75264d09a.tar.gz
Merge "Add --attached / --detached parameter to volume set"
Diffstat (limited to 'openstackclient/volume')
-rw-r--r--openstackclient/volume/v2/volume.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/openstackclient/volume/v2/volume.py b/openstackclient/volume/v2/volume.py
index 14a454c2..fa587b5f 100644
--- a/openstackclient/volume/v2/volume.py
+++ b/openstackclient/volume/v2/volume.py
@@ -559,6 +559,25 @@ class SetVolume(command.Command):
'in the database with no regard to actual status, '
'exercise caution when using)'),
)
+ attached_group = parser.add_mutually_exclusive_group()
+ attached_group.add_argument(
+ "--attached",
+ action="store_true",
+ help=_('Set volume attachment status to "attached" '
+ '(admin only) '
+ '(This option simply changes the state of the volume '
+ 'in the database with no regard to actual status, '
+ 'exercise caution when using)'),
+ )
+ attached_group.add_argument(
+ "--detached",
+ action="store_true",
+ help=_('Set volume attachment status to "detached" '
+ '(admin only) '
+ '(This option simply changes the state of the volume '
+ 'in the database with no regard to actual status, '
+ 'exercise caution when using)'),
+ )
parser.add_argument(
'--type',
metavar='<volume-type>',
@@ -645,6 +664,22 @@ class SetVolume(command.Command):
except Exception as e:
LOG.error(_("Failed to set volume state: %s"), e)
result += 1
+ if parsed_args.attached:
+ try:
+ volume_client.volumes.reset_state(
+ volume.id, state=None,
+ attach_status="attached")
+ except Exception as e:
+ LOG.error(_("Failed to set volume attach-status: %s"), e)
+ result += 1
+ if parsed_args.detached:
+ try:
+ volume_client.volumes.reset_state(
+ volume.id, state=None,
+ attach_status="detached")
+ except Exception as e:
+ LOG.error(_("Failed to set volume attach-status: %s"), e)
+ result += 1
if parsed_args.bootable or parsed_args.non_bootable:
try:
volume_client.volumes.set_bootable(