Changeset 132


Ignore:
Timestamp:
04/14/09 14:14:32 (15 years ago)
Author:
bas
Message:

pxeconfig.in:

  • First port to new option parser module
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pxeconfig.in

    r131 r132  
    6969import ConfigParser
    7070import re
     71
     72# import from the sara_python_modules
     73from sara import AdvancedParser
    7174
    7275# Global Variables
     
    452455
    453456        set_padding(binfo[id]) 
     457
     458def add_options(p):
     459        """
     460        add the default options
     461        """
     462        p.set_defaults(
     463                DEBUG   = False,
     464                VERBOSE = False,
     465                DRY_RUN = False,
     466                REMOVE  = False,
     467                VERSION  = False,
     468        )
     469
     470        p.add_option('-f', '--filename',
     471                action = 'store',
     472                dest   = 'filename',
     473                help   = 'Specifies which PXE filename must be use'
     474        )
     475
     476        p.add_option('-r', '--remove',
     477                action = 'store_true',
     478                dest   = 'REMOVE',
     479                help   = 'Removes the PXE filename for a host(s)'
     480        )
     481
     482        p.add_option('-V', '--version',
     483                action = 'store_true',
     484                dest   = 'VERSION',
     485                help   = 'Removes the PXE filename for a host(s)'
     486        )
     487
     488
     489def new_parser(argv):
     490        """
     491        Make use of sara advance parser module
     492        """
     493        parser = AdvancedParser.AdvancedParser(version='Version: 3.0.0', usage=__doc__)
     494        add_options(parser)
     495
     496        options, args = parser.parse_args()
     497        return (options, args)
     498
    454499       
    455500def parse_args(argv, binfo):
     
    626671                base_2_host(new_bootinfo)
    627672
     673
     674def new_main():
     675
    628676def main():
    629677        # A dictionary holding the boot info
     
    658706if __name__ == '__main__':
    659707        try:
    660                 main()
     708                new_parser(sys.argv)
     709                new_main()
    661710        except PxeConfig, detail:
    662711                print detail
Note: See TracChangeset for help on using the changeset viewer.