summaryrefslogtreecommitdiff
path: root/openstackclient/compute/v2
diff options
context:
space:
mode:
authortianhui <tianhui@awcloud.com>2018-07-06 08:23:06 +0000
committerStephen Finucane <sfinucan@redhat.com>2020-10-09 17:31:14 +0100
commit1c7fe3b6bd60aa22ae525d0418729590f6429e96 (patch)
tree3fb48d0e1f0116ef37f5df858a5ccc7c1f79ecb3 /openstackclient/compute/v2
parent960004dcc733e88841d372e160b9e43669796c80 (diff)
downloadpython-openstackclient-1c7fe3b6bd60aa22ae525d0418729590f6429e96.tar.gz
Compute: Add tag support for server add volume
Change-Id: Id9f2e09426f6824e9ca672bf7808b5165c650a69 Story: 2002195 Task: 21675
Diffstat (limited to 'openstackclient/compute/v2')
-rw-r--r--openstackclient/compute/v2/server.py64
1 files changed, 43 insertions, 21 deletions
diff --git a/openstackclient/compute/v2/server.py b/openstackclient/compute/v2/server.py
index 06bbb7ee..0b1209f4 100644
--- a/openstackclient/compute/v2/server.py
+++ b/openstackclient/compute/v2/server.py
@@ -460,20 +460,32 @@ class AddServerVolume(command.Command):
metavar='<device>',
help=_('Server internal device name for volume'),
)
+ parser.add_argument(
+ '--tag',
+ metavar='<tag>',
+ help=_(
+ "Tag for the attached volume. "
+ "(Supported by API versions '2.49' - '2.latest')"
+ ),
+ )
termination_group = parser.add_mutually_exclusive_group()
termination_group.add_argument(
'--enable-delete-on-termination',
action='store_true',
- help=_("Specify if the attached volume should be deleted when "
- "the server is destroyed. (Supported with "
- "``--os-compute-api-version`` 2.79 or greater.)"),
+ help=_(
+ "Specify if the attached volume should be deleted when the "
+ "server is destroyed. "
+ "(Supported by API versions '2.79' - '2.latest')"
+ ),
)
termination_group.add_argument(
'--disable-delete-on-termination',
action='store_true',
- help=_("Specify if the attached volume should not be deleted "
- "when the server is destroyed. (Supported with "
- "``--os-compute-api-version`` 2.79 or greater.)"),
+ help=_(
+ "Specify if the attached volume should not be deleted when "
+ "the server is destroyed. "
+ "(Supported by API versions '2.79' - '2.latest')"
+ ),
)
return parser
@@ -490,28 +502,38 @@ class AddServerVolume(command.Command):
parsed_args.volume,
)
- support_set_delete_on_termination = (compute_client.api_version >=
- api_versions.APIVersion('2.79'))
-
- if not support_set_delete_on_termination:
- if parsed_args.enable_delete_on_termination:
- msg = _('--os-compute-api-version 2.79 or greater '
- 'is required to support the '
- '--enable-delete-on-termination option.')
- raise exceptions.CommandError(msg)
- if parsed_args.disable_delete_on_termination:
- msg = _('--os-compute-api-version 2.79 or greater '
- 'is required to support the '
- '--disable-delete-on-termination option.')
- raise exceptions.CommandError(msg)
-
kwargs = {
"device": parsed_args.device
}
+ if parsed_args.tag:
+ if compute_client.api_version < api_versions.APIVersion('2.49'):
+ msg = _(
+ '--os-compute-api-version 2.49 or greater is required to '
+ 'support the --tag option'
+ )
+ raise exceptions.CommandError(msg)
+
+ kwargs['tag'] = parsed_args.tag
+
if parsed_args.enable_delete_on_termination:
+ if compute_client.api_version < api_versions.APIVersion('2.79'):
+ msg = _(
+ '--os-compute-api-version 2.79 or greater is required to '
+ 'support the --enable-delete-on-termination option.'
+ )
+ raise exceptions.CommandError(msg)
+
kwargs['delete_on_termination'] = True
+
if parsed_args.disable_delete_on_termination:
+ if compute_client.api_version < api_versions.APIVersion('2.79'):
+ msg = _(
+ '--os-compute-api-version 2.79 or greater is required to '
+ 'support the --disable-delete-on-termination option.'
+ )
+ raise exceptions.CommandError(msg)
+
kwargs['delete_on_termination'] = False
compute_client.volumes.create_server_volume(