1
0
Fork 0
mirror of https://github.com/ansible-collections/hetzner.hcloud.git synced 2026-02-04 08:01:49 +00:00

feat: allow renaming a volume (#683)

##### SUMMARY
Allow renaming volume
Fixes #681 

##### ISSUE TYPE
- Feature Pull Request

##### COMPONENT NAME
`volume`

---------

Co-authored-by: Jonas L. <jooola@users.noreply.github.com>
This commit is contained in:
Amirhossein Shaerpour 2025-08-14 16:32:28 +03:30 committed by GitHub
parent b566c017e2
commit 8c8a52ceed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 35 additions and 1 deletions

View file

@ -245,10 +245,20 @@ class AnsibleHCloudVolume(AnsibleHCloud):
action.wait_until_finished()
self._mark_as_changed()
update_params = {}
name = self.module.params.get("name")
if name is not None and name != self.hcloud_volume.name:
self.module.fail_on_missing_params(required_params=["id"])
update_params["name"] = name
labels = self.module.params.get("labels")
if labels is not None and labels != self.hcloud_volume.labels:
update_params["labels"] = labels
if update_params:
if not self.module.check_mode:
self.hcloud_volume.update(labels=labels)
self.hcloud_volume.update(**update_params)
self._mark_as_changed()
delete_protection = self.module.params.get("delete_protection")