Ignore:
Timestamp:
Aug 15, 2012, 1:41:31 PM (12 years ago)
Author:
joergs
Message:

added subcommand

File:
1 edited

Legend:

Unmodified
Added
Removed
  • opsi/server/dass-opsi-tools/usr/bin/opsi-client.py

    r1049 r1050  
    7575    parser.add_argument( '--debug', action='store_true', help="enable debugging output" )
    7676    #parser.add_argument( '--verbose', type=bool, help="add debugging output" )
    77     parser.add_argument( 'src', help="source/template opsi client" )
    78     parser.add_argument( 'dst', help="opsi client to be created" )
    79     parser.add_argument( '--ip', help="IP address of the new opsi client" )
    80     parser.add_argument( '--mac', help="MAC address of the new opsi client" )
    81     parser.add_argument( '--depot', help="depot server the new opsi client should be located" )
    8277    parser.add_argument( '--url', help="OPSI Server JSON-RPC url, normally https://<username>:<password>@<OPSI-SERVER>:4447/rpc" )
    8378
     79    subparsers = parser.add_subparsers(title='subcommands',
     80        description='valid subcommands',
     81        help='additional help',
     82        dest='subcommand' )
    8483
     84    parser_list = subparsers.add_parser('list', help='list all opsi clients' )
     85
     86    parser_exists = subparsers.add_parser('exists', help='check, if a opsi clients exists' )
     87    parser_exists.add_argument( 'src', help="source opsi client" )
     88   
     89    parser_clean = subparsers.add_parser('clean', help='remove all product states from a opsi client' )
     90    parser_clean.add_argument( 'src', help="source opsi client to clean" )
     91               
     92    parser_copy = subparsers.add_parser('copy', help='copy/create a opsi client from a template opsi client')   
     93    parser_copy.add_argument( 'src', help="source/template opsi client" )
     94    parser_copy.add_argument( 'dst', help="opsi client to be created" )
     95    parser_copy.add_argument( '--ip', help="IP address of the new opsi client" )
     96    parser_copy.add_argument( '--mac', help="MAC address of the new opsi client" )
     97    parser_copy.add_argument( '--depot', help="depot server the new opsi client should be located" )
     98
     99    #>>> parser_bar.set_defaults(func=bar)
     100    #>>> # parse the args and call whatever function was selected
     101    #>>> args = parser.parse_args('bar XYZYX'.split())
     102    #>>> args.func(args)   
     103   
     104   
    85105    args = parser.parse_args()
     106   
    86107   
    87108    urlJsonRpc = UrlJsonRpc
     
    90111   
    91112    opsi=OpsiRpc( urlJsonRpc, args.debug )
    92     opsi.copyClient( args.src, args.dst, args.ip, args.mac, args.depot )
     113   
     114    if args.subcommand == "copy":
     115        opsi.copyClient( args.src, args.dst, args.ip, args.mac, args.depot )
     116    else:
     117        print "not yet implemented"
     118
    93119    if args.debug: print "end"
    94120   
Note: See TracChangeset for help on using the changeset viewer.