From 123ad2c1b06de7f4765d5fd187add09e8724a10a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20K=C3=A4mmerling?= Date: Tue, 8 Nov 2022 10:14:24 +0100 Subject: [PATCH] hcloud_volume & hcloud_volume_info: "None" -> null (#165) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lukas Kämmerling Signed-off-by: Lukas Kämmerling --- changelogs/fragments/hcloud_volume_server_none.yml | 3 +++ plugins/modules/hcloud_volume.py | 4 ++-- plugins/modules/hcloud_volume_info.py | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/hcloud_volume_server_none.yml diff --git a/changelogs/fragments/hcloud_volume_server_none.yml b/changelogs/fragments/hcloud_volume_server_none.yml new file mode 100644 index 0000000..1635c8d --- /dev/null +++ b/changelogs/fragments/hcloud_volume_server_none.yml @@ -0,0 +1,3 @@ +bugfixes: + - hcloud_volume - fix server name was given out as "None" instead of null if no server was attached + - hcloud_volume_info - fix server name was given out as "None" instead of null if no server was attached diff --git a/plugins/modules/hcloud_volume.py b/plugins/modules/hcloud_volume.py index 304759d..60a2cd7 100644 --- a/plugins/modules/hcloud_volume.py +++ b/plugins/modules/hcloud_volume.py @@ -183,7 +183,7 @@ class AnsibleHcloudVolume(Hcloud): def _prepare_result(self): server_name = None if self.hcloud_volume.server is not None: - server_name = self.hcloud_volume.server.name + server_name = to_native(self.hcloud_volume.server.name) return { "id": to_native(self.hcloud_volume.id), @@ -191,7 +191,7 @@ class AnsibleHcloudVolume(Hcloud): "size": self.hcloud_volume.size, "location": to_native(self.hcloud_volume.location.name), "labels": self.hcloud_volume.labels, - "server": to_native(server_name), + "server": server_name, "linux_device": to_native(self.hcloud_volume.linux_device), "delete_protection": self.hcloud_volume.protection["delete"], } diff --git a/plugins/modules/hcloud_volume_info.py b/plugins/modules/hcloud_volume_info.py index 3621776..6a6cc22 100644 --- a/plugins/modules/hcloud_volume_info.py +++ b/plugins/modules/hcloud_volume_info.py @@ -117,14 +117,14 @@ class AnsibleHcloudVolumeInfo(Hcloud): if volume is not None: server_name = None if volume.server is not None: - server_name = volume.server.name + server_name = to_native(volume.server.name) tmp.append({ "id": to_native(volume.id), "name": to_native(volume.name), "size": volume.size, "location": to_native(volume.location.name), "labels": volume.labels, - "server": to_native(server_name), + "server": server_name, "linux_device": to_native(volume.linux_device), "delete_protection": volume.protection["delete"], })