Changeset 8922e1b
- Timestamp:
- Jun 25, 2008 5:06:42 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:
- 2d58549
- Parents:
- 2106ed1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/fedd_proj.py
r2106ed1 r8922e1b 118 118 def get_users(self, obj): 119 119 """ 120 Return a list of the IDs of the users in obj (accessed using get_id) 121 """ 122 if obj.get_element_user() != None: 123 return [ self.get_id(u.get_element_userID()) \ 124 for u in obj.get_element_user() \ 125 if u.get_element_userID() != None] 120 Return a list of the IDs of the users in dict 121 """ 122 if obj.has_key('user'): 123 return [ unpack_id(u['userID']) \ 124 for u in obj['user'] if u.has_key('userID') ] 126 125 else: 127 126 return None … … 246 245 # Reconstruct the full request message 247 246 msg = RequestAccessRequestMessage() 248 msg.set_element_RequestAccessRequestBody( req)249 247 msg.set_element_RequestAccessRequestBody( 248 pack_soap(msg, "RequestAccessRequestBody", req)) 250 249 try: 251 250 resp = port.RequestAccess(msg) 252 251 except ZSI.FaultException, e: 253 252 raise e.fault 254 return resp 253 254 r = unpack_soap(resp) 255 256 if r.has_key('RequestAccessResponseBody'): 257 return r['RequestAccessResponseBody'] 258 else: 259 raise Fault(Fault.Server, "Bad proxy response") 255 260 256 261 def permute_wildcards(self, a, p): … … 308 313 if principal_type == "testbed": tb = fid 309 314 310 p = req.get_element_project()311 if p != None:312 if p. get_element_name() != None:313 project = self.get_id(p.get_element_name())315 if req.has_key('project'): 316 p = req['project'] 317 if p.has_key('name'): 318 project = unpack_id(p['name']) 314 319 user = self.get_users(p) 315 320 else: … … 368 373 return found, (dyn_user, dyn_proj) 369 374 370 def build_response(self, resp,alloc_id, ap, ssh):375 def build_response(self, alloc_id, ap, ssh): 371 376 """ 372 377 Create the SOAP response. … … 400 405 [ { 'attribute': x, 'value' : y } \ 401 406 for x,y in self.attrs.iteritems()] 407 return msg 408 409 410 def soap_RequestAccess(self, ps, fid): 411 req = ps.Parse(RequestAccessRequestMessage.typecode) 412 413 414 #if req == None: raise Fault(Fault.Client, "No request??") 415 #req = req.get_element_RequestAccessRequestBody() 416 # if req == None: raise Fault(Fault.Client, "No request body??") 417 418 msg = self.RequestAccess(unpack_soap(req), fedid) 419 resp = RequestAccessResponseMessage() 402 420 403 421 resp.set_element_RequestAccessResponseBody( 404 422 pack_soap(resp, "RequestAccessResponseBody", msg)) 405 406 def soap_RequestAccess(self, ps, fid): 407 req = ps.Parse(RequestAccessRequestMessage.typecode) 408 resp = RequestAccessResponseMessage() 409 410 411 if req == None: raise Fault(Fault.Client, "No request??") 412 req = req.get_element_RequestAccessRequestBody() 413 if req == None: raise Fault(Fault.Client, "No request body??") 414 415 416 dt = req.get_element_destinationTestbed() 417 418 if dt != None: dt = dt.get_element_uri() 423 return resp 424 425 def RequestAccess(self, req, fid): 426 427 if req.has_key('RequestAccessRequestBody'): 428 req = req['RequestAccessRequestBody'] 429 else: 430 raise Fault(Fault.Client, "No request!?") 431 432 if req.has_key('destinationTestbed'): 433 dt = unpack_id(req['destinationTestbed']) 419 434 435 print dt 436 420 437 if dt == None or dt == self.testbed: 421 438 # Request for this fedd … … 423 440 424 441 # Check for access to restricted nodes 425 if req.get_element_resources() != None and \ 426 req.get_element_resources().get_element_node() != None: 427 428 resources = req.get_element_resources() 429 inaccessible = [ t for n in resources.get_element_node()\ 430 if n.get_element_hardware() != None \ 431 for t in n.get_element_hardware() 442 if req.has_key('resources') and req['resources'].has_key('node'): 443 resources = req['resources'] 444 inaccessible = [ t for n in resources['node'] \ 445 if n.has_key('hardware') != None \ 446 for t in n['hardware'] \ 432 447 if t in self.restricted and \ 433 448 t not in found[0].node_types] … … 437 452 str(', ').join(inaccessible)) 438 453 439 ssh = [ x.get_element_sshPubkey() \ 440 for x in req.get_element_access() \ 441 if x.get_element_sshPubkey() != None] 454 ssh = [ x['sshPubkey'] \ 455 for x in req['access'] if x.has_key('sshPubkey')] 442 456 443 457 if len(ssh) > 0: … … 447 461 raise Fault(Fault.Client, "SSH access parameters required") 448 462 449 self.build_response(resp, req.get_element_allocID(), found, ssh)463 resp = self.build_response(req['allocID'], found, ssh) 450 464 return resp 451 465 else: 452 466 # Proxy the request 453 467 return self.proxy_request(dt, req) 454 455 468 456 469 def read_trust(self, trust):
Note: See TracChangeset
for help on using the changeset viewer.