source: opsi/server/opsi-tools-dass-it/usr/bin/opsi-client-copy.py @ 1046

Last change on this file since 1046 was 1046, checked in by joergs, 9 years ago

initiale Tests auf json-rpc basis

  • Property svn:executable set to *
File size: 2.0 KB
Line 
1#!/usr/bin/env python
2
3# Skript erstellen, dass ein OPSI-Rechner-Eintrag kopiert.
4# D.h. die Produkte, Anforderung.
5# Ggf. optional Stand und ggf. Versionsnummer
6# Ggf. optional ProductProperties
7
8                #self.command("opsi-admin -d method host_createOpsiClient "+ \
9                        #computername + " null " + "\\'"+description+"\\'" + \
10                        #" \\'created by dassadmin\\' " + mac_address + " " + \
11                        #ip_address)
12                #method host_createOpsiClient id *opsiHostKey *description *notes *hardwareAddress *ipAddress *inventoryNumber *oneTimePassword *created *lastSeen
13                #self.command("opsi-admin -d method configState_create clientconfig.depot.id " + \
14                        #computername + " " + depotName)                       
15
16import jsonrpc
17from pprint import pprint
18
19UrlJsonRpc="https://joergs:linuxlinux@opsi4.joergs.dass-it:4447/rpc"
20
21class OpsiRpc:
22    def __init__(self, urlJsonRpc=UrlJsonRpc):
23        self.urlJsonRpc=urlJsonRpc
24        self.rpcProxy=jsonrpc.ServiceProxy(self.urlJsonRpc)
25       
26    def dump(self):
27        print self.urlJsonRpc
28        print self.rpcProxy.getClientIds_list()
29       
30    def copyClient( self, src, dst, hardwareAddress, ipAddress ):
31   
32        #method host_createOpsiClient id *opsiHostKey *description *notes *hardwareAddress *ipAddress *inventoryNumber *oneTimePassword *created *lastSeen
33        id=dst
34        opsiHostKey=None
35        description=""
36        notes="copy of " + src
37        self.rpcProxy.host_createOpsiClient( id, opsiHostKey, description, notes, hardwareAddress, ipAddress )
38       
39    def productOnClient( self, client ):
40        pprint( self.rpcProxy.productOnClient_getObjects( [], { 'clientId': client } ) )
41
42
43
44if __name__ == '__main__':
45    opsi=OpsiRpc()
46    #opsi.dump()
47    opsi.copyClient( "test1.joergs.dass-it.opsi", "testnew1.joergs.dass-it.opsi", "00:00:00:00:01:01", "192.168.0.1" )
48    opsi.productOnClient( "opsiwin1.joergs.dass-it.opsi" )
49    opsi.dump()
50    print "end"
51   
Note: See TracBrowser for help on using the repository browser.