- Timestamp:
- Nov 30, 2008 5:38:16 PM (16 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-1.30, version-2.00, version-3.01, version-3.02
- Children:
- 05191a6
- Parents:
- edbc841
- Location:
- fedd
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/fedd/access.py
redbc841 rf069052 10 10 from threading import * 11 11 12 from fedd_services import *13 12 from util import * 14 13 from allocate_project import allocate_project_local, allocate_project_remote … … 45 44 id_list_attrs = ("restricted",) 46 45 47 proxy_RequestAccess= \ 48 service_caller('RequestAccess', 'getfeddPortType', 49 feddServiceLocator, RequestAccessRequestMessage, 50 'RequestAccessRequestBody') 51 52 proxy_ReleaseAccess= \ 53 service_caller('ReleaseAccess', 'getfeddPortType', 54 feddServiceLocator, ReleaseAccessRequestMessage, 55 'ReleaseAccessRequestBody') 46 proxy_RequestAccess= service_caller('RequestAccess') 47 proxy_ReleaseAccess= service_caller('ReleaseAccess') 56 48 57 49 def __init__(self, config=None, auth=None): … … 154 146 155 147 self.soap_services = {\ 156 'RequestAccess': soap_handler(\ 157 RequestAccessRequestMessage.typecode,\ 158 self.RequestAccess, RequestAccessResponseMessage,\ 159 "RequestAccessResponseBody"), \ 160 'ReleaseAccess': soap_handler(\ 161 ReleaseAccessRequestMessage.typecode,\ 162 self.ReleaseAccess, ReleaseAccessResponseMessage,\ 163 "ReleaseAccessResponseBody")\ 148 'RequestAccess': soap_handler("RequestAccess", self.RequestAccess), 149 'ReleaseAccess': soap_handler("ReleaseAccess", self.ReleaseAccess), 164 150 } 165 151 self.xmlrpc_services = {\ 166 'RequestAccess': xmlrpc_handler( \167 self.RequestAccess , "RequestAccessResponseBody"),\168 'ReleaseAccess': xmlrpc_handler( \169 self.ReleaseAccess , "ReleaseAccessResponseBody")\152 'RequestAccess': xmlrpc_handler('RequestAccess', 153 self.RequestAccess), 154 'ReleaseAccess': xmlrpc_handler('ReleaseAccess', 155 self.ReleaseAccess), 170 156 } 171 157 … … 518 504 519 505 Build the dictionary description of the response and use 520 fedd_utils.pack_soap to create the soap message. NB that alloc_id is 521 a fedd_services_types.IDType_Holder pulled from the incoming message. 522 ap is the allocate project message returned from a remote project 523 allocation (even if that allocation was done locally). 506 fedd_utils.pack_soap to create the soap message. ap is the allocate 507 project message returned from a remote project allocation (even if that 508 allocation was done locally). 524 509 """ 525 510 # Because alloc_id is already a fedd_services_types.IDType_Holder, -
fedd/fedd/allocate_project.py
redbc841 rf069052 8 8 import tempfile 9 9 10 from fedd_services import *11 from fedd_internal_services import *12 10 from util import * 13 11 from fedid import fedid … … 92 90 # Internal services are SOAP only 93 91 self.soap_services = {\ 94 "AllocateProject": soap_handler(\ 95 AllocateProjectRequestMessage.typecode,\ 96 self.dynamic_project, AllocateProjectResponseMessage,\ 97 "AllocateProjectResponseBody"), 98 "StaticProject": soap_handler(\ 99 StaticProjectRequestMessage.typecode,\ 100 self.static_project, StaticProjectResponseMessage,\ 101 "StaticProjectResponseBody"),\ 102 "ReleaseProject": soap_handler(\ 103 ReleaseProjectRequestMessage.typecode,\ 104 self.release_project, ReleaseProjectResponseMessage,\ 105 "ReleaseProjectResponseBody")\ 92 "AllocateProject": soap_handler("AllocateProject", 93 self.dynamic_project), 94 "StaticProject": soap_handler("StaticProject", 95 self.static_project), 96 "ReleaseProject": soap_handler("ReleaseProject", 97 self.release_project), 106 98 } 107 99 self.xmlrpc_services = { } … … 388 380 """ 389 381 390 def __init__(self, url, cert_file, cert_pwd, trusted_certs, 391 method, req_name, req_alloc, resp_name): 392 service_caller.__init__(self, method, 'getfeddInternalPortType', 393 feddInternalServiceLocator, req_alloc, req_name) 382 def __init__(self, url, cert_file, cert_pwd, trusted_certs, method): 383 service_caller.__init__(self, method) 394 384 self.url = url 395 385 self.cert_file = cert_file … … 471 461 # The specializations of the proxy functions 472 462 self.dynamic_project = self.proxy(self.url, self.cert_file, 473 self.cert_pwd, self.trusted_certs, "AllocateProject", 474 "AllocateProjectRequestBody", AllocateProjectRequestMessage, 475 "AllocateProjectResponseBody") 463 self.cert_pwd, self.trusted_certs, "AllocateProject") 476 464 self.static_project = self.proxy(self.url, self.cert_file, 477 self.cert_pwd, self.trusted_certs, "StaticProject", 478 "StaticProjectRequestBody", StaticProjectRequestMessage, 479 "StaticProjectResponseBody") 465 self.cert_pwd, self.trusted_certs, "StaticProject") 480 466 self.release_project = self.proxy(self.url, self.cert_file, 481 self.cert_pwd, self.trusted_certs, "ReleaseProject", 482 "ReleaseProjectRequestBody", ReleaseProjectRequestMessage, 483 "ReleaseProjectResponseBody") 484 467 self.cert_pwd, self.trusted_certs, "ReleaseProject") 468 -
fedd/fedd/experiment_control.py
redbc841 rf069052 19 19 from subprocess import * 20 20 21 from fedd_services import *22 from fedd_internal_services import *23 21 from util import * 24 22 from fedid import fedid, generate_fedid … … 140 138 self.pdata.terminate() 141 139 142 call_RequestAccess = service_caller('RequestAccess', 143 'getfeddPortType', feddServiceLocator, 144 RequestAccessRequestMessage, 'RequestAccessRequestBody') 145 146 call_ReleaseAccess = service_caller('ReleaseAccess', 147 'getfeddPortType', feddServiceLocator, 148 ReleaseAccessRequestMessage, 'ReleaseAccessRequestBody') 149 150 call_Ns2Split = service_caller('Ns2Split', 151 'getfeddInternalPortType', feddInternalServiceLocator, 152 Ns2SplitRequestMessage, 'Ns2SplitRequestBody') 140 call_RequestAccess = service_caller('RequestAccess') 141 call_ReleaseAccess = service_caller('ReleaseAccess') 142 call_Ns2Split = service_caller('Ns2Split') 153 143 154 144 def __init__(self, config=None, auth=None): … … 275 265 # Dispatch tables 276 266 self.soap_services = {\ 277 'Create': soap_handler(\ 278 CreateRequestMessage.typecode, 279 getattr(self, "create_experiment"), 280 CreateResponseMessage, 281 "CreateResponseBody"), 282 'Vtopo': soap_handler(\ 283 VtopoRequestMessage.typecode, 284 getattr(self, "get_vtopo"), 285 VtopoResponseMessage, 286 "VtopoResponseBody"), 287 'Vis': soap_handler(\ 288 VisRequestMessage.typecode, 289 getattr(self, "get_vis"), 290 VisResponseMessage, 291 "VisResponseBody"), 292 'Info': soap_handler(\ 293 InfoRequestMessage.typecode, 294 getattr(self, "get_info"), 295 InfoResponseMessage, 296 "InfoResponseBody"), 297 'Terminate': soap_handler(\ 298 TerminateRequestMessage.typecode, 299 getattr(self, "terminate_experiment"), 300 TerminateResponseMessage, 301 "TerminateResponseBody"), 267 'Create': soap_handler('Create', self.create_experiment), 268 'Vtopo': soap_handler('Vtopo', self.get_vtopo), 269 'Vis': soap_handler('Vis', self.get_vis), 270 'Info': soap_handler('Info', self.get_info), 271 'Terminate': soap_handler('Terminate', 272 self.terminate_experiment), 302 273 } 303 274 304 275 self.xmlrpc_services = {\ 305 'Create': xmlrpc_handler(\ 306 getattr(self, "create_experiment"), 307 "CreateResponseBody"), 308 'Vtopo': xmlrpc_handler(\ 309 getattr(self, "get_vtopo"), 310 "VtopoResponseBody"), 311 'Vis': xmlrpc_handler(\ 312 getattr(self, "get_vis"), 313 "VisResponseBody"), 314 'Info': xmlrpc_handler(\ 315 getattr(self, "get_info"), 316 "InfoResponseBody"), 317 'Terminate': xmlrpc_handler(\ 318 getattr(self, "terminate_experiment"), 319 "TerminateResponseBody"), 276 'Create': xmlrpc_handler('Create', self.create_experiment), 277 'Vtopo': xmlrpc_handler('Vtopo', self.get_vtopo), 278 'Vis': xmlrpc_handler('Vis', self.get_vis), 279 'Info': xmlrpc_handler('Info', self.get_info), 280 'Terminate': xmlrpc_handler('Terminate', 281 self.terminate_experiment), 320 282 } 321 283 -
fedd/fedd/remote_service.py
redbc841 rf069052 11 11 from ZSI import ParseException, FaultException, SoapWriter 12 12 13 from service_error import *13 from service_error import service_error 14 14 from xmlrpclib import ServerProxy, dumps, loads, Fault, Error, Binary 15 15 16 import fedd_services 17 import fedd_internal_services 16 18 from util import fedd_ssl_context 17 19 from fedid import fedid … … 181 183 created constructors will result in None being returned. 182 184 """ 183 def __init__(self, typecode, method, constructor, body_name):184 self.typecode = typecode185 def __init__(self, service_name, method, typecode=None, 186 constructor=None, body_name=None): 185 187 self.method = method 186 self.constructor = constructor 187 self.body_name = body_name 188 189 response_class_name = "%sResponseMessage" % service_name 190 request_class_name = "%sRequestMessage" % service_name 191 192 if body_name: self.body_name = body_name 193 else: self.body_name = "%sResponseBody" % service_name 194 195 if constructor: self.constructor = constructor 196 else: 197 self.constructor = self.get_class(response_class_name) 198 if not self.constructor: 199 raise service_error(service_error.internal, 200 "Cannot find class for %s" % response_class_name) 201 202 if typecode: self.typecode = typecode 203 else: 204 req = self.get_class(request_class_name) 205 if req: 206 self.typecode = req.typecode 207 else: 208 raise service_error(service_error.internal, 209 "Cannot find class for %s" % request_class_name) 210 211 if not self.typecode: 212 raise service_error(service_error.internal, 213 "Cannot get typecode for %s" % class_name) 214 215 def get_class(self, class_name): 216 return getattr(fedd_services, class_name, None) or \ 217 getattr(fedd_internal_services, class_name, None) 188 218 189 219 def __call__(self, ps, fid): … … 197 227 resp = self.constructor() 198 228 set_element = getattr(resp, "set_element_%s" % self.body_name, None) 229 print "set_element_%s" % self.body_name 199 230 if set_element and callable(set_element): 200 231 try: … … 220 251 to fedid objects on input and encapsulated as Binaries on output. 221 252 """ 222 def __init__(self, method, body_name):253 def __init__(self, service_name, method): 223 254 self.method = method 224 self.body_name = body_name255 self.body_name = "%sResponseBody" % service_name 225 256 226 257 def __call__(self, params, fid): … … 239 270 240 271 class service_caller(remote_service_base): 241 def __init__(self, service_name, port_name, locator, request_message,242 request_body_name , tracefile=None):272 def __init__(self, service_name, request_message=None, 273 request_body_name=None, tracefile=None): 243 274 self.service_name = service_name 244 self.port_name = port_name 245 self.locator = locator 246 self.request_message = request_message 247 self.request_body_name = request_body_name 275 276 if getattr(fedd_services.feddBindingSOAP, service_name, None): 277 self.locator = fedd_services.feddServiceLocator 278 self.port_name = 'getfeddPortType' 279 elif getattr(fedd_internal_services.feddInternalBindingSOAP, 280 service_name, None): 281 self.locator = fedd_internal_services.feddInternalServiceLocator 282 self.port_name = 'getfeddInternalPortType' 283 284 if request_message: self.request_message = request_message 285 else: 286 request_message_name = "%sRequestMessage" % service_name 287 self.request_message = \ 288 getattr(fedd_services, request_message_name, None) or \ 289 getattr(fedd_internal_services, request_message_name, None) 290 if not self.request_message: 291 raise service_error(service_error.internal, 292 "Cannot find class for %s" % request_message_name) 293 294 if request_body_name: self.request_body_name = request_body_name 295 else: self.request_body_name = "%sRequestBody" % service_name 296 248 297 self.tracefile = tracefile 249 298 self.__call__ = self.call_service -
fedd/fedd/split.py
redbc841 rf069052 6 6 import logging 7 7 8 from fedd_services import *9 from fedd_internal_services import *10 8 from util import * 11 9 from fedid import fedid … … 45 43 # Dispatch tables 46 44 self.soap_services = {\ 47 'Ns2Split': soap_handler(\ 48 Ns2SplitRequestMessage.typecode, 49 getattr(self, "run_splitter"), 50 Ns2SplitResponseMessage, 51 "Ns2SplitResponseBody"), 45 'Ns2Split': soap_handler("Ns2Split", self.run_splitter), 52 46 } 53 47 54 48 self.xmlrpc_services = {\ 55 'Ns2Split': xmlrpc_handler(\ 56 getattr(self, "run_splitter"), 57 "Ns2SplitResponseBody"), 49 'Ns2Split': xmlrpc_handler('Ns2Split', self.run_splitter), 58 50 } 59 51 -
fedd/fedd/util.py
redbc841 rf069052 35 35 else: 36 36 self.load_cert(my_cert) 37 if trusted_certs != None: self.load_verify_locations(trusted_certs) 38 self.set_verify(SSL.verify_peer, 10) 37 38 # If no trusted certificates are specified, allow unknown CAs. 39 if trusted_certs: 40 self.load_verify_locations(trusted_certs) 41 self.set_verify(SSL.verify_peer, 10) 42 else: 43 self.set_verify(SSL.verify_peer, 10, 44 callback=SSL.cb.ssl_verify_callback_allow_unknown_ca) 39 45 40 46 def pack_id(id): -
fedd/fedd_client.py
redbc841 rf069052 4 4 import os 5 5 import pwd 6 7 from fedd.fedd_services import *8 from fedd.fedd_internal_services import *9 6 10 7 from fedd import fedid, service_error … … 177 174 Specialize the class for the pre method 178 175 """ 179 self.RequestMessage = globals()["%sRequestMessage" % pre]180 self.ResponseMessage = globals()["%sResponseMessage" % pre]181 176 self.RequestBody="%sRequestBody" % pre 182 177 self.ResponseBody="%sResponseBody" % pre 183 178 self.method = pre 184 179 185 method_call = getattr(feddServiceLocator().getfeddPortType(), 186 self.method, None) 187 if method_call: 188 # The pre method is a fedd external service 189 self.caller = service_caller(self.method, 'getfeddPortType', 190 feddServiceLocator, self.RequestMessage, self.RequestBody) 191 else: 192 # The pre method is a fedd internal service 193 self.caller = service_caller(self.method, 194 'getfeddInternalPortType', feddInternalServiceLocator, 195 self.RequestMessage, self.RequestBody) 196 180 self.caller = service_caller(self.method) 197 181 self.RPCException = fedd_rpc.RPCException 198 182 … … 255 239 try: 256 240 context = fedd_ssl_context(cert, trusted) 257 except SSL.SSLError, e:241 except Exception, e: 258 242 # Yes, doing this on message type is not ideal. The string 259 243 # comes from OpenSSL, so check there is this stops working. … … 343 327 (opts, args) = parser.parse_args() 344 328 345 if opts.trusted != None:329 if opts.trusted: 346 330 if ( not os.access(opts.trusted, os.R_OK) ) : 347 331 sys.exit("Cannot read trusted certificates (%s)" % opts.trusted) 348 else:349 parser.error("--trusted is required")350 332 351 333 if opts.debug > 0: opts.tracefile=sys.stderr … … 411 393 (opts, args) = parser.parse_args() 412 394 413 if opts.trusted != None:395 if opts.trusted: 414 396 if ( not os.access(opts.trusted, os.R_OK) ) : 415 397 sys.exit("Cannot read trusted certificates (%s)" % opts.trusted) 416 else:417 parser.error("--trusted is required")418 398 419 399 if opts.debug > 0: opts.tracefile=sys.stderr … … 471 451 (opts, args) = parser.parse_args() 472 452 473 if opts.trusted != None:453 if opts.trusted: 474 454 if ( not os.access(opts.trusted, os.R_OK) ) : 475 455 sys.exit("Cannot read trusted certificates (%s)" % opts.trusted) 476 else:477 parser.error("--trusted is required")478 456 479 457 if not opts.project : … … 568 546 (opts, args) = parser.parse_args() 569 547 570 if opts.trusted != None:548 if opts.trusted: 571 549 if ( not os.access(opts.trusted, os.R_OK) ) : 572 550 sys.exit("Cannot read trusted certificates (%s)" % opts.trusted) 573 else:574 parser.error("--trusted is required")575 551 576 552 if opts.debug > 0: opts.tracefile=sys.stderr … … 674 650 parser.error("--testbed is required") 675 651 676 if opts.trusted != None:652 if opts.trusted: 677 653 if ( not os.access(opts.trusted, os.R_OK) ) : 678 654 sys.exit("Cannot read trusted certificates (%s)" % opts.trusted) 679 else:680 parser.error("--trusted is required")681 655 682 656 if opts.debug > 0: opts.tracefile=sys.stderr
Note: See TracChangeset
for help on using the changeset viewer.