Exemplo n.º 1
0
def mmc_pxe_configure(interface, ipaddr, netmask):
    net = numToDottedQuad(dottedQuadToNum(netmask) & dottedQuadToNum(ipaddr))

    if not getSubnets(net):
        bitlength = reduce(lambda x, y: x + (y + 1)/32, map(int, netmask.split(".")), 0)
        addSubnet(net, bitlength, "Pulse2 Subnet");

    if not getPoolsRanges(net):
        ips = IP('%s/%s' % (ipaddr, netmask), make_net=True)
        for ip in ips:
            if not str(ip) == ipaddr and not str(ip).endswith('0'):
                start = str(ip)
                break
        for nb in (50, 25, 10, 5):
            try:
                end = str(ips[nb])
                break
            except:
                pass
        if start and end:
            addPool(net, "Imaging pool", start, end)

    # Configure pxe
    setSubnetStatement(net, "filename", "\"/bootloader/pxe_boot\"")
    setSubnetStatement(net, "next-server", ipaddr)
    #/bootloader/pxe_boot
    setSubnetAuthoritative(net)
Exemplo n.º 2
0
 def configure_dhcp():
     subnet = getSubnet(network)
     if not subnet:
         addSubnet(network, netmask, realm)
         setSubnetDescription(network, 'AD network')
         setSubnetAuthoritative(network)
         setSubnetOption(network, 'domain-name', '\"' + realm + '\"')
         setSubnetOption(network, 'domain-name-servers', addr)
         start = IP(ip.net().int() + 100)
         end = IP(start.int() + 99)
         addPool(network, 'ADpool', str(start), str(end))
         shlaunch("systemctl restart dhcpd")
     print("### Done configure_dhcp")