예제 #1
0
파일: mmc_dhcp.py 프로젝트: neoclust/mss
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)
예제 #2
0
파일: provision.py 프로젝트: neoclust/mss
 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")