- Timestamp:
- 03/28/07 12:50:40 (17 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/pxeconfig
r74 r75 30 30 Usage: pxeconfig 31 31 32 [-d|--directory <pxe_config_dir>]33 32 [-f|--file <filename>] [hostname(s)] 34 33 [-i|--interactive] … … 82 81 INTERACTIVE='interactive' 83 82 84 SHORTOPT_LIST='hV d:n:s:e:f:ri'85 LONGOPT_LIST=['help', 'version', ' directory=', 'net=', 'start=', 'end=', 'file=', 'remove', 'debug' , 'interactive' ]86 87 def ReadConfig(file , name):83 SHORTOPT_LIST='hVn:s:e:f:ri' 84 LONGOPT_LIST=['help', 'version', 'net=', 'start=', 'end=', 'file=', 'remove', 'debug' , 'interactive' ] 85 86 def ReadConfig(file): 88 87 """ 89 88 Parse the config file … … 93 92 sys.exit(1) 94 93 95 config = ConfigParser. ConfigParser()94 config = ConfigParser.RawConfigParser() 96 95 try: 97 96 config.read(file) … … 100 99 sys.exit(1) 101 100 102 # Use given project name else use defaults101 # Not yet uses 103 102 # 104 if name: 105 if not config.has_section(name): 106 print "Not a valid project name: %s" %name 107 print "Valid names: %s" %config.sections() 108 sys.exit(1) 109 110 project = dict() 111 for option in config.options(name): 112 project[option] = config.get(name, option) 113 else: 114 project = config.defaults() 115 116 return project 103 #projects = {} 104 #for section in config.sections(): 105 # projects[section] = {} 106 # for option in config.options(section): 107 # projects[section][option] = config.get(section, option) 108 109 stanza = config.defaults() 110 return stanza 117 111 118 112 def select_pxe_configfile(): … … 282 276 hostnames: the rest of the command lines options that are not-parseble. 283 277 """ 284 global PXE_CONF_DIR285 global DEBUG286 287 278 try: 288 279 opts, args = getopt.getopt(argv[1:], SHORTOPT_LIST, LONGOPT_LIST) … … 295 286 # 296 287 for opt,value in opts: 297 298 if opt in ['-d', '--directory']:299 if os.path.isdir(value):300 PXE_CONF_DIR = value301 else:302 print 'Directory %s does not exists\n' %value303 sys.exit(1)304 305 288 elif opt in ['-i', '--interactive']: 306 289 binfo[INTERACTIVE] = 1 … … 356 339 # A dictionary holding the boot info 357 340 # 341 global PXE_CONF_DIR 342 global DEBUG 343 358 344 bootinfo = {} 359 345 bootinfo[REMOVE] = 0 360 346 361 project_name = None362 347 configfile = 'pxeconfig.conf' 363 settings = ReadConfig(configfile, project_name) 364 print settings 365 sys.exit(1) 348 settings = ReadConfig(configfile) 349 350 try: 351 PXE_CONF_DIR = settings['pxe_config_dir'] 352 DEBUG = settings['debug'] 353 except KeyError: 354 pass 355 366 356 hostnames = check_args(sys.argv, bootinfo) 367 357
Note: See TracChangeset
for help on using the changeset viewer.