From 8c846f3b68771669695bb19d398b80effcda73e0 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 20 Nov 2023 09:25:57 +0100 Subject: [PATCH] deps: update dependency hcloud to v1.32.0 (#389) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate logo banner](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [hcloud](https://togithub.com/hetznercloud/hcloud-python) ([changelog](https://togithub.com/hetznercloud/hcloud-python/blob/main/CHANGELOG.md)) | `1.31.0` -> `1.32.0` | [![age](https://developer.mend.io/api/mc/badges/age/pypi/hcloud/1.32.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/pypi/hcloud/1.32.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/pypi/hcloud/1.31.0/1.32.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/hcloud/1.31.0/1.32.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
hetznercloud/hcloud-python (hcloud) ### [`v1.32.0`](https://togithub.com/hetznercloud/hcloud-python/blob/HEAD/CHANGELOG.md#1320-2023-11-17) [Compare Source](https://togithub.com/hetznercloud/hcloud-python/compare/v1.31.0...v1.32.0) ##### Features - allow returning root_password in servers rebuild ([#​276](https://togithub.com/hetznercloud/hcloud-python/issues/276)) ([38e098a](https://togithub.com/hetznercloud/hcloud-python/commit/38e098a41154e6561578cd723608fcd7577c3d01)) ##### Dependencies - update dependency mypy to >=1.7,<1.8 ([#​325](https://togithub.com/hetznercloud/hcloud-python/issues/325)) ([7b59a2d](https://togithub.com/hetznercloud/hcloud-python/commit/7b59a2decc9bb5152dc9de435bfe12ce1f34ac1c)) - update pre-commit hook pre-commit/mirrors-prettier to v3.1.0 ([#​326](https://togithub.com/hetznercloud/hcloud-python/issues/326)) ([213b661](https://togithub.com/hetznercloud/hcloud-python/commit/213b661d897cdd327f478b52aeb79844826694d8)) - update pre-commit hook psf/black-pre-commit-mirror to v23.10.1 ([#​322](https://togithub.com/hetznercloud/hcloud-python/issues/322)) ([999afe3](https://togithub.com/hetznercloud/hcloud-python/commit/999afe37e02a113639930aff6879f50918ac0e89)) - update pre-commit hook psf/black-pre-commit-mirror to v23.11.0 ([#​324](https://togithub.com/hetznercloud/hcloud-python/issues/324)) ([7b2a24e](https://togithub.com/hetznercloud/hcloud-python/commit/7b2a24ecf69c0bead7f9113053fda37a0cc31d1b))
--- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/ansible-collections/hetzner.hcloud). --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: jo --- .../module_utils/vendor/hcloud/_version.py | 2 +- .../vendor/hcloud/servers/client.py | 42 +++++++++++++++---- .../vendor/hcloud/servers/domain.py | 18 ++++++++ plugins/modules/hcloud_server.py | 3 +- scripts/vendor.py | 2 +- 5 files changed, 55 insertions(+), 12 deletions(-) diff --git a/plugins/module_utils/vendor/hcloud/_version.py b/plugins/module_utils/vendor/hcloud/_version.py index d7f9786..ce6064e 100644 --- a/plugins/module_utils/vendor/hcloud/_version.py +++ b/plugins/module_utils/vendor/hcloud/_version.py @@ -1,3 +1,3 @@ from __future__ import annotations -VERSION = "1.31.0" # x-release-please-version +VERSION = "1.32.0" # x-release-please-version diff --git a/plugins/module_utils/vendor/hcloud/servers/client.py b/plugins/module_utils/vendor/hcloud/servers/client.py index ea72851..b6da0d3 100644 --- a/plugins/module_utils/vendor/hcloud/servers/client.py +++ b/plugins/module_utils/vendor/hcloud/servers/client.py @@ -1,5 +1,6 @@ from __future__ import annotations +import warnings from typing import TYPE_CHECKING, Any, NamedTuple from ..actions import ActionsPageResult, BoundAction, ResourceActionsClient @@ -21,6 +22,7 @@ from .domain import ( PrivateNet, PublicNetwork, PublicNetworkFirewall, + RebuildResponse, RequestConsoleResponse, ResetPasswordResponse, Server, @@ -299,13 +301,18 @@ class BoundServer(BoundModelBase, Server): """ return self._client.create_image(self, description, type, labels) - def rebuild(self, image: Image | BoundImage) -> BoundAction: + def rebuild( + self, + image: Image | BoundImage, + *, + return_response: bool = False, + ) -> RebuildResponse | BoundAction: """Rebuilds a server overwriting its disk with the content of an image, thereby destroying all data on the target server. - :param image: :class:`BoundImage ` or :class:`Image ` - :return: :class:`BoundAction ` + :param image: Image to use for the rebuilt server + :param return_response: Whether to return the full response or only the action. """ - return self._client.rebuild(self, image) + return self._client.rebuild(self, image, return_response=return_response) def change_type( self, @@ -930,12 +937,14 @@ class ServersClient(ClientEntityBase): self, server: Server | BoundServer, image: Image | BoundImage, - ) -> BoundAction: + *, + return_response: bool = False, + ) -> RebuildResponse | BoundAction: """Rebuilds a server overwriting its disk with the content of an image, thereby destroying all data on the target server. - :param server: :class:`BoundServer ` or :class:`Server ` - :param image: :class:`BoundImage ` or :class:`Image ` - :return: :class:`BoundAction ` + :param server: Server to rebuild + :param image: Image to use for the rebuilt server + :param return_response: Whether to return the full response or only the action. """ data: dict[str, Any] = {"image": image.id_or_name} response = self._client.request( @@ -943,7 +952,22 @@ class ServersClient(ClientEntityBase): method="POST", json=data, ) - return BoundAction(self._client.actions, response["action"]) + + rebuild_response = RebuildResponse( + action=BoundAction(self._client.actions, response["action"]), + root_password=response.get("root_password"), + ) + + if not return_response: + warnings.warn( + "Returning only the 'action' is deprecated, please set the " + "'return_response' keyword argument to 'True' to return the full " + "rebuild response and update your code accordingly.", + DeprecationWarning, + stacklevel=2, + ) + return rebuild_response.action + return rebuild_response def enable_backup(self, server: Server | BoundServer) -> BoundAction: """Enables and configures the automatic daily backup option for the server. Enabling automatic backups will increase the price of the server by 20%. diff --git a/plugins/module_utils/vendor/hcloud/servers/domain.py b/plugins/module_utils/vendor/hcloud/servers/domain.py index b78dd59..71ca99d 100644 --- a/plugins/module_utils/vendor/hcloud/servers/domain.py +++ b/plugins/module_utils/vendor/hcloud/servers/domain.py @@ -247,6 +247,24 @@ class RequestConsoleResponse(BaseDomain): self.password = password +class RebuildResponse(BaseDomain): + """Rebuild Response Domain + + :param action: Shows the progress of the server rebuild action + :param root_password: The root password of the server when not using SSH keys + """ + + __slots__ = ("action", "root_password") + + def __init__( + self, + action: BoundAction, + root_password: str | None, + ): + self.action = action + self.root_password = root_password + + class PublicNetwork(BaseDomain): """Public Network Domain diff --git a/plugins/modules/hcloud_server.py b/plugins/modules/hcloud_server.py index d949d26..e1f0aeb 100644 --- a/plugins/modules/hcloud_server.py +++ b/plugins/modules/hcloud_server.py @@ -853,7 +853,8 @@ class AnsibleHCloudServer(AnsibleHCloud): if not self.module.check_mode: image = self._get_image(self.hcloud_server.server_type) # When we rebuild the server progress takes some more time. - self.client.servers.rebuild(self.hcloud_server, image).wait_until_finished(1000) + resp = self.client.servers.rebuild(self.hcloud_server, image, return_response=True) + resp.action.wait_until_finished(1000) self._mark_as_changed() self._get_server() diff --git a/scripts/vendor.py b/scripts/vendor.py index b878842..7083db5 100755 --- a/scripts/vendor.py +++ b/scripts/vendor.py @@ -20,7 +20,7 @@ from textwrap import dedent logger = logging.getLogger("vendor") HCLOUD_SOURCE_URL = "https://github.com/hetznercloud/hcloud-python" -HCLOUD_VERSION = "v1.31.0" +HCLOUD_VERSION = "v1.32.0" HCLOUD_VENDOR_PATH = "plugins/module_utils/vendor/hcloud"