diff options
| author | whoami-rajat <rajatdhasmana@gmail.com> | 2022-02-25 22:43:24 +0530 |
|---|---|---|
| committer | Stephen Finucane <sfinucan@redhat.com> | 2022-09-14 11:24:10 +0100 |
| commit | 4024bdb3933dd79eec4bcf99c13f3dbf17add40b (patch) | |
| tree | f0b45c85bbf8b4926595b871b5078996351ab1ee /openstackclient/compute | |
| parent | 1f63034441a63b968185e1678049c01205b8e6d7 (diff) | |
| download | python-openstackclient-4024bdb3933dd79eec4bcf99c13f3dbf17add40b.tar.gz | |
compute: Add support for microversion 2.93
Add '--reimage-boot-volume' and '--no-reimage-boot-volume parameters'
to the rebuild command to allow rebuilding of volume backed instances.
Change-Id: I4a6e30b2cf12f32202a2d9ef1ced347e1dd139f3
Diffstat (limited to 'openstackclient/compute')
| -rw-r--r-- | openstackclient/compute/v2/server.py | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/openstackclient/compute/v2/server.py b/openstackclient/compute/v2/server.py index 24c158ae..02fed155 100644 --- a/openstackclient/compute/v2/server.py +++ b/openstackclient/compute/v2/server.py @@ -3092,6 +3092,28 @@ class RebuildServer(command.ShowOne): ), ) parser.add_argument( + '--reimage-boot-volume', + action='store_true', + dest='reimage_boot_volume', + default=None, + help=_( + 'Rebuild a volume-backed server. This will wipe the root ' + 'volume data and overwrite it with the provided image. ' + 'Defaults to False. ' + '(supported by --os-compute-api-version 2.93 or above)' + ), + ) + parser.add_argument( + '--no-reimage-boot-volume', + action='store_false', + dest='reimage_boot_volume', + default=None, + help=_( + 'Do not rebuild a volume-backed server. ' + '(supported by --os-compute-api-version 2.93 or above)' + ), + ) + parser.add_argument( '--wait', action='store_true', help=_('Wait for rebuild to complete'), @@ -3226,6 +3248,41 @@ class RebuildServer(command.ShowOne): kwargs['hostname'] = parsed_args.hostname + v2_93 = api_versions.APIVersion('2.93') + if parsed_args.reimage_boot_volume: + if compute_client.api_version < v2_93: + msg = _( + '--os-compute-api-version 2.93 or greater is required to ' + 'support the --reimage-boot-volume option' + ) + raise exceptions.CommandError(msg) + else: + # force user to explicitly request reimaging of volume-backed + # server + if not server.image: + if compute_client.api_version >= v2_93: + msg = ( + '--reimage-boot-volume is required to rebuild a ' + 'volume-backed server' + ) + raise exceptions.CommandError(msg) + else: # microversion < 2.93 + # attempts to rebuild a volume-backed server before API + # microversion 2.93 will fail in all cases except one: if + # the user attempts the rebuild with the exact same image + # that the server was initially built with. We can't check + # for this since we don't have the original image ID to + # hand, so we simply warn the user. + # TODO(stephenfin): Make this a failure in a future + # version + self.log.warning( + 'Attempting to rebuild a volume-backed server using ' + '--os-compute-api-version 2.92 or earlier, which ' + 'will only succeed if the image is identical to the ' + 'one initially used. This will be an error in a ' + 'future release.' + ) + try: server = server.rebuild(image, parsed_args.password, **kwargs) finally: |
