hcloud_volume & hcloud_volume_info: "None" -> null (#165)

Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>

Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>
This commit is contained in:
Lukas Kämmerling 2022-11-08 10:14:24 +01:00 committed by GitHub
parent d1c97c7e89
commit 123ad2c1b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 4 deletions

View file

@ -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

View file

@ -183,7 +183,7 @@ class AnsibleHcloudVolume(Hcloud):
def _prepare_result(self): def _prepare_result(self):
server_name = None server_name = None
if self.hcloud_volume.server is not 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 { return {
"id": to_native(self.hcloud_volume.id), "id": to_native(self.hcloud_volume.id),
@ -191,7 +191,7 @@ class AnsibleHcloudVolume(Hcloud):
"size": self.hcloud_volume.size, "size": self.hcloud_volume.size,
"location": to_native(self.hcloud_volume.location.name), "location": to_native(self.hcloud_volume.location.name),
"labels": self.hcloud_volume.labels, "labels": self.hcloud_volume.labels,
"server": to_native(server_name), "server": server_name,
"linux_device": to_native(self.hcloud_volume.linux_device), "linux_device": to_native(self.hcloud_volume.linux_device),
"delete_protection": self.hcloud_volume.protection["delete"], "delete_protection": self.hcloud_volume.protection["delete"],
} }

View file

@ -117,14 +117,14 @@ class AnsibleHcloudVolumeInfo(Hcloud):
if volume is not None: if volume is not None:
server_name = None server_name = None
if volume.server is not None: if volume.server is not None:
server_name = volume.server.name server_name = to_native(volume.server.name)
tmp.append({ tmp.append({
"id": to_native(volume.id), "id": to_native(volume.id),
"name": to_native(volume.name), "name": to_native(volume.name),
"size": volume.size, "size": volume.size,
"location": to_native(volume.location.name), "location": to_native(volume.location.name),
"labels": volume.labels, "labels": volume.labels,
"server": to_native(server_name), "server": server_name,
"linux_device": to_native(volume.linux_device), "linux_device": to_native(volume.linux_device),
"delete_protection": volume.protection["delete"], "delete_protection": volume.protection["delete"],
}) })