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:
parent
b566c017e2
commit
8c8a52ceed
3 changed files with 35 additions and 1 deletions
2
changelogs/fragments/rename-volume.yml
Normal file
2
changelogs/fragments/rename-volume.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
minor_changes:
|
||||||
|
- volume - Allow renaming a volume.
|
||||||
|
|
@ -245,10 +245,20 @@ class AnsibleHCloudVolume(AnsibleHCloud):
|
||||||
action.wait_until_finished()
|
action.wait_until_finished()
|
||||||
self._mark_as_changed()
|
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")
|
labels = self.module.params.get("labels")
|
||||||
if labels is not None and labels != self.hcloud_volume.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:
|
if not self.module.check_mode:
|
||||||
self.hcloud_volume.update(labels=labels)
|
self.hcloud_volume.update(**update_params)
|
||||||
self._mark_as_changed()
|
self._mark_as_changed()
|
||||||
|
|
||||||
delete_protection = self.module.params.get("delete_protection")
|
delete_protection = self.module.params.get("delete_protection")
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,28 @@
|
||||||
that:
|
that:
|
||||||
- volume is not changed
|
- volume is not changed
|
||||||
|
|
||||||
|
- name: test update Volume name
|
||||||
|
hetzner.hcloud.volume:
|
||||||
|
id: "{{ volume.hcloud_volume.id }}"
|
||||||
|
name: "{{ hcloud_volume_name }}-new"
|
||||||
|
register: result
|
||||||
|
- name: verify test update Volume name
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- result is changed
|
||||||
|
- result.hcloud_volume.name == hcloud_volume_name + '-new'
|
||||||
|
|
||||||
|
- name: reset volume name
|
||||||
|
hetzner.hcloud.volume:
|
||||||
|
id: "{{ volume.hcloud_volume.id }}"
|
||||||
|
name: "{{ hcloud_server_name }}"
|
||||||
|
register: result
|
||||||
|
- name: verify reset volume name
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- result is changed
|
||||||
|
- result.hcloud_volume.name == hcloud_volume_name
|
||||||
|
|
||||||
- name: test increase Volume size
|
- name: test increase Volume size
|
||||||
hetzner.hcloud.volume:
|
hetzner.hcloud.volume:
|
||||||
name: "{{hcloud_volume_name}}"
|
name: "{{hcloud_volume_name}}"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue