Changeset 206 for trunk/src/pxeconfig.py


Ignore:
Timestamp:
12/18/12 12:53:42 (11 years ago)
Author:
bas
Message:

added a new option to skip hostname lookup failures

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/pxeconfig.py

    r203 r206  
    7474START        = 'start'
    7575END          = 'end'
    76 VERSION      = '3.1.0'
     76VERSION      = '4.2.0'
    7777
    7878def select_pxe_configfile():
     
    233233        SCRIPT_HOOK_ADD = False,
    234234        SCRIPT_HOOK_REMOVE = False,
     235        SKIP_HOSTNAME_ERRORS = False,
    235236    )
    236237
     
    263264        dest   = 'VERBOSE',
    264265        help   = 'Make the program more verbose (default: False)'
     266    )
     267
     268    p.add_option('-H', '--skip-hostname-lookup-error',
     269        action = 'store_true',
     270        dest   = 'SKIP_HOSTNAME_LOOKUP_ERROR',
     271        help   = 'When hostname lookup fails, skip it (default: False)'
    265272    )
    266273
     
    309316
    310317
     318    if not options.SKIP_HOSTNAME_LOOKUP_ERROR:
     319        try:
     320            options.SKIP_HOSTNAME_LOOKUP_ERROR = defaults['skip_hostname_lookup_error']
     321        except KeyError, detail:
     322            pass
     323
    311324    ## This will be obsoleted by client_script_hook_add
    312325    #
     
    343356            mac_2_hex(host, options)
    344357        else:
    345             host_2_hex(host, options)
     358            try:
     359                host_2_hex(host, options)
     360            except PxeConfig, detail:
     361
     362                if options.SKIP_HOSTNAME_LOOKUP_ERROR:
     363                    print 'Skipping Hostname lookup failed for: %s' %(host)
     364                    continue
     365                else:
     366                    print detail
     367                    sys.exit(1)
    346368
    347369def main():
Note: See TracChangeset for help on using the changeset viewer.