29
29
def get_interfaces_managed_by(nodegroup):
30
30
"""Return `NodeGroupInterface` objects for which `nodegroup` manages DHCP.
32
Returns only interfaces for which MAAS is supposed to serve DHCP. If DHCP
33
is disabled, or the node group is not accepted, an empty list will be
34
returned. Interfaces whose DHCP is not managed are not returned in any
32
Returns only interfaces for which MAAS is supposed to serve DHCP.
33
If the node group is not accepted, an empty list will be returned.
34
Interfaces whose DHCP is not managed are not returned in any case.
37
if settings.DHCP_CONNECT and nodegroup.status == NODEGROUP_STATUS.ACCEPTED:
36
if nodegroup.status == NODEGROUP_STATUS.ACCEPTED:
38
37
return nodegroup.get_managed_interfaces()
43
42
def configure_dhcp(nodegroup):
44
43
"""Write the DHCP configuration file and restart the DHCP server."""
44
# Let's get this out of the way first up shall we?
45
if not settings.DHCP_CONNECT:
46
# For the uninitiated, DHCP_CONNECT is set, by default, to False
47
# in all tests and True in non-tests. This avoids unnecessary
48
# calls to async tasks.
45
51
# Circular imports.
46
52
from maasserver.dns import get_dns_server_address
48
54
interfaces = get_interfaces_managed_by(nodegroup)
55
if interfaces is None:
52
58
# Make sure this nodegroup has a key to communicate with the dhcp