Changeset 4f4b977 for fedd


Ignore:
Timestamp:
Jun 26, 2008 5:55:10 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:
329f61d
Parents:
5b8b886
Message:

backout the regression, XMLRPC looks better

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/fedd_proj.py

    r5b8b886 r4f4b977  
    118118    def get_users(self, obj):
    119119        """
    120         Return a list of the IDs of the users in obj
     120        Return a list of the IDs of the users in dict
    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(req)
    248 
     247        msg.set_element_RequestAccessRequestBody(
     248                pack_soap(msg, "RequestAccessRequestBody", req))
    249249        try:
    250250            resp = port.RequestAccess(msg)
    251251        except ZSI.FaultException, e:
    252252            raise e.fault
    253         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")
    254260
    255261    def permute_wildcards(self, a, p):
     
    309315        if req.has_key('project'):
    310316            p = req['project']
    311             project = unpack_id(p['name'])
     317            if p.has_key('name'):
     318                project = unpack_id(p['name'])
    312319            user = self.get_users(p)
    313320        else:
     
    366373        return found, (dyn_user, dyn_proj)
    367374
    368     def build_response(self, resp, alloc_id, ap, ssh):
     375    def build_response(self, alloc_id, ap, ssh):
    369376        """
    370377        Create the SOAP response.
     
    398405                [ { 'attribute': x, 'value' : y } \
    399406                        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()
    400420
    401421        resp.set_element_RequestAccessResponseBody(
    402422                pack_soap(resp, "RequestAccessResponseBody", msg))
    403 
    404     def soap_RequestAccess(self, ps, fid):
    405         req = ps.Parse(RequestAccessRequestMessage.typecode)
    406 
    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()
     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'])
    415434       
     435        print dt
     436
    416437        if dt == None or dt == self.testbed:
    417             # Request for this fedd (shift to dictionary representation)
    418             r = unpack_soap(req)
    419 
    420             found, dyn = self.lookup_access(r, fid)
     438            # Request for this fedd
     439            found, dyn = self.lookup_access(req, fid)
    421440
    422441            # Check for access to restricted nodes
    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') \
     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 \
    428446                                    for t in n['hardware'] \
    429447                                        if t in self.restricted and \
     
    435453
    436454            ssh = [ x['sshPubkey'] \
    437                     for x in r['access'] if x.has_key('sshPubkey')]
     455                    for x in req['access'] if x.has_key('sshPubkey')]
    438456
    439457            if len(ssh) > 0:
     
    443461                raise Fault(Fault.Client, "SSH access parameters required")
    444462
    445             resp = RequestAccessResponseMessage()
    446             self.build_response(resp, r['allocID'], found, ssh)
     463            resp = self.build_response(req['allocID'], found, ssh)
    447464            return resp
    448465        else:
    449466            # Proxy the request
    450467            return self.proxy_request(dt, req)
    451 
    452468
    453469    def read_trust(self, trust):
Note: See TracChangeset for help on using the changeset viewer.