diff options
| author | Zuul <zuul@review.opendev.org> | 2021-09-02 20:15:11 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2021-09-02 20:15:11 +0000 |
| commit | 3a0571c4dfc1e79a5dd8b1a9f8856c8971fb05d6 (patch) | |
| tree | a0fe815f7dc01587bcf6a0e0262b5b068cd1ef83 /openstackclient/compute | |
| parent | 51ee17a94dccd297101725593b223f01c4f9b906 (diff) | |
| parent | 8e833a3ed26467a1190ba69d8ba716a7cd1cccb3 (diff) | |
| download | python-openstackclient-3a0571c4dfc1e79a5dd8b1a9f8856c8971fb05d6.tar.gz | |
Merge "compute: Add support for microversion 2.90"
Diffstat (limited to 'openstackclient/compute')
| -rw-r--r-- | openstackclient/compute/v2/server.py | 76 |
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) |
