apply fix for ipv6 addresses in dhcpd.conf
https: //bugs.launchpad.net/maas/+bug/2027621 Change-Id: I1dddfe235e670d187c4b0b87b6a669eb9900d976 Signed-off-by: Anselme, Schubert (sa246v) <sa246v@att.com>
This commit is contained in:
parent
736c936394
commit
7d0f064d62
|
@ -0,0 +1,72 @@
|
|||
diff --git a/src/maasserver/dhcp.py b/src/maasserver/dhcp.py
|
||||
index 2d61705..21ecda8 100644
|
||||
--- a/src/maasserver/dhcp.py
|
||||
+++ b/src/maasserver/dhcp.py
|
||||
@@ -224,15 +224,17 @@ def ip_is_on_vlan(ip_address, vlan):
|
||||
)
|
||||
|
||||
|
||||
-def get_ip_address_for_interface(interface, vlan):
|
||||
+def get_ip_address_for_interface(interface, vlan, ip_version: int):
|
||||
"""Return the IP address for `interface` on `vlan`."""
|
||||
for ip_address in interface.ip_addresses.all():
|
||||
- if ip_is_on_vlan(ip_address, vlan):
|
||||
+ if ip_is_version(ip_address, ip_version) and ip_is_on_vlan(
|
||||
+ ip_address, vlan
|
||||
+ ):
|
||||
return ip_address
|
||||
return None
|
||||
|
||||
|
||||
-def get_ip_address_for_rack_controller(rack_controller, vlan):
|
||||
+def get_ip_address_for_rack_controller(rack_controller, vlan, ip_version: int):
|
||||
"""Return the IP address for `rack_controller` on `vlan`."""
|
||||
# First we build a list of all interfaces that have an IP address
|
||||
# on that vlan. Then we pick the best interface for that vlan
|
||||
@@ -243,10 +245,12 @@ def get_ip_address_for_rack_controller(rack_controller, vlan):
|
||||
matching_interfaces = set()
|
||||
for interface in interfaces:
|
||||
for ip_address in interface.ip_addresses.all():
|
||||
- if ip_is_on_vlan(ip_address, vlan):
|
||||
+ if ip_is_version(ip_address, ip_version) and ip_is_on_vlan(
|
||||
+ ip_address, vlan
|
||||
+ ):
|
||||
matching_interfaces.add(interface)
|
||||
interface = get_best_interface(matching_interfaces)
|
||||
- return get_ip_address_for_interface(interface, vlan)
|
||||
+ return get_ip_address_for_interface(interface, vlan, ip_version)
|
||||
|
||||
|
||||
@typed
|
||||
@@ -489,17 +493,19 @@ def make_subnet_config(
|
||||
return subnet_config
|
||||
|
||||
|
||||
-def make_failover_peer_config(vlan, rack_controller):
|
||||
+def make_failover_peer_config(vlan, rack_controller, ip_version: int):
|
||||
"""Return DHCP failover peer configuration dict for a rack controller."""
|
||||
is_primary = vlan.primary_rack_id == rack_controller.id
|
||||
interface_ip_address = get_ip_address_for_rack_controller(
|
||||
- rack_controller, vlan
|
||||
+ rack_controller, vlan, ip_version
|
||||
)
|
||||
if is_primary:
|
||||
peer_rack = vlan.secondary_rack
|
||||
else:
|
||||
peer_rack = vlan.primary_rack
|
||||
- peer_address = get_ip_address_for_rack_controller(peer_rack, vlan)
|
||||
+ peer_address = get_ip_address_for_rack_controller(
|
||||
+ peer_rack, vlan, ip_version
|
||||
+ )
|
||||
name = "failover-vlan-%d" % vlan.id
|
||||
return (
|
||||
name,
|
||||
@@ -650,7 +656,7 @@ def get_dhcp_configure_for(
|
||||
if has_secondary:
|
||||
# Generate the failover peer for this VLAN.
|
||||
peer_name, peer_config, peer_rack = make_failover_peer_config(
|
||||
- vlan, rack_controller
|
||||
+ vlan, rack_controller, ip_version
|
||||
)
|
||||
else:
|
||||
peer_name, peer_config, peer_rack = None, None, None
|
Loading…
Reference in New Issue