~allenap/maas/xxx-a-thon

« back to all changes in this revision

Viewing changes to src/provisioningserver/rpc/dhcp.py

  • Committer: LaMont Jones
  • Date: 2016-03-07 23:20:52 UTC
  • mfrom: (4657.1.84 maas)
  • mto: (4657.1.93 maas)
  • mto: This revision was merged to the branch mainline in revision 4660.
  • Revision ID: lamont@canonical.com-20160307232052-rgfxbq7dujj6s093
MergeĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
 
36
36
 
37
37
@synchronous
38
 
def configure(server, failover_peers, subnet_configs):
 
38
def configure(server, failover_peers, shared_networks, hosts, interfaces):
39
39
    """Configure the DHCPv6/DHCPv4 server, and restart it as appropriate.
40
40
 
41
41
    :param server: A `DHCPServer` instance.
42
42
    :param failover_peers: List of dicts with failover parameters for each
43
43
        subnet where HA is enabled.
44
 
    :param subnet_configs: List of dicts with subnet parameters for each
45
 
        subnet for which the DHCP server should serve DHCP. If no subnets
46
 
        are defined, the DHCP server will be stopped.
 
44
    :param shared_networks: List of dicts with shared network parameters that
 
45
        contain a list of subnets when the DHCP should server shared.
 
46
        If no shared network are defined, the DHCP server will be stopped.
 
47
    :param hosts: List of dicts with host parameters that
 
48
        contain a list of hosts the DHCP should statically.
 
49
    :param interfaces: List of interfaces that DHCP should use.
47
50
    """
48
 
    stopping = len(subnet_configs) == 0
 
51
    stopping = len(shared_networks) == 0
49
52
 
50
53
    if stopping:
51
54
        if os.path.exists(server.config_filename):
71
74
    else:
72
75
        dhcpd_config = get_config(
73
76
            server.template_basename, omapi_key=server.omapi_key,
74
 
            failover_peers=failover_peers, dhcp_subnets=subnet_configs)
75
 
        interfaces = {subnet['interface'] for subnet in subnet_configs}
 
77
            failover_peers=failover_peers, shared_networks=shared_networks,
 
78
            hosts=hosts)
 
79
        interfaces = {
 
80
            interface['name']
 
81
            for interface in interfaces
 
82
        }
76
83
        interfaces_config = ' '.join(sorted(interfaces))
77
84
        try:
78
85
            sudo_write_file(