summaryrefslogtreecommitdiff
path: root/openstackclient/compute
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2020-10-14 03:46:06 +0000
committerGerrit Code Review <review@openstack.org>2020-10-14 03:46:06 +0000
commit6216025e9da0b1689ddc4a494eaf562f15b28b32 (patch)
tree9589be1848a6704462ae13820b5ad6732c97f6e9 /openstackclient/compute
parentf083d42972ec1678ad705b4e1984ba2944a07da2 (diff)
parent1c7fe3b6bd60aa22ae525d0418729590f6429e96 (diff)
downloadpython-openstackclient-6216025e9da0b1689ddc4a494eaf562f15b28b32.tar.gz
Merge "Compute: Add tag support for server add volume"
Diffstat (limited to 'openstackclient/compute')
-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 03763021..89ea0067 100644
--- a/openstackclient/compute/v2/server.py
+++ b/openstackclient/compute/v2/server.py
@@ -510,20 +510,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
@@ -540,28 +552,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(