Changeset 5b8b886 for fedd


Ignore:
Timestamp:
Jun 26, 2008 3:16:21 PM (16 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-1.30, version-2.00, version-3.01, version-3.02
Children:
4f4b977
Parents:
2d58549
Message:

back out some of the extra conversions to dictionary. Not useful for XMLRPC (left the ones that simplified code, though)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/fedd_proj.py

    r2d58549 r5b8b886  
    118118    def get_users(self, obj):
    119119        """
    120         Return a list of the IDs of the users in dict
     120        Return a list of the IDs of the users in obj
    121121        """
    122122        if obj.has_key('user'):
    123123            return [ unpack_id(u['userID']) \
    124                     for u in obj['user'] if u.has_key('userID') ]
     124                    for u in obj['user'] if u.has_key('userID')]
    125125        else:
    126126            return None
     
    245245        # Reconstruct the full request message
    246246        msg = RequestAccessRequestMessage()
    247         msg.set_element_RequestAccessRequestBody(
    248                 pack_soap(msg, "RequestAccessRequestBody", req))
     247        msg.set_element_RequestAccessRequestBody(req)
     248
    249249        try:
    250250            resp = port.RequestAccess(msg)
    251251        except ZSI.FaultException, e:
    252252            raise e.fault
    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")
     253        return resp
    260254
    261255    def permute_wildcards(self, a, p):
     
    315309        if req.has_key('project'):
    316310            p = req['project']
    317             if p.has_key('name'):
    318                 project = unpack_id(p['name'])
     311            project = unpack_id(p['name'])
    319312            user = self.get_users(p)
    320313        else:
     
    373366        return found, (dyn_user, dyn_proj)
    374367
    375     def build_response(self, alloc_id, ap, ssh):
     368    def build_response(self, resp, alloc_id, ap, ssh):
    376369        """
    377370        Create the SOAP response.
     
    405398                [ { 'attribute': x, 'value' : y } \
    406399                        for x,y in self.attrs.iteritems()]
    407         return msg
    408 
     400
     401        resp.set_element_RequestAccessResponseBody(
     402                pack_soap(resp, "RequestAccessResponseBody", msg))
    409403
    410404    def soap_RequestAccess(self, ps, fid):
    411405        req = ps.Parse(RequestAccessRequestMessage.typecode)
    412406
    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()
    420 
    421         resp.set_element_RequestAccessResponseBody(
    422                 pack_soap(resp, "RequestAccessResponseBody", msg))
    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'])
     407        if req == None: raise Fault(Fault.Client, "No request??")
     408        req = req.get_element_RequestAccessRequestBody()
     409        if req == None: raise Fault(Fault.Client, "No request body??")
     410
     411
     412        dt = req.get_element_destinationTestbed()
     413
     414        if dt != None: dt = dt.get_element_uri()
    434415       
    435         print dt
    436 
    437416        if dt == None or dt == self.testbed:
    438             # Request for this fedd
    439             found, dyn = self.lookup_access(req, fid)
     417            # Request for this fedd (shift to dictionary representation)
     418            r = unpack_soap(req)
     419
     420            found, dyn = self.lookup_access(r, fid)
    440421
    441422            # Check for access to restricted nodes
    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 \
     423            if r.has_key('resources') and r['resources'].has_key('node'):
     424
     425                resources = r['resources']
     426                inaccessible = [ t for n in resources['node']\
     427                                if n.has_key('hardware') \
    446428                                    for t in n['hardware'] \
    447429                                        if t in self.restricted and \
     
    453435
    454436            ssh = [ x['sshPubkey'] \
    455                     for x in req['access'] if x.has_key('sshPubkey')]
     437                    for x in r['access'] if x.has_key('sshPubkey')]
    456438
    457439            if len(ssh) > 0:
     
    461443                raise Fault(Fault.Client, "SSH access parameters required")
    462444
    463             resp = self.build_response(req['allocID'], found, ssh)
     445            resp = RequestAccessResponseMessage()
     446            self.build_response(resp, r['allocID'], found, ssh)
    464447            return resp
    465448        else:
    466449            # Proxy the request
    467450            return self.proxy_request(dt, req)
     451
    468452
    469453    def read_trust(self, trust):
Note: See TracChangeset for help on using the changeset viewer.