Skip to content

Commit

Permalink
Update parsing logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmoore3 committed Jul 9, 2024
1 parent 5036ee2 commit 3448bcb
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions cloudinit/sources/helpers/openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,17 +628,16 @@ def convert_net_json(network_json=None, known_macs=None):

# Filter the route entries as they may contain extra elements such
# as DNS which are required elsewhere by the cloudinit schema
subnet.update(
{
"routes": [
dict(
(k, v) for k, v in route.items()
if k in valid_keys["routes"]
)
for route in network.get("routes", [])
]
}
)
routes = [
dict(
(k, v) for k, v in route.items()
if k in valid_keys["routes"]
)
for route in network.get("routes", [])
]

if routes:
subnet.update({"routes": routes})

if network["type"] == "ipv4_dhcp":
subnet.update({"type": "dhcp4"})
Expand Down Expand Up @@ -666,14 +665,24 @@ def convert_net_json(network_json=None, known_macs=None):
}
)

dns_nameservers = [
# Look for either subnet or network specific DNS servers
# and add them as subnet level DNS entries. Use a set to
# for accumulation to eliminate duplicates.
# Subnet specific nameservers
dns_nameservers = set([
service["address"]
for route in network.get("routes", [])
for service in route.get("services", [])
if service.get("type") == "dns"
]
])
# Network specific nameservers
dns_nameservers.update([
service["address"]
for service in network.get("services", [])
if service.get("type") == "dns"
])
if dns_nameservers:
subnet["dns_nameservers"] = dns_nameservers
subnet["dns_nameservers"] = list(dns_nameservers)

# Enable accept_ra for stateful and legacy ipv6_dhcp types
if network["type"] in ["ipv6_dhcpv6-stateful", "ipv6_dhcp"]:
Expand Down

0 comments on commit 3448bcb

Please sign in to comment.