summaryrefslogtreecommitdiff
path: root/openstackclient/compute
diff options
context:
space:
mode:
authorStephen Finucane <sfinucan@redhat.com>2021-09-01 13:04:51 +0100
committerStephen Finucane <sfinucan@redhat.com>2021-09-01 13:18:25 +0100
commit8e833a3ed26467a1190ba69d8ba716a7cd1cccb3 (patch)
treee7d34b5b6669150d1f6f2b2a88b20320b10a7eab /openstackclient/compute
parent6ce7da8aeb7e5d1347940433e087036e8e43eaa6 (diff)
downloadpython-openstackclient-8e833a3ed26467a1190ba69d8ba716a7cd1cccb3.tar.gz
compute: Add support for microversion 2.90
Allow configuring hostname when creating a new server or updating or rebuilding an existing server. Change-Id: Ibe603eab78bbbec43605f56de62a20493b6aa93d Signed-off-by: Stephen Finucane <sfinucan@redhat.com> Depends-On: https://review.opendev.org/c/openstack/python-novaclient/+/806917
Diffstat (limited to 'openstackclient/compute')
-rw-r--r--openstackclient/compute/v2/server.py76
1 files changed, 72 insertions, 4 deletions
diff --git a/openstackclient/compute/v2/server.py b/openstackclient/compute/v2/server.py
index a09fd44d..47505838 100644
--- a/openstackclient/compute/v2/server.py
+++ b/openstackclient/compute/v2/server.py
@@ -1155,6 +1155,18 @@ class CreateServer(command.ShowOne):
),
)
parser.add_argument(
+ '--hostname',
+ metavar='<hostname>',
+ help=_(
+ 'Hostname configured for the server in the metadata service. '
+ 'If unset, a hostname will be automatically generated from '
+ 'the server name. '
+ 'A utility such as cloud-init is required to propagate the '
+ 'hostname in the metadata service to the guest OS itself. '
+ '(supported by --os-compute-api-version 2.90 or above)'
+ ),
+ )
+ parser.add_argument(
'--wait',
action='store_true',
help=_('Wait for build to complete'),
@@ -1618,6 +1630,16 @@ class CreateServer(command.ShowOne):
boot_kwargs['hypervisor_hostname'] = (
parsed_args.hypervisor_hostname)
+ if parsed_args.hostname:
+ if compute_client.api_version < api_versions.APIVersion("2.90"):
+ msg = _(
+ '--os-compute-api-version 2.90 or greater is required to '
+ 'support the --hostname option'
+ )
+ raise exceptions.CommandError(msg)
+
+ boot_kwargs['hostname'] = parsed_args.hostname
+
LOG.debug('boot_args: %s', boot_args)
LOG.debug('boot_kwargs: %s', boot_kwargs)
@@ -3274,6 +3296,16 @@ class RebuildServer(command.ShowOne):
),
)
parser.add_argument(
+ '--hostname',
+ metavar='<hostname>',
+ help=_(
+ 'Hostname configured for the server in the metadata service. '
+ 'A separate utility running in the guest is required to '
+ 'propagate changes to this value to the guest OS itself. '
+ '(supported by --os-compute-api-version 2.90 or above)'
+ ),
+ )
+ parser.add_argument(
'--wait',
action='store_true',
help=_('Wait for rebuild to complete'),
@@ -3390,6 +3422,16 @@ class RebuildServer(command.ShowOne):
kwargs['trusted_image_certificates'] = None
+ if parsed_args.hostname:
+ if compute_client.api_version < api_versions.APIVersion('2.90'):
+ msg = _(
+ '--os-compute-api-version 2.90 or greater is required to '
+ 'support the --hostname option'
+ )
+ raise exceptions.CommandError(msg)
+
+ kwargs['hostname'] = parsed_args.hostname
+
try:
server = server.rebuild(image, parsed_args.password, **kwargs)
finally:
@@ -4076,6 +4118,16 @@ class SetServer(command.Command):
'(supported by --os-compute-api-version 2.26 or above)'
),
)
+ parser.add_argument(
+ '--hostname',
+ metavar='<hostname>',
+ help=_(
+ 'Hostname configured for the server in the metadata service. '
+ 'A separate utility running in the guest is required to '
+ 'propagate changes to this value to the guest OS itself. '
+ '(supported by --os-compute-api-version 2.90 or above)'
+ ),
+ )
return parser
def take_action(self, parsed_args):
@@ -4102,8 +4154,27 @@ class SetServer(command.Command):
)
raise exceptions.CommandError(msg)
+ if parsed_args.hostname:
+ if server.api_version < api_versions.APIVersion('2.90'):
+ msg = _(
+ '--os-compute-api-version 2.90 or greater is required to '
+ 'support the --hostname option'
+ )
+ raise exceptions.CommandError(msg)
+
+ update_kwargs = {}
+
if parsed_args.name:
- server.update(name=parsed_args.name)
+ update_kwargs['name'] = parsed_args.name
+
+ if parsed_args.description:
+ update_kwargs['description'] = parsed_args.description
+
+ if parsed_args.hostname:
+ update_kwargs['hostname'] = parsed_args.hostname
+
+ if update_kwargs:
+ server.update(**update_kwargs)
if parsed_args.properties:
compute_client.servers.set_meta(server, parsed_args.properties)
@@ -4124,9 +4195,6 @@ class SetServer(command.Command):
elif parsed_args.no_password:
server.clear_password()
- if parsed_args.description:
- server.update(description=parsed_args.description)
-
if parsed_args.tags:
for tag in parsed_args.tags:
server.add_tag(tag=tag)