mirror of
https://github.com/ansible-collections/hetzner.hcloud.git
synced 2026-02-04 08:01:49 +00:00
fix: ensure returned resource ids are integers (#651)
##### SUMMARY The documentation states that all our returned resource ids are integers, this change aligns our modules with the docs. The impact of this change should be minimal, as ids are used for identification purposes by directly forwarding the values (no transformation of the data is done). ##### ISSUE TYPE - Bugfix Pull Request ##### COMPONENT NAME All modules
This commit is contained in:
parent
ef6a9389dc
commit
579b34e754
28 changed files with 36 additions and 34 deletions
2
changelogs/fragments/returned-resource-ids.yml
Normal file
2
changelogs/fragments/returned-resource-ids.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- All returned resource IDs are now integers instead of strings.
|
||||
|
|
@ -159,7 +159,7 @@ class AnsibleHCloudCertificate(AnsibleHCloud):
|
|||
|
||||
def _prepare_result(self):
|
||||
return {
|
||||
"id": str(self.hcloud_certificate.id),
|
||||
"id": self.hcloud_certificate.id,
|
||||
"name": self.hcloud_certificate.name,
|
||||
"type": self.hcloud_certificate.type,
|
||||
"fingerprint": self.hcloud_certificate.fingerprint,
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ class AnsibleHCloudCertificateInfo(AnsibleHCloud):
|
|||
|
||||
tmp.append(
|
||||
{
|
||||
"id": str(certificate.id),
|
||||
"id": certificate.id,
|
||||
"name": certificate.name,
|
||||
"fingerprint": certificate.fingerprint,
|
||||
"certificate": certificate.certificate,
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ class AnsibleHCloudDatacenterInfo(AnsibleHCloud):
|
|||
|
||||
tmp.append(
|
||||
{
|
||||
"id": str(datacenter.id),
|
||||
"id": datacenter.id,
|
||||
"name": datacenter.name,
|
||||
"description": datacenter.description,
|
||||
"location": datacenter.location.name,
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ class AnsibleHCloudFirewall(AnsibleHCloud):
|
|||
|
||||
def _prepare_result(self):
|
||||
return {
|
||||
"id": str(self.hcloud_firewall.id),
|
||||
"id": self.hcloud_firewall.id,
|
||||
"name": self.hcloud_firewall.name,
|
||||
"rules": [self._prepare_result_rule(rule) for rule in self.hcloud_firewall.rules],
|
||||
"labels": self.hcloud_firewall.labels,
|
||||
|
|
@ -256,14 +256,14 @@ class AnsibleHCloudFirewall(AnsibleHCloud):
|
|||
def _prepare_result_applied_to(self, resource: FirewallResource):
|
||||
result = {
|
||||
"type": resource.type,
|
||||
"server": str(resource.server.id) if resource.server is not None else None,
|
||||
"server": resource.server.id if resource.server is not None else None,
|
||||
"label_selector": resource.label_selector.selector if resource.label_selector is not None else None,
|
||||
}
|
||||
if resource.applied_to_resources is not None:
|
||||
result["applied_to_resources"] = [
|
||||
{
|
||||
"type": item.type,
|
||||
"server": str(item.server.id) if item.server is not None else None,
|
||||
"server": item.server.id if item.server is not None else None,
|
||||
}
|
||||
for item in resource.applied_to_resources
|
||||
]
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ class AnsibleHCloudFirewallInfo(AnsibleHCloud):
|
|||
|
||||
tmp.append(
|
||||
{
|
||||
"id": str(firewall.id),
|
||||
"id": firewall.id,
|
||||
"name": firewall.name,
|
||||
"labels": firewall.labels,
|
||||
"rules": [self._prepare_result_rule(rule) for rule in firewall.rules],
|
||||
|
|
@ -189,14 +189,14 @@ class AnsibleHCloudFirewallInfo(AnsibleHCloud):
|
|||
def _prepare_result_applied_to(self, resource: FirewallResource):
|
||||
result = {
|
||||
"type": resource.type,
|
||||
"server": str(resource.server.id) if resource.server is not None else None,
|
||||
"server": resource.server.id if resource.server is not None else None,
|
||||
"label_selector": resource.label_selector.selector if resource.label_selector is not None else None,
|
||||
}
|
||||
if resource.applied_to_resources is not None:
|
||||
result["applied_to_resources"] = [
|
||||
{
|
||||
"type": item.type,
|
||||
"server": str(item.server.id) if item.server is not None else None,
|
||||
"server": item.server.id if item.server is not None else None,
|
||||
}
|
||||
for item in resource.applied_to_resources
|
||||
]
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ class AnsibleHCloudFloatingIP(AnsibleHCloud):
|
|||
|
||||
def _prepare_result(self):
|
||||
return {
|
||||
"id": str(self.hcloud_floating_ip.id),
|
||||
"id": self.hcloud_floating_ip.id,
|
||||
"name": self.hcloud_floating_ip.name,
|
||||
"description": self.hcloud_floating_ip.description,
|
||||
"ip": self.hcloud_floating_ip.ip,
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ class AnsibleHCloudFloatingIPInfo(AnsibleHCloud):
|
|||
|
||||
tmp.append(
|
||||
{
|
||||
"id": str(floating_ip.id),
|
||||
"id": floating_ip.id,
|
||||
"name": floating_ip.name,
|
||||
"description": floating_ip.description,
|
||||
"ip": floating_ip.ip,
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ class AnsibleHCloudImageInfo(AnsibleHCloud):
|
|||
|
||||
tmp.append(
|
||||
{
|
||||
"id": str(image.id),
|
||||
"id": image.id,
|
||||
"status": image.status,
|
||||
"type": image.type,
|
||||
"name": image.name,
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ class AnsibleHCloudIsoInfo(AnsibleHCloud):
|
|||
|
||||
tmp.append(
|
||||
{
|
||||
"id": str(iso_info.id),
|
||||
"id": iso_info.id,
|
||||
"name": iso_info.name,
|
||||
"description": iso_info.description,
|
||||
"type": iso_info.type,
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ class AnsibleHCloudLoadBalancer(AnsibleHCloud):
|
|||
|
||||
def _prepare_result(self):
|
||||
return {
|
||||
"id": str(self.hcloud_load_balancer.id),
|
||||
"id": self.hcloud_load_balancer.id,
|
||||
"name": self.hcloud_load_balancer.name,
|
||||
"ipv4_address": self.hcloud_load_balancer.public_net.ipv4.ip,
|
||||
"ipv6_address": self.hcloud_load_balancer.public_net.ipv6.ip,
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@ class AnsibleHCloudLoadBalancerInfo(AnsibleHCloud):
|
|||
|
||||
tmp.append(
|
||||
{
|
||||
"id": str(load_balancer.id),
|
||||
"id": load_balancer.id,
|
||||
"name": load_balancer.name,
|
||||
"ipv4_address": load_balancer.public_net.ipv4.ip,
|
||||
"ipv6_address": load_balancer.public_net.ipv6.ip,
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ class AnsibleHCloudLoadBalancerTypeInfo(AnsibleHCloud):
|
|||
|
||||
tmp.append(
|
||||
{
|
||||
"id": str(load_balancer_type.id),
|
||||
"id": load_balancer_type.id,
|
||||
"name": load_balancer_type.name,
|
||||
"description": load_balancer_type.description,
|
||||
"max_connections": load_balancer_type.max_connections,
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ class AnsibleHCloudLocationInfo(AnsibleHCloud):
|
|||
|
||||
tmp.append(
|
||||
{
|
||||
"id": str(location.id),
|
||||
"id": location.id,
|
||||
"name": location.name,
|
||||
"description": location.description,
|
||||
"city": location.city,
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ class AnsibleHCloudNetwork(AnsibleHCloud):
|
|||
|
||||
def _prepare_result(self):
|
||||
return {
|
||||
"id": str(self.hcloud_network.id),
|
||||
"id": self.hcloud_network.id,
|
||||
"name": self.hcloud_network.name,
|
||||
"ip_range": self.hcloud_network.ip_range,
|
||||
"expose_routes_to_vswitch": self.hcloud_network.expose_routes_to_vswitch,
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ class AnsibleHCloudNetworkInfo(AnsibleHCloud):
|
|||
servers = []
|
||||
for server in network.servers:
|
||||
prepared_server = {
|
||||
"id": str(server.id),
|
||||
"id": server.id,
|
||||
"name": server.name,
|
||||
"ipv4_address": server.public_net.ipv4.ip if server.public_net.ipv4 is not None else None,
|
||||
"ipv6": server.public_net.ipv6.ip if server.public_net.ipv6 is not None else None,
|
||||
|
|
@ -238,7 +238,7 @@ class AnsibleHCloudNetworkInfo(AnsibleHCloud):
|
|||
|
||||
tmp.append(
|
||||
{
|
||||
"id": str(network.id),
|
||||
"id": network.id,
|
||||
"name": network.name,
|
||||
"ip_range": network.ip_range,
|
||||
"subnetworks": subnets,
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ class AnsibleHCloudPlacementGroup(AnsibleHCloud):
|
|||
|
||||
def _prepare_result(self):
|
||||
return {
|
||||
"id": str(self.hcloud_placement_group.id),
|
||||
"id": self.hcloud_placement_group.id,
|
||||
"name": self.hcloud_placement_group.name,
|
||||
"labels": self.hcloud_placement_group.labels,
|
||||
"type": self.hcloud_placement_group.type,
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ class AnsibleHCloudPrimaryIP(AnsibleHCloud):
|
|||
|
||||
def _prepare_result(self):
|
||||
return {
|
||||
"id": str(self.hcloud_primary_ip.id),
|
||||
"id": self.hcloud_primary_ip.id,
|
||||
"name": self.hcloud_primary_ip.name,
|
||||
"ip": self.hcloud_primary_ip.ip,
|
||||
"type": self.hcloud_primary_ip.type,
|
||||
|
|
@ -189,7 +189,7 @@ class AnsibleHCloudPrimaryIP(AnsibleHCloud):
|
|||
"labels": self.hcloud_primary_ip.labels,
|
||||
"delete_protection": self.hcloud_primary_ip.protection["delete"],
|
||||
"assignee_id": (
|
||||
str(self.hcloud_primary_ip.assignee_id) if self.hcloud_primary_ip.assignee_id is not None else None
|
||||
self.hcloud_primary_ip.assignee_id if self.hcloud_primary_ip.assignee_id is not None else None
|
||||
),
|
||||
"assignee_type": self.hcloud_primary_ip.assignee_type,
|
||||
"auto_delete": self.hcloud_primary_ip.auto_delete,
|
||||
|
|
|
|||
|
|
@ -145,11 +145,11 @@ class AnsibleHCloudPrimaryIPInfo(AnsibleHCloud):
|
|||
|
||||
tmp.append(
|
||||
{
|
||||
"id": str(primary_ip.id),
|
||||
"id": primary_ip.id,
|
||||
"name": primary_ip.name,
|
||||
"ip": primary_ip.ip,
|
||||
"type": primary_ip.type,
|
||||
"assignee_id": str(primary_ip.assignee_id) if primary_ip.assignee_id is not None else None,
|
||||
"assignee_id": primary_ip.assignee_id if primary_ip.assignee_id is not None else None,
|
||||
"assignee_type": primary_ip.assignee_type,
|
||||
"auto_delete": primary_ip.auto_delete,
|
||||
"home_location": primary_ip.datacenter.name,
|
||||
|
|
|
|||
|
|
@ -369,7 +369,7 @@ class AnsibleHCloudServer(AnsibleHCloud):
|
|||
|
||||
def _prepare_result(self):
|
||||
return {
|
||||
"id": str(self.hcloud_server.id),
|
||||
"id": self.hcloud_server.id,
|
||||
"name": self.hcloud_server.name,
|
||||
"created": self.hcloud_server.created.isoformat(),
|
||||
"ipv4_address": (
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ class AnsibleHCloudServerInfo(AnsibleHCloud):
|
|||
|
||||
tmp.append(
|
||||
{
|
||||
"id": str(server.id),
|
||||
"id": server.id,
|
||||
"name": server.name,
|
||||
"created": server.created.isoformat(),
|
||||
"ipv4_address": server.public_net.ipv4.ip if server.public_net.ipv4 is not None else None,
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ class AnsibleHCloudServerTypeInfo(AnsibleHCloud):
|
|||
|
||||
tmp.append(
|
||||
{
|
||||
"id": str(server_type.id),
|
||||
"id": server_type.id,
|
||||
"name": server_type.name,
|
||||
"description": server_type.description,
|
||||
"cores": server_type.cores,
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ class AnsibleHCloudSSHKey(AnsibleHCloud):
|
|||
|
||||
def _prepare_result(self):
|
||||
return {
|
||||
"id": str(self.hcloud_ssh_key.id),
|
||||
"id": self.hcloud_ssh_key.id,
|
||||
"name": self.hcloud_ssh_key.name,
|
||||
"fingerprint": self.hcloud_ssh_key.fingerprint,
|
||||
"public_key": self.hcloud_ssh_key.public_key,
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ class AnsibleHCloudSSHKeyInfo(AnsibleHCloud):
|
|||
|
||||
tmp.append(
|
||||
{
|
||||
"id": str(ssh_key.id),
|
||||
"id": ssh_key.id,
|
||||
"name": ssh_key.name,
|
||||
"fingerprint": ssh_key.fingerprint,
|
||||
"public_key": ssh_key.public_key,
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ class AnsibleHCloudVolume(AnsibleHCloud):
|
|||
|
||||
def _prepare_result(self):
|
||||
return {
|
||||
"id": str(self.hcloud_volume.id),
|
||||
"id": self.hcloud_volume.id,
|
||||
"name": self.hcloud_volume.name,
|
||||
"size": self.hcloud_volume.size,
|
||||
"location": self.hcloud_volume.location.name,
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ class AnsibleHCloudVolumeInfo(AnsibleHCloud):
|
|||
|
||||
tmp.append(
|
||||
{
|
||||
"id": str(volume.id),
|
||||
"id": volume.id,
|
||||
"name": volume.name,
|
||||
"size": volume.size,
|
||||
"location": volume.location.name,
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
ansible.builtin.assert:
|
||||
that:
|
||||
- result.hcloud_iso_info | list | count == 1
|
||||
- result.hcloud_iso_info[0].id == hcloud_iso_id | string
|
||||
- result.hcloud_iso_info[0].id == hcloud_iso_id
|
||||
- result.hcloud_iso_info[0].name == hcloud_iso_name
|
||||
- result.hcloud_iso_info[0].architecture == hcloud_iso_architecture
|
||||
- result.hcloud_iso_info[0].type == hcloud_iso_type
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@
|
|||
- result is changed
|
||||
- result.hcloud_primary_ip.name == hcloud_primary_ip_name
|
||||
- result.hcloud_primary_ip.type == "ipv6"
|
||||
- result.hcloud_primary_ip.assignee_id == test_server.hcloud_server.id | string
|
||||
- result.hcloud_primary_ip.assignee_id == test_server.hcloud_server.id
|
||||
- result.hcloud_primary_ip.assignee_type == "server"
|
||||
|
||||
- name: Test create with server idempotency
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue