Changeset 1088
- Timestamp:
- Aug 29, 2012, 7:24:39 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
opsi/server/dass-opsi-tools/usr/bin/opsiclient
r1087 r1088 85 85 products = self.rpc.productOnClient_getObjects( [], { 'clientId': src } ) 86 86 self.rpc.productOnClient_deleteObjects( products ) 87 88 products = self.rpc.productPropertyState_getObjects( [], { 'clientId': src } ) 89 self.rpc.productPropertyState_deleteObjects( products ) 90 87 91 if self.debug: 88 92 pprint( self.getProductOnClient( src ) ) … … 95 99 self.rpc.configState_create( "clientconfig.depot.id", name, depot ) 96 100 97 def copyClient( self, src, dst, ipAddress = None, hardwareAddress = None, depot = None, description = "" ):101 def copyClient( self, src, dst, ipAddress = None, hardwareAddress = None, depot = None, description = "", copyProperties = True ): 98 102 99 103 print "create/update", dst, "from template", src + ":", … … 124 128 # copy product properties: 125 129 # opsiCallClientBaculaProperties=[ "method", "getProductProperties_hash", "bacula" ] 130 if copyProperties: 131 if self.debug: 132 print "copy product properties" 133 self.copyProductPropertyState( src, dst ) 126 134 print "done" 127 135 return True … … 134 142 135 143 def copyProductOnClient( self, src, dst, attributes = ProductAttributesCopy ): 136 products = self.rpc.productOnClient_getHashes( attributes, { 'clientId': src } ) 137 for i in products: 144 products_src = self.rpc.productOnClient_getHashes( attributes, { 'clientId': src } ) 145 products_dst = [] 146 for i in products_src: 138 147 if self.debug: 139 148 print i['productId'] 140 149 pprint( i ) 141 150 i['clientId'] = dst 142 self.rpc.productOnClient_createObjects( i ) 151 products_dst.append(i) 152 self.rpc.productOnClient_createObjects( products_dst ) 143 153 if self.debug: 144 154 pprint( self.getProductOnClient( dst ) ) 155 156 def getProductPropertyState( self, client, attributes = [] ): 157 return self.rpc.productPropertyState_getHashes( [], { 'objectId': client } ) 158 159 def copyProductPropertyState( self, src, dst, attributes = [] ): 160 productProperties_src = self.getProductPropertyState( src, attributes ) 161 productProperties_dst = [] 162 for i in productProperties_src: 163 if self.debug: 164 print i['productId'], "-", i["propertyId"] + ": ", 165 pprint(i["values"]) 166 #pprint( i ) 167 i['objectId'] = dst 168 productProperties_dst.append(i) 169 self.rpc.productPropertyState_createObjects( productProperties_dst ) 170 if self.debug: 171 pprint( self.getProductPropertyState( dst ) ) 172 145 173 146 174 … … 176 204 parser_copy.add_argument( '--mac', help="MAC address of the new opsi client" ) 177 205 parser_copy.add_argument( '--depot', help="depot server the new opsi client should be located" ) 206 #parser_copy.add_argument( '--no-properties', action='store_false', help="don't copy product properties" ) 178 207 179 208 args = parser.parse_args() … … 192 221 result = opsi.clean( args.src ) 193 222 elif args.subcommand == "copy": 223 #result = opsi.copyClient( args.src, args.dst, args.ip, args.mac, args.depot, not args.no-properties ) 194 224 result = opsi.copyClient( args.src, args.dst, args.ip, args.mac, args.depot ) 195 225 else:
Note:
See TracChangeset
for help on using the changeset viewer.