Changeset 1b376ca for fedd/federation


Ignore:
Timestamp:
Dec 3, 2008 10:12:13 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:
c8853fd
Parents:
dceeef9
Message:

Correct resource communication to allocation and wildcarding of gateway requests

Location:
fedd/federation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/access.py

    rdceeef9 r1b376ca  
    541541        """
    542542
     543        def gateway_hardware(h):
     544            if h == 'GWTYPE': return self.attrs.get('connectorType', 'GWTYPE')
     545            else: return h
     546
    543547        # The dance to get into the request body
    544548        if req.has_key('RequestAccessRequestBody'):
     
    567571            if req.has_key('resources') and req['resources'].has_key('node'):
    568572                resources = req['resources']
    569                 restricted = [ t for n in resources['node'] \
     573                restricted = [ gateway_hardware(t) for n in resources['node'] \
    570574                                if n.has_key('hardware') \
    571575                                    for t in n['hardware'] \
    572                                         if t in self.restricted ]
     576                                        if gateway_hardware(t) \
     577                                            in self.restricted ]
    573578                inaccessible = [ t for t in restricted \
    574579                                    if t not in found[0].node_types]
     
    611616                    if restricted != None and len(restricted) > 0:
    612617                        preq['AllocateProjectRequestBody']['resources'] = \
    613                             [ {'node': { 'hardware' :  [ h ] } } \
    614                                     for h in restricted ]
     618                             {'node': [ { 'hardware' :  [ h ] } \
     619                                    for h in restricted ] }
    615620                    ap = self.allocate_project.dynamic_project(preq)
    616621                else:
     
    636641                    if restricted != None and len(restricted) > 0:
    637642                        preq['StaticProjectRequestBody']['resources'] = \
    638                             [ {'node': { 'hardware' :  [ h ] } } \
    639                                     for h in restricted ]
     643                            {'node': [ { 'hardware' :  [ h ] } \
     644                                    for h in restricted ] }
    640645                    ap = self.allocate_project.static_project(preq)
    641646            else:
  • fedd/federation/allocate_project.py

    rdceeef9 r1b376ca  
    176176                dir="/tmp")
    177177
    178         if req.has_key('AllocateProjectRequestBody') and \
    179                 req['AllocateProjectRequestBody'].has_key('project'):
    180             proj = req['AllocateProjectRequestBody']['project']
     178        if req.has_key('AllocateProjectRequestBody'):
     179            proj = req['AllocateProjectRequestBody'].get('project', None)
     180            if not proj:
     181                raise service_error(service_error.req,
     182                        "Badly formed allocation request")
     183            resources = req['AllocateProjectRequestBody'].get('resources', { })
    181184        else:
    182185            raise service_error(service_error.req,
     
    279282                ]
    280283
    281         # Add commands to grant access to any resources in the request.
    282         for nt in [ h for r in req.get('resources', []) \
    283                 if r.has_key('node') and r['node'].has_key('hardware')\
    284                     for h in r['node']['hardware'] ] :
    285             cmds.append((self.wap, self.grantnodetype, '-p', name, nt))
     284        # Add commands to grant access to any resources in the request.  The
     285        # list comprehension pulls out the hardware types in the node entries
     286        # in the resources list.
     287        if resources.has_key('node'):
     288            for nt in [ h for n in resources['node']\
     289                    if n.has_key('hardware') for h in n['hardware'] ] :
     290                if self.allocation_level >= self.confirm_keys:
     291                    cmds.append((self.wap, self.grantnodetype, '-p', pname, nt))
     292
    286293
    287294        # Create the projects
     
    344351            pname = req['StaticProjectRequestBody']['project']\
    345352                    ['name']['localname']
    346             resources = req['StaticProjectRequestBody'].get('resources', [])
     353            resources = req['StaticProjectRequestBody'].get('resources', { })
    347354        except KeyError:
    348355            raise service_error(service_error.req, "Badly formed request")
     
    370377        # list comprehension pulls out the hardware types in the node entries
    371378        # in the resources list.
    372         for nt in [ h for r in resources \
    373                 if r.has_key('node') and r['node'].has_key('hardware')\
    374                     for h in r['node']['hardware'] ] :
    375             if self.allocation_level >= self.confirm_keys:
    376                 cmds.append((self.wap, self.grantnodetype, '-p', pname, nt))
     379        if resources.has_key('node'):
     380            for nt in [ h for n in resources['node']\
     381                    if n.has_key('hardware') for h in n['hardware'] ] :
     382                if self.allocation_level >= self.confirm_keys:
     383                    cmds.append((self.wap, self.grantnodetype, '-p', pname, nt))
    377384
    378385        # Run the commands
Note: See TracChangeset for help on using the changeset viewer.