Skip to content

Commit

Permalink
fix hcloud_network_info failing without internet connectivity (#159)
Browse files Browse the repository at this point in the history
This fixes the behavior if there is a server without direct internet
connectivity in the examined network.
Previously, the module would throw an AttributeError because
server.public_net.ipv4/ipv6 is None in this case. Now the None propagates
correctly.
  • Loading branch information
Galaxy102 authored Nov 7, 2022
1 parent a87c82d commit 5cc7c58
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions plugins/modules/hcloud_network_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@
type: str
sample: cx11
ipv4_address:
description: Public IPv4 address of the server
description: Public IPv4 address of the server, None if not existing
returned: always
type: str
sample: 116.203.104.109
ipv6:
description: IPv6 network of the server
description: IPv6 network of the server, None if not existing
returned: always
type: str
sample: 2a01:4f8:1c1c:c140::/64
Expand Down Expand Up @@ -220,11 +220,13 @@ def _prepare_result(self):
servers = []
for server in network.servers:
image = None if server.image is None else to_native(server.image.name)
ipv4_address = None if server.public_net.ipv4 is None else to_native(server.public_net.ipv4.ip)
ipv6 = None if server.public_net.ipv6 is None else to_native(server.public_net.ipv6.ip)
prepared_server = {
"id": to_native(server.id),
"name": to_native(server.name),
"ipv4_address": to_native(server.public_net.ipv4.ip),
"ipv6": to_native(server.public_net.ipv6.ip),
"ipv4_address": ipv4_address,
"ipv6": ipv6,
"image": image,
"server_type": to_native(server.server_type.name),
"datacenter": to_native(server.datacenter.name),
Expand Down

0 comments on commit 5cc7c58

Please sign in to comment.