Changeset bb3769a
- Timestamp:
- Jul 16, 2008 11:28:14 AM (16 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-1.30, version-2.00, version-3.01, version-3.02
- Children:
- 0c0b13c
- Parents:
- 0a47d52
- Location:
- fedd
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/fedd.py
r0a47d52 rbb3769a 123 123 fedid(cert=self.request.get_peer_cert())) 124 124 data = xmlrpclib.dumps((resp,), methodresponse=True) 125 except Fault, f:126 xf = xmlrpclib.Fault(f.code, f.string)127 data = xmlrpclib.dumps(xf, methodresponse=True)128 resp = None125 #except Fault, f: 126 # xf = xmlrpclib.Fault(f.code, f.string) 127 # data = xmlrpclib.dumps(xf, methodresponse=True) 128 # resp = None 129 129 except xmlrpclib.Fault, f: 130 130 data = xmlrpclib.dumps(f, methodresponse=True) -
fedd/fedd_bindings.wsdl
r0a47d52 rbb3769a 22 22 <soap:operation soapAction=""/> 23 23 <input> 24 <soap:body use="encoded" part ="tns:RequestAccessRequestBody"24 <soap:body use="encoded" parts="tns:RequestAccessRequestBody" 25 25 namespace="http://www.isi.edu/faber/fedd.wsdl" 26 26 encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> 27 27 </input> 28 28 <output> 29 <soap:body use="encoded" part ="tns:RequestAccessResponseBody"29 <soap:body use="encoded" parts="tns:RequestAccessResponseBody" 30 30 namespace="http://www.isi.edu/faber/fedd.wsdl" 31 31 encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> -
fedd/fedd_client.py
r0a47d52 rbb3769a 13 13 from xmlrpclib import ServerProxy, Error, dumps, loads 14 14 from ZSI import SoapWriter 15 from ZSI.TC import QName, String, URI, AnyElement, UNBOUNDED, Any 16 from ZSI.wstools.Namespaces import SOAP 17 from ZSI.fault import FaultType, Detail 15 18 16 19 import xmlrpclib … … 20 23 21 24 from optparse import OptionParser, OptionValueError 25 26 import parse_detail 22 27 23 28 # Turn off the matching of hostname to certificate ID … … 269 274 if opts.debug > 1: print >>sys.stderr, msg 270 275 276 print FaultType.typecode; 277 271 278 if opts.transport == "soap": 272 279 loc = feddServiceLocator(); … … 292 299 sys.exit("Malformed response (XMLPRC?): %s" % e) 293 300 except ZSI.FaultException, e: 294 sys.exit("Fault: %s" % e) 301 print dir(e.fault.detail[0]) 302 print e.fault.detail[0].RequestAccessFaultBody.get_element_code() 303 d = unpack_soap(e.fault.detail[0].get_element_RequestAccessFaultBody()) 304 f = unpack_soap(e.fault.detail[0]) 305 print "unpack ", d 306 print "unpack ", f 307 sys.exit("Fault: %s %s" % (str(e.fault.code), str(e.fault.string))) 295 308 296 309 -
fedd/fedd_messages.wsdl
r0a47d52 rbb3769a 15 15 </message> 16 16 17 <message name="RequestAccessFaultMessage"> 18 <part name="RequestAccessFaultBody" type="xsd1:faultType"/> 19 </message> 20 17 21 18 22 <portType name="feddPortType"> … … 24 28 <output message="tns:RequestAccessResponseMessage"/> 25 29 <fault name="RequestAccessFault" 26 message="tns:RequestAccess ResponseMessage"/>30 message="tns:RequestAccessFaultMessage"/> 27 31 </operation> 28 32 </portType> -
fedd/fedd_proj.py
r0a47d52 rbb3769a 20 20 from fedd_services import * 21 21 from fedd_util import * 22 23 if False: 24 _RequestAccessFault_typecode = Struct(pname=("http://www.isi.edu/faber/fedd.wsdl", 'RequestAccessFault'), ofwhat=[ns0.faultType_Def( pname=("http://www.isi.edu/faber/fedd.wsdl", "RequestAccessFaultBody"), aname="_RequestAccessFaultBody", minoccurs=0, maxoccurs=1, nillable=True, encoded=None, typed=True)], pyclass=None) 25 class RequestAccessFault: 26 typecode = _RequestAccessFault_typecode 27 __metaclass__ = pyclass_type 28 def __init__(self, code=0, str="str"): 29 self._RequestAccessFaultBody = None 30 RequestAccessFault.typecode.pyclass=RequestAccessFault 22 31 23 32 class fedd_proj: … … 57 66 return "access_proj('%s', [])" % self.name 58 67 59 60 class parse_error(RuntimeError): 61 """Raised if the configuration file is unparsable""" 62 pass 68 # These are used to make the error reporting independent of the transport. 69 # The XMLRPC and SOAP dispatchers will convert them to transport-specific 70 # errors 71 class server_error(RuntimeError): pass 72 class client_error(RuntimeError): pass 73 # Error parsing config 74 class parse_error(RuntimeError): pass 75 63 76 64 77 def __init__(self, config=None): … … 216 229 rc = subprocess.call(cmd) 217 230 except OSerror, e: 218 raise Fault(Fault.Server,231 raise fedd_proj.server_error( 219 232 "Dynamic project subprocess creation error "+ \ 220 233 "[%s] (%s)" % (cmd[1], e.strerror)) … … 223 236 224 237 if rc != 0: 225 raise Fault(Fault.Server,238 raise fedd_proj.server_error( 226 239 "Dynamic project subprocess error " +\ 227 240 "[%s] (%d)" % (cmd[1], rc)) … … 253 266 ctx = fedd_ssl_context(self.cert_file, tc, password=self.cert_pwd) 254 267 except SSL.SSLError: 255 raise Fault(Fault.Server,"Server certificates misconfigured")268 raise fedd_proj.server_error("Server certificates misconfigured") 256 269 257 270 # Of all the dumbass things. The XMLRPC library in use here won't … … 274 287 resp, method = xmlrpclib.loads(resp) 275 288 except xmlrpclib.Error, e: 276 raise Fault(Fault.Server,"Remote XMLRPC Fault: %s" % e)289 raise fedd_proj.server_error("Remote XMLRPC Fault: %s" % e) 277 290 278 291 if resp[0].has_key('RequestAccessResponseBody'): 279 292 return resp[0]['RequestAccessResponseBody'] 280 293 else: 281 raise Fault(Fault.Server,"Bad proxy response")294 raise fedd_proj.server_error("Bad proxy response") 282 295 283 296 def proxy_request(self, dt, req): … … 295 308 ctx = fedd_ssl_context(self.cert_file, tc, password=self.cert_pwd) 296 309 except SSL.SSLError: 297 raise Fault(Fault.Server,"Server certificates misconfigured")310 raise fedd_proj.server_error("Server certificates misconfigured") 298 311 299 312 loc = feddServiceLocator(); … … 309 322 resp = port.RequestAccess(msg) 310 323 except ZSI.ParseException, e: 311 raise Fault(Fault.Server,"Bad format message (XMLRPC??): %s" %324 raise fedd_proj.server_error("Bad format message (XMLRPC??): %s" % 312 325 str(e)) 313 326 except ZSI.FaultException, e: … … 319 332 return r['RequestAccessResponseBody'] 320 333 else: 321 raise Fault(Fault.Server,"Bad proxy response")334 raise fedd_proj.server_error("Bad proxy response") 322 335 323 336 def permute_wildcards(self, a, p): … … 388 401 fedids = [ u for u in user if isinstance(u, type(fid))] 389 402 if len(fedids) > 1: 390 raise Fault(Fault.Client,403 raise fedd_proj.client_error( 391 404 "User asserting multiple fedids") 392 405 elif len(fedids) == 1 and fedids[0] != fid: 393 raise Fault(Fault.Client,406 raise fedd_proj.client_error( 394 407 "User asserting different fedid") 395 408 project = None … … 397 410 elif principal_type == "project": 398 411 if isinstance(project, type(fid)) and fid != project: 399 raise Fault(Fault.Client,412 raise fedd_proj.client_error( 400 413 "Project asserting different fedid") 401 414 tb = None … … 406 419 print "Found: ", found 407 420 408 if found == None: raise Fault(Fault.Server,"Access denied")421 if found == None: raise fedd_proj.server_error("Access denied") 409 422 410 423 # resolve <dynamic> and <same> in found … … 416 429 found[0].name = project 417 430 else : 418 raise Fault(Fault.Server,431 raise fedd_proj.server_error( 419 432 "Project matched <same> when no project given") 420 433 elif found[0].name == "<dynamic>": … … 425 438 if user_match == "<any>": 426 439 if user != None: found = (found[0], user[0]) 427 else: raise Fault(Fault.Server,440 else: raise fedd_proj.server_error( 428 441 "Matched <same> on anonymous request") 429 442 else: … … 474 487 req = req['RequestAccessRequestBody'] 475 488 else: 476 raise Fault(Fault.Client,"No request!?")489 raise fedd_proj.client_error("No request!?") 477 490 478 491 if req.has_key('destinationTestbed'): … … 492 505 t not in found[0].node_types] 493 506 if len(inaccessible) > 0: 494 raise Fault(Fault.Server,507 raise fedd_proj.server_error( 495 508 "Access denied (nodetypes %s)" % \ 496 509 str(', ').join(inaccessible)) … … 503 516 else: pass # SSH key additions 504 517 else: 505 raise Fault(Fault.Client,"SSH access parameters required")518 raise fedd_proj.client_error("SSH access parameters required") 506 519 507 520 resp = self.build_response(req['allocID'], found, ssh) … … 512 525 # Proxy the request using SOAP 513 526 return self.proxy_request(dt, req) 514 except Fault, f:527 except RuntimeError, f: 515 528 p_fault = f 516 529 … … 519 532 try: 520 533 return self.proxy_xmlrpc_request(dt, req) 521 except Fault: 534 print "here" 535 except RuntimeError: 522 536 # Both failed, return the SOAP error. If somehow that 523 537 # exception is gone, return the XMLRPC one … … 529 543 530 544 msg = self.RequestAccess(unpack_soap(req), fedid) 545 531 546 resp = RequestAccessResponseMessage() 532 533 547 resp.set_element_RequestAccessResponseBody( 534 548 pack_soap(resp, "RequestAccessResponseBody", msg)) 549 535 550 return resp 536 551 537 552 def xmlrpc_RequestAccess(self, params, fid): 538 553 msg = self.RequestAccess(params[0], fedid) 554 539 555 if msg != None: 540 556 return xmlrpclib.dumps(({ "RequestAccessResponseBody": msg },)) 557 else: 558 raise server_error("No response generated?!"); 541 559 542 560 def read_trust(self, trust): … … 709 727 def soap_dispatch(self, method, req, fid): 710 728 if fedd_proj.soap_methods.has_key(method): 711 return getattr(self, fedd_proj.soap_methods[method])(req, fid) 729 try: 730 return getattr(self, fedd_proj.soap_methods[method])(req, fid) 731 except fedd_proj.server_error, e: 732 de = ns0.faultType_Def((ns0.faultType_Def.schema,"RequestAccessFaultBody")).pyclass() 733 de._code=100 734 de._desc="temp" 735 f = Fault(Fault.Server, "Server Test", detail=de) 736 raise f 737 except fedd_proj.client_error, e: 738 raise Fault(Fault.Client, str(e)) 712 739 else: 713 740 raise Fault(Fault.Client, "Unknown method: %s" % method) … … 715 742 def xmlrpc_dispatch(self, method, req, fid): 716 743 if fedd_proj.xmlrpc_methods.has_key(method): 717 return getattr(self, fedd_proj.xmlrpc_methods[method])(req, fid) 744 try: 745 return getattr(self, fedd_proj.xmlrpc_methods[method])(req, fid) 746 except fedd_proj.server_error, e: 747 raise xmlrpclib.Fault("server", str(e)) 748 except fedd_proj.client_error, e: 749 raise xmlrpclib.Fault("client", str(e)) 718 750 else: 719 751 raise xmlrpclib.Fault(100, "Unknown method: %s" % method) -
fedd/fedd_types.xsd
r0a47d52 rbb3769a 183 183 </xsd:complexType> 184 184 185 <xsd:complexType name="faultType"> 186 <xsd:sequence> 187 <xsd:element name="code" type="xsd:int"/> 188 <xsd:element name="desc" type="xsd:string"/> 189 </xsd:sequence> 190 </xsd:complexType> 191 185 192 </xsd:schema>
Note: See TracChangeset
for help on using the changeset viewer.