Changeset 117 for trunk


Ignore:
Timestamp:
04/10/08 18:41:48 (16 years ago)
Author:
bas
Message:

pxeconfig.in:

  • Fixed many small bugs
  • added -w,--equal-width option
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Changelog

    r114 r117  
    33   pxe filemame menu.
    44   Author: Bas van der Vlies
     5
     6 - Fixed some spell errors
     7   Author: Bas van der Vlies
     8
     9 - Add new optione -w/--equal-width, eg:
     10    * pxeconfig -w --basename gb-r40n -s 1 -e 2 --filename default.install
     11
     12   Will create links to default.install for hosts:
     13        gb-r40n09
     14        gb-r40n10
     15
     16   Suggested by : Ole Holm Nielsen
     17   Implemented by : Bas van der Vlies
     18
     19 - Fixed a bug when pxeconfig directory was set in pxeconfig.conf it was not
     20   used at all.
     21   Author: Bas van der Vlies
     22
     23 - Fixed a bug in short option '-b' (basename) must have an argument.
     24   Author: Bas van der Vlies
     25   
    526
    6271.0.0
  • trunk/pxeconfig.conf

    r75 r117  
    11[DEFAULT]
    2 pxe_config_dir  : /tftpboot/pxelinux.cfg
    3 debug           : 0
     2pxe_config_dir  : ./pxelinux.cfg
     3debug           : 1
  • trunk/pxeconfig.in

    r114 r117  
    7171#
    7272DEBUG=0
     73VERBOSE=0
    7374
    7475# Constants
     
    8283REMOVE='remove'
    8384INTERACTIVE='interactive'
    84 VERSION='1.0.0'
    85 
    86 SHORTOPT_LIST='be:f:hin:s:rV'
    87 LONGOPT_LIST=['basename=', 'debug', 'end=', 'file=', 'help', 'interactive', 'net=', 'start=', 'remove', 'version' ]
     85EQUALWIDTH='equalwidth'
     86VERSION='1.1.0'
     87
     88SHORTOPT_LIST='b:e:f:hin:s:rwvV'
     89LONGOPT_LIST=[ 'basename=', 'debug', 'end=', 'equal-width',
     90    'file=', 'help', 'interactive', 'net=', 'start=',
     91        'remove', 'verbose', 'version', 'equal-width'
     92        ]
     93
     94def verbose(str):
     95        if VERBOSE:
     96                print '%s'
    8897
    8998def ReadConfig(file):
     
    339348       
    340349        global DEBUG
     350        global VERBOSE
    341351
    342352        # if nothing is specified then print usage and exit
     
    380390                        binfo[START] = value
    381391
     392                elif opt in ['-w', '--equal-width']:
     393                        binfo[EQUALWIDTH] = True
     394
     395                elif opt in ['-v', '--verbose']:
     396                        VERBOSE = 1
     397
    382398                elif opt in ['-V', '--version']:
    383399                        print VERSION
     
    388404def host_2_net(hosts, binfo):
    389405        """
    390         Convert hostsname to a net address that can be handled by manage_links function
     406        Convert hostname(s) to a net address that can be handled by manage_links function
    391407        """
    392408        for host in hosts:
     
    414430                sys.exit(1)
    415431
     432        if binfo[EQUALWIDTH]:
     433                width = len(str(binfo[END]))
     434
    416435        hostnames = list()
    417436        for i in xrange(binfo[START], binfo[END] + 1):
    418                 hostname = '%s%d' %(binfo[BASENAME], i)
     437                if binfo[EQUALWIDTH]:
     438                        hostname = '%s%0*d' %(binfo[BASENAME], width, i)
     439                else:
     440                        hostname = '%s%d' %(binfo[BASENAME], i)
     441
    419442                if DEBUG:
    420443                        print 'host = %s, Basename = %s, number = %d' %(hostname, binfo[BASENAME], i)
     
    427450        #
    428451        global DEBUG
     452        global PXE_CONF_DIR
    429453       
    430454        bootinfo = {}
    431         bootinfo[REMOVE] = 0
     455        bootinfo[REMOVE] = False
     456        bootinfo[EQUALWIDTH] = False
    432457       
    433458        configfile = '@pxeconfig_conf@'
     
    438463                if not DEBUG:
    439464                        DEBUG = int(settings['debug'])
     465
    440466        except KeyError:
    441467                pass
    442468
     469        if not os.path.isdir(PXE_CONF_DIR):
     470                print 'pxeconfig directory: %s does not exists' %(PXE_CONF_DIR)
     471                sys.exit(1)
     472
    443473        check_args(sys.argv, bootinfo)
    444474       
Note: See TracChangeset for help on using the changeset viewer.