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, on Aug 6, 2012 at 5:13:08 PM

initiale Tests auf json-rpc basis

  • Property svn:executable set to *
File size: 2.0 KB
RevLine 
[1027]1#!/usr/bin/env python
2
[1046]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
[1027]7
[1046]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
[1027]17from pprint import pprint
18
[1046]19UrlJsonRpc="https://joergs:linuxlinux@opsi4.joergs.dass-it:4447/rpc"
[1027]20
[1046]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 ):
[1028]31
[1046]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 } ) )
[1028]41
42
43
[1046]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.