Changeset 53


Ignore:
Timestamp:
09/19/05 15:55:56 (19 years ago)
Author:
bas
Message:

pxeconfig:

Added --debug and --remover option
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pxeconfig/pxeconfig

    r51 r53  
    3131
    3232 [-d|--directory <pxe_config_dir>]
     33 [-f|--file <filename>] [hostname(s)]
     34 [-n|--net <C-net> -s|--start <number> -e|--end <number> -f|--file <filename>]
     35 [-r|--remove]
    3336 [-V|--version]
    34  [-n|--net <C-net> -s|--start <number> -e|--end <number> -f|--file <filename>]
    35  [-f|--file <filename>] [hostname(s)]
    3637
    3738With this program you can configure which PXE configuration file a node
     
    7576START='start'
    7677END='end'
    77 VERSION='0.5'
    78 
    79 SHORTOPT_LIST='hVd:n:s:e:f:'
    80 LONGOPT_LIST=['help', 'version', 'directory=', 'net=', 'start=', 'end=', 'file=']
     78VERSION='0.6'
     79REMOVE='remove'
     80
     81SHORTOPT_LIST='hVd:n:s:e:f:r'
     82LONGOPT_LIST=['help', 'version', 'directory=', 'net=', 'start=', 'end=', 'file=', 'remove', 'debug']
    8183
    8284def select_pxe_configfile():
     
    125127  return files[index-1]
    126128
    127 def create_links(dict):
     129def manage_links(dict):
    128130  """
    129131  Create the links in the PXE_CONF_DIR,
     
    136138  for i in range(dict[START], dict[END]+1):
    137139    haddr = '%s%02X' %(naddr, i)
    138     if DEBUG:
    139       print 'linking %s to %s' %(haddr, pxe_filename)
    140 
    141     if os.path.exists(haddr):
    142        os.unlink(haddr)
    143 
    144     os.symlink(pxe_filename, haddr)
    145 
     140
     141    if dict[REMOVE]:
     142       if DEBUG:
     143          print 'removing %s/%s' %(PXE_CONF_DIR, haddr)
     144       if os.path.exists(haddr):
     145          os.unlink(haddr)
     146    else:
     147       if DEBUG:
     148          print 'linking %s to %s' %(haddr, pxe_filename)
     149       if os.path.exists(haddr):
     150          os.unlink(haddr)
     151       os.symlink(pxe_filename, haddr)
    146152
    147153def convert_network(net, prefix=''):
     
    243249  """
    244250  global PXE_CONF_DIR
     251  global DEBUG
    245252
    246253  try:
     
    277284      print VERSION
    278285      sys.exit(0)
     286
     287    elif opt in ['-r', '--remove']:
     288      binfo[REMOVE] = 1
     289
     290    elif opt in ['--debug']:
     291      DEBUG = 1
    279292
    280293    elif opt in ['-h', '--help']:
     
    299312                binfo[START] = int(net[3])
    300313                binfo[END] =  int(net[3])
    301                 create_links(binfo)
     314                manage_links(binfo)
    302315
    303316
     
    306319  #
    307320  bootinfo = {}
     321  bootinfo[REMOVE] = 0
    308322
    309323  hostnames = check_args(sys.argv, bootinfo)
     324
     325  if bootinfo[REMOVE]:
     326     bootinfo[FILENAME] = 'remove_boot_file'
    310327
    311328
     
    315332  if hostnames:
    316333        if not bootinfo.has_key(FILENAME):
    317                 bootinfo[FILENAME] = select_pxe_configfile()
     334              bootinfo[FILENAME] = select_pxe_configfile()
    318335        hosts_links(hostnames,bootinfo)
    319336  else:
     
    322339        else:
    323340                interactive(bootinfo)
    324         create_links(bootinfo)
     341        manage_links(bootinfo)
    325342
    326343if __name__ == '__main__':
Note: See TracChangeset for help on using the changeset viewer.