Changeset 1117


Ignore:
Timestamp:
Nov 9, 2012, 5:40:28 PM (12 years ago)
Author:
joergs
Message:

added function update client

File:
1 edited

Legend:

Unmodified
Added
Removed
  • opsi/server/dass-opsi-tools/usr/bin/opsiclient

    r1114 r1117  
    104104       
    105105    def createClient(self, name, opsiHostKey, description, notes, hardwareAddress, ipAddress):
    106         self.rpc.host_createOpsiClient( name, opsiHostKey, description, notes, hardwareAddress, ipAddress )
    107 
     106        #    self.rpc.host_createOpsiClient( name, opsiHostKey, description, notes, hardwareAddress, ipAddress )
     107        self.updateClient( name, opsiHostKey, description, notes, hardwareAddress, ipAddress )
     108
     109    def updateClient(self, src, opsiHostKey = None, description = None, notes = None, hardwareAddress = None, ipAddress = None, depot = None ):
     110        obj = {
     111          "id" : src,
     112          "type" : "OpsiClient",
     113        }
     114        if opsiHostKey:
     115            obj['opsiHostKey'] = opsiHostKey
     116        if description:
     117            obj['description'] = description
     118        if notes:
     119            obj['notes'] = notes           
     120        if hardwareAddress:
     121            obj['hardwareAddress'] = hardwareAddress
     122        if ipAddress:
     123            obj['ipAddress'] = ipAddress
     124
     125        if self.exists( src ):
     126            self.rpc.host_updateObject(obj)
     127        else:
     128            self.rpc.host_insertObject(obj)
     129           
     130        if depot:
     131            self.clientSetDepot(src,depot)
     132        return True
     133
     134
     135       
    108136    def clientSetDepot(self, name, depot):
    109137        self.rpc.configState_create( "clientconfig.depot.id", name, depot )       
     
    310338    parser_clean = subparsers.add_parser('clean', help='remove all product states from a opsi client' )
    311339    parser_clean.add_argument( 'src', help="source opsi client to clean" )
    312                
     340                   
    313341    parser_copy = subparsers.add_parser('copy', help='copy/create a opsi client from a template opsi client')   
    314342    parser_copy.add_argument( 'src', help="source/template opsi client" )
     
    331359    parser_info = subparsers.add_parser('info', help='print information about a opsi client' )
    332360    parser_info.add_argument( 'src', help="opsi client" )
     361   
     362    parser_update = subparsers.add_parser('update', help='update/create a opsi client')
     363    parser_update.add_argument( 'src', help="opsi client to be created" )
     364    parser_update.add_argument( '--ip', help="IP address of the new opsi client" )
     365    parser_update.add_argument( '--mac', help="MAC address of the new opsi client" )
     366    parser_update.add_argument( '--description', help="IP address of the new opsi client" )
     367    parser_update.add_argument( '--notes', help="MAC address of the new opsi client" )   
     368    parser_update.add_argument( '--depot', help="depot server the new opsi client should be located" )
    333369   
    334370    args = parser.parse_args()
     
    366402        result = opsi.listClients( args.product )       
    367403    elif args.subcommand == "info":
    368         result = opsi.info( args.src )       
     404        result = opsi.info( args.src )
     405    elif args.subcommand == "update":
     406        result = opsi.updateClient( args.src, None, args.description, args.notes, args.mac, args.ip, args.depot )
    369407    else:
    370408        print "not yet implemented"
Note: See TracChangeset for help on using the changeset viewer.