コード例 #1
0
    def startDHCPD(self):
        dhcpdsetting = open(setting.MONITOR_MODULE_PATH+'template/dhcpd.conf').read()% \
         { 'network_id': setting.PRIVATE_NETWORK_ID ,
          'netmask' : setting.PRIVATE_SUBNET,
          'ip_range' : setting.PRIVATE_RANGE,
          'server_ip' : setting.PRIVATE_NETWORK_IP,
          'host_declaration' : ''
         }
        f = open('/maekin/var/dhcp-distro.conf', 'w')
        f.write(dhcpdsetting)
        f.close()
        # create temp sub-interface
        subifsetting = open(setting.MONITOR_MODULE_PATH+'template/ifcfg-br0.1').read()% \
         { 'ip_addr': setting.PRIVATE_NETWORK_IP ,
          'netmask' : setting.PRIVATE_SUBNET,
         }
        f = open('/etc/sysconfig/network-scripts/ifcfg-br0.1', 'w')
        f.write(subifsetting)
        f.close()
        if general.runsh('ifup br0.1')[1] != '':
            print 'Exiting'
            exit(0)

        general.runsh('service dhcpd stop')
        print general.runsh('service dhcpd start')[0],
コード例 #2
0
 def cleanupHTTPD(self):
     os.unlink('/etc/httpd/conf.d/pxeboot.conf')
     try:
         open('/maekin/var/maekin-web')
     except IOError as e:
         #print 'Oh dear.'
         print general.runsh('service httpd stop')[0],
         return
     print general.runsh('service httpd reload')[0],
コード例 #3
0
 def startHTTPD(self):
     httpdsetting = open(setting.MONITOR_MODULE_PATH+'template/pxeboot.conf').read()% \
      { 'network_id': setting.PRIVATE_NETWORK_ID ,
       'prefix' : setting.PRIVATE_PREFIX
      }
     f = open('/etc/httpd/conf.d/pxeboot.conf', 'w')
     f.write(httpdsetting)
     f.close()
     general.runsh('service httpd stop')
     print general.runsh('service httpd start')[0],
コード例 #4
0
    def cleanupTFTP(self):
        tftpsetting = open(setting.MONITOR_MODULE_PATH +
                           'template/tftp').read() % {
                               'tftp_disable': 'yes'
                           }
        f = open('/etc/xinetd.d/tftp', 'w')
        f.write(tftpsetting)
        f.close()

        print general.runsh('service xinetd stop')[0],
コード例 #5
0
 def signal_handler(self, signal, frame):
     print general.red('Exiting')
     print 'Doing some cleanup...',
     self.cleanupDHCPD()
     self.cleanupHTTPD()
     self.cleanupTFTP()
     if not self.gotIP:
         general.runsh('service mklocd start')[0]
         print 'Starting mklocd:%s[  %s  ]' % (general.TAB,
                                               general.green('OK'))
     sys.exit(0)
コード例 #6
0
    def cleanupDHCPD(self):
        os.unlink('/maekin/var/dhcp-distro.conf')
        general.runsh('touch /maekin/var/dhcp-distro.conf')

        general.runsh('ifdown br0.1')
        result = connection.socketCall('localhost', 50000,
                                       'are_you_running_dhcpd', [])

        if result == 'yes':
            general.runsh('service dhcpd restart')
        else:
            print general.runsh('service dhcpd stop')[0],
コード例 #7
0
    def reloadDHCP(self):
        count = 0
        host_dec_string = ''
        for host in self.pxe_client:
            if self.pxe_client[host]['state'] != 'completed':
                host_dec_string += 'host netinstall%(netint_id)s { hardware ethernet %(netint_mac)s; fixed-address %(netint_ip)s; }\n' % {
                    'netint_id': str(count),
                    'netint_mac': host,
                    'netint_ip': self.pxe_client[host]['ip']
                }
                count = count + 1
        dhcpdsetting = open(setting.MONITOR_MODULE_PATH+'template/dhcpd.conf').read()% \
         { 'network_id': setting.PRIVATE_NETWORK_ID ,
          'netmask' : setting.PRIVATE_SUBNET,
          'ip_range' : setting.PRIVATE_RANGE,
          'server_ip' : setting.PRIVATE_NETWORK_IP,
          'host_declaration' : host_dec_string
         }
        f = open('/maekin/var/dhcp-distro.conf', 'w')
        f.write(dhcpdsetting)
        f.close()

        general.runsh('service dhcpd restart')
コード例 #8
0
    def insert_procedure(self):
        # assume all package installed
        # checkRPM('httpd')
        # checkRPM('tftp-server')
        # cehckRPM('dhcpd')
        if not self.gotIP:
            #print 'Stoping mklocd: ',
            print general.runsh('service mklocd stop')[0],
            #print '%s[  %s  ]'%(general.TAB, general.green('OK'))

        print 'Prepareing kickstart file: ',
        try:
            self.prepareKS()
        except Exception as e:
            print "%s[%s]" % (general.TAB, general.red('FAILED'))
        #print 'Starting httpd: ',
        self.startHTTPD()
        #print 'Starting xinetd: ',
        self.startTFTP()
        #print 'Starting dhcpd: ',
        self.startDHCPD()

        #print 'Press Ctrl+C to quit'
        #print 'waiting for new node...'
        self.show_ui()
        log = open('/var/log/messages', 'r')
        log.seek(0, 2)
        httplog = open('/var/log/httpd/access_log', 'r')
        httplog.seek(0, 2)
        while True:
            syslog = log.readline()
            self.check_new_node(syslog)

            access_log = httplog.readline()
            self.check_ks_request(access_log)
            self.check_install_request(access_log)
コード例 #9
0
    def startTFTP(self):
        # enable tftp-server
        tftpsetting = open(setting.MONITOR_MODULE_PATH +
                           'template/tftp').read() % {
                               'tftp_disable': 'no'
                           }
        f = open('/etc/xinetd.d/tftp', 'w')
        f.write(tftpsetting)
        f.close()

        general.runsh('mkdir -p /var/lib/tftpboot/pxelinux.cfg/')
        pxesetting = open(setting.MONITOR_MODULE_PATH +
                          'template/default').read() % {
                              'server_ip': setting.PRIVATE_NETWORK_IP
                          }
        f = open('/var/lib/tftpboot/pxelinux.cfg/default', 'w')
        f.write(pxesetting)
        f.close()

        general.runsh('service xinetd stop')
        print general.runsh('service xinetd start')[0],
コード例 #10
0
 def create_pxe_localboot(self, mac):
     mac = mac.replace(':', '-')
     general.runsh(
         'cp /maekin/lib/distro/template/localboot /var/lib/tftpboot/pxelinux.cfg/01-'
         + mac)