Browse Source

Merge "Filter nameservers for undercloud networks" into stable/rocky

tags/9.4.1
Zuul 2 weeks ago
parent
commit
a0f6a5fc27
1 changed files with 11 additions and 4 deletions
  1. 11
    4
      extraconfig/post_deploy/undercloud_ctlplane_network.py

+ 11
- 4
extraconfig/post_deploy/undercloud_ctlplane_network.py View File

@@ -70,6 +70,9 @@ def _ensure_neutron_network(sdk):
70 70
 
71 71
     return network
72 72
 
73
+def _get_nameservers_for_version(servers, ipversion):
74
+    """Get list of nameservers for an IP version"""
75
+    return [s for s in servers if netaddr.IPAddress(s).version == ipversion]
73 76
 
74 77
 def _neutron_subnet_create(sdk, network_id, cidr, gateway, host_routes,
75 78
                            allocation_pool, name, segment_id, dns_nameservers):
@@ -86,7 +89,8 @@ def _neutron_subnet_create(sdk, network_id, cidr, gateway, host_routes,
86 89
                 allocation_pools=allocation_pool,
87 90
                 network_id=network_id,
88 91
                 segment_id=segment_id,
89
-                dns_nameservers=dns_nameservers)
92
+                dns_nameservers=_get_nameservers_for_version(dns_nameservers,
93
+                                                             6))
90 94
         else:
91 95
             subnet = sdk.network.create_subnet(
92 96
                 name=name,
@@ -98,7 +102,8 @@ def _neutron_subnet_create(sdk, network_id, cidr, gateway, host_routes,
98 102
                 allocation_pools=allocation_pool,
99 103
                 network_id=network_id,
100 104
                 segment_id=segment_id,
101
-                dns_nameservers=dns_nameservers)
105
+                dns_nameservers=_get_nameservers_for_version(dns_nameservers,
106
+                                                             4))
102 107
             print('INFO: Subnet created %s' % subnet)
103 108
     except Exception:
104 109
         print('ERROR: Create subnet %s failed.' % name)
@@ -116,7 +121,8 @@ def _neutron_subnet_update(sdk, subnet_id, cidr, gateway, host_routes,
116 121
                 name=name,
117 122
                 gateway_ip=gateway,
118 123
                 allocation_pools=allocation_pool,
119
-                dns_nameservers=dns_nameservers)
124
+                dns_nameservers=_get_nameservers_for_version(dns_nameservers,
125
+                                                             6))
120 126
         else:
121 127
             subnet = sdk.network.update_subnet(
122 128
                 subnet_id,
@@ -124,7 +130,8 @@ def _neutron_subnet_update(sdk, subnet_id, cidr, gateway, host_routes,
124 130
                 gateway_ip=gateway,
125 131
                 host_routes=host_routes,
126 132
                 allocation_pools=allocation_pool,
127
-                dns_nameservers=dns_nameservers)
133
+                dns_nameservers=_get_nameservers_for_version(dns_nameservers,
134
+                                                             4))
128 135
         print('INFO: Subnet updated %s' % subnet)
129 136
     except Exception:
130 137
         print('ERROR: Update of subnet %s failed.' % name)

Loading…
Cancel
Save