mirror of
https://github.com/ansible-collections/hetzner.hcloud.git
synced 2026-02-04 08:01:49 +00:00
refactor: remove unneeded to_native calls (#477)
##### SUMMARY Since we only support python >=3.8, the `to_native` python2/3 compatibility function is not needed anymore. We only keep it for printing a traceback free exception message. Where a type conversion is needed, we use the built-in `str()` function.
This commit is contained in:
parent
64f7824cc8
commit
4bb02b9cd2
34 changed files with 394 additions and 453 deletions
|
|
@ -160,7 +160,6 @@ hcloud_volume:
|
|||
"""
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.common.text.converters import to_native
|
||||
|
||||
from ..module_utils.hcloud import AnsibleHCloud
|
||||
from ..module_utils.vendor.hcloud import HCloudException
|
||||
|
|
@ -173,18 +172,14 @@ class AnsibleHCloudVolume(AnsibleHCloud):
|
|||
hcloud_volume: BoundVolume | None = None
|
||||
|
||||
def _prepare_result(self):
|
||||
server_name = None
|
||||
if self.hcloud_volume.server is not None:
|
||||
server_name = to_native(self.hcloud_volume.server.name)
|
||||
|
||||
return {
|
||||
"id": to_native(self.hcloud_volume.id),
|
||||
"name": to_native(self.hcloud_volume.name),
|
||||
"id": str(self.hcloud_volume.id),
|
||||
"name": self.hcloud_volume.name,
|
||||
"size": self.hcloud_volume.size,
|
||||
"location": to_native(self.hcloud_volume.location.name),
|
||||
"location": self.hcloud_volume.location.name,
|
||||
"labels": self.hcloud_volume.labels,
|
||||
"server": server_name,
|
||||
"linux_device": to_native(self.hcloud_volume.linux_device),
|
||||
"server": self.hcloud_volume.server.name if self.hcloud_volume.server is not None else None,
|
||||
"linux_device": self.hcloud_volume.linux_device,
|
||||
"delete_protection": self.hcloud_volume.protection["delete"],
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue