Skip to content

Commit

Permalink
Include available public IP information within the network calls
Browse files Browse the repository at this point in the history
  • Loading branch information
yyzkevin committed Dec 14, 2024
1 parent ca0a634 commit 357d24e
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions plugins/modules/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,14 @@
returned: if available
type: str
sample: My VPC
public_ips:
description: A list of all public ip addresses associated to the network
returned: if available
type: arr
snat_ip:
description: The public IP address configured for snat
returned: if available
type: str
"""

from ansible.module_utils.basic import AnsibleModule
Expand Down Expand Up @@ -389,6 +397,8 @@ def __init__(self, module):
"broadcastdomaintype": "broadcast_domain_type",
"dns1": "dns1",
"dns2": "dns2",
"public_ips": "public_ips",
"snat_ip": "snat_ip",
}
self.network = None

Expand Down Expand Up @@ -456,6 +466,19 @@ def query_network(self, refresh=False):
self.network = n
self.network["acl"] = self.get_network_acl(key="name", acl_id=n.get("aclid"))
break

if self.network:
# self.network["public_ips"] = []
# self.network["snat_ip"] = None
args = {
"associatednetworkid" : self.network["id"]
}
ip_addresses = self.query_api("listPublicIpAddresses", **args)
if ip_addresses:
self.network["public_ips"]=ip_addresses["publicipaddress"]
for n in self.network["public_ips"]:
if n["issourcenat"]:
self.network["snat_ip"] = n["ipaddress"]
return self.network

def present_network(self):
Expand Down

0 comments on commit 357d24e

Please sign in to comment.