Changeset 53
- Timestamp:
- 09/19/05 15:55:56 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/pxeconfig/pxeconfig
r51 r53 31 31 32 32 [-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] 33 36 [-V|--version] 34 [-n|--net <C-net> -s|--start <number> -e|--end <number> -f|--file <filename>]35 [-f|--file <filename>] [hostname(s)]36 37 37 38 With this program you can configure which PXE configuration file a node … … 75 76 START='start' 76 77 END='end' 77 VERSION='0.5' 78 79 SHORTOPT_LIST='hVd:n:s:e:f:' 80 LONGOPT_LIST=['help', 'version', 'directory=', 'net=', 'start=', 'end=', 'file='] 78 VERSION='0.6' 79 REMOVE='remove' 80 81 SHORTOPT_LIST='hVd:n:s:e:f:r' 82 LONGOPT_LIST=['help', 'version', 'directory=', 'net=', 'start=', 'end=', 'file=', 'remove', 'debug'] 81 83 82 84 def select_pxe_configfile(): … … 125 127 return files[index-1] 126 128 127 def create_links(dict):129 def manage_links(dict): 128 130 """ 129 131 Create the links in the PXE_CONF_DIR, … … 136 138 for i in range(dict[START], dict[END]+1): 137 139 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) 146 152 147 153 def convert_network(net, prefix=''): … … 243 249 """ 244 250 global PXE_CONF_DIR 251 global DEBUG 245 252 246 253 try: … … 277 284 print VERSION 278 285 sys.exit(0) 286 287 elif opt in ['-r', '--remove']: 288 binfo[REMOVE] = 1 289 290 elif opt in ['--debug']: 291 DEBUG = 1 279 292 280 293 elif opt in ['-h', '--help']: … … 299 312 binfo[START] = int(net[3]) 300 313 binfo[END] = int(net[3]) 301 create_links(binfo)314 manage_links(binfo) 302 315 303 316 … … 306 319 # 307 320 bootinfo = {} 321 bootinfo[REMOVE] = 0 308 322 309 323 hostnames = check_args(sys.argv, bootinfo) 324 325 if bootinfo[REMOVE]: 326 bootinfo[FILENAME] = 'remove_boot_file' 310 327 311 328 … … 315 332 if hostnames: 316 333 if not bootinfo.has_key(FILENAME): 317 334 bootinfo[FILENAME] = select_pxe_configfile() 318 335 hosts_links(hostnames,bootinfo) 319 336 else: … … 322 339 else: 323 340 interactive(bootinfo) 324 create_links(bootinfo)341 manage_links(bootinfo) 325 342 326 343 if __name__ == '__main__':
Note: See TracChangeset
for help on using the changeset viewer.