Changeset 125 for trunk


Ignore:
Timestamp:
04/13/08 18:46:59 (16 years ago)
Author:
bas
Message:

pxeconfig.in:

  • renamed some functions
  • added some verbose commands
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pxeconfig.in

    r123 r125  
    211211           start number, end number
    212212  """
     213  str = 'manage_links'
     214  verbose(str)
     215
    213216  os.chdir(PXE_CONF_DIR)
    214217  naddr = dict[NETWORK]
     
    230233       os.symlink(pxe_filename, haddr)
    231234
    232 def convert_network(net):
     235def net_2_hex(net):
    233236        """
    234237        This function checks if the give network is a Class C-network and will
    235238        convert the network address to a hex address if true.
    236239        """
    237         str = 'convert_network : %s' %(net)
     240        str = 'net_2_hex : %s' %(net)
    238241        verbose(str)
    239242       
     
    286289
    287290                try:
    288                         naddr = convert_network(network)
     291                        naddr = net_2_hex(network)
    289292                        break
    290293                except PxeConfig, detail:
     
    344347
    345348        if hostnames:
    346                 host_2_net(hostnames, binfo)
     349                host_2_hex(hostnames, binfo)
    347350                sys.exit(0)
    348351               
     
    356359                else:
    357360                        set_padding(binfo)
    358                         create_links =  base_2_net
     361                        create_links =  base_2_host
    359362
    360363        elif binfo.has_key(NETWORK):
     
    512515
    513516                elif opt in ['-n', '--net']:
    514                         binfo[NETWORK] = convert_network(value)
     517                        binfo[NETWORK] = net_2_hex(value)
    515518                       
    516519                elif opt in ['-r', '--remove']:
     
    548551        check_args(binfo, args)
    549552
    550 def host_2_net(hosts, binfo):
     553def host_2_hex(hosts, binfo):
    551554        """
    552555        Convert hostname(s) to a net address that can be handled by manage_links function
    553556        """
     557        str = 'host_2_hex: %s' %hosts
     558        verbose(str)
     559
    554560        for host in hosts:
    555561                try:
     
    562568                cnet = string.joinfields(net[0:3], '.')
    563569
    564                 binfo[NETWORK] = convert_network(cnet)
     570                binfo[NETWORK] = net_2_hex(cnet)
    565571                binfo[START] = int(net[3])
    566572                binfo[END] =  int(net[3])
    567573                manage_links(binfo)
    568574
    569 def base_2_net(binfo):
     575def base_2_host(binfo):
    570576        """
    571577        Construct hostname(s) from the supplied basename and start and end numbers
    572578        """
     579        str = 'base_2_host'
     580        verbose(str)
     581
    573582        start = binfo[START]
    574583        end = binfo[END]
     
    589598                hostnames.append(hostname)
    590599
    591         host_2_net(hostnames,binfo)
     600        host_2_hex(hostnames,binfo)
    592601
    593602def rack_2_net(binfo):
    594603        """
    595604        """
     605        str = 'rack_2_net'
     606        verbose(str)
    596607        basename = binfo[BASENAME]
    597608        start = binfo[RACK][START]
    598609        end = binfo[RACK][END]
    599 
    600610
    601611        if start > end:
     
    619629                        print 'rack ', new_bootinfo
    620630
    621                 base_2_net(new_bootinfo)
     631                base_2_host(new_bootinfo)
    622632
    623633def main():
Note: See TracChangeset for help on using the changeset viewer.