Browse Source

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

tags/10.6.1
Zuul 2 weeks ago
parent
commit
4e2dddb524
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

@@ -61,6 +61,9 @@ def _ensure_neutron_network(sdk):
61 61
 
62 62
     return network
63 63
 
64
+def _get_nameservers_for_version(servers, ipversion):
65
+    """Get list of nameservers for an IP version"""
66
+    return [s for s in servers if netaddr.IPAddress(s).version == ipversion]
64 67
 
65 68
 def _neutron_subnet_create(sdk, network_id, cidr, gateway, host_routes,
66 69
                            allocation_pools, name, segment_id, dns_nameservers):
@@ -77,7 +80,8 @@ def _neutron_subnet_create(sdk, network_id, cidr, gateway, host_routes,
77 80
                 allocation_pools=allocation_pools,
78 81
                 network_id=network_id,
79 82
                 segment_id=segment_id,
80
-                dns_nameservers=dns_nameservers)
83
+                dns_nameservers=_get_nameservers_for_version(dns_nameservers,
84
+                                                             6))
81 85
         else:
82 86
             subnet = sdk.network.create_subnet(
83 87
                 name=name,
@@ -89,7 +93,8 @@ def _neutron_subnet_create(sdk, network_id, cidr, gateway, host_routes,
89 93
                 allocation_pools=allocation_pools,
90 94
                 network_id=network_id,
91 95
                 segment_id=segment_id,
92
-                dns_nameservers=dns_nameservers)
96
+                dns_nameservers=_get_nameservers_for_version(dns_nameservers,
97
+                                                             4))
93 98
             print('INFO: Subnet created %s' % subnet)
94 99
     except Exception:
95 100
         print('ERROR: Create subnet %s failed.' % name)
@@ -107,7 +112,8 @@ def _neutron_subnet_update(sdk, subnet_id, cidr, gateway, host_routes,
107 112
                 name=name,
108 113
                 gateway_ip=gateway,
109 114
                 allocation_pools=allocation_pools,
110
-                dns_nameservers=dns_nameservers)
115
+                dns_nameservers=_get_nameservers_for_version(dns_nameservers,
116
+                                                             6))
111 117
         else:
112 118
             subnet = sdk.network.update_subnet(
113 119
                 subnet_id,
@@ -115,7 +121,8 @@ def _neutron_subnet_update(sdk, subnet_id, cidr, gateway, host_routes,
115 121
                 gateway_ip=gateway,
116 122
                 host_routes=host_routes,
117 123
                 allocation_pools=allocation_pools,
118
-                dns_nameservers=dns_nameservers)
124
+                dns_nameservers=_get_nameservers_for_version(dns_nameservers,
125
+                                                             4))
119 126
         print('INFO: Subnet updated %s' % subnet)
120 127
     except Exception:
121 128
         print('ERROR: Update of subnet %s failed.' % name)

Loading…
Cancel
Save