Changeset 25bf6cc for fedd/federation


Ignore:
Timestamp:
Jul 8, 2012 7:43:41 AM (12 years ago)
Author:
Ted Faber <faber@…>
Branches:
compt_changes, master
Children:
df35876
Parents:
b15ecc6
Message:

Grouper updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/experiment_control.py

    rb15ecc6 r25bf6cc  
    1313import signal
    1414import time
     15import shutil
     16import zipfile
    1517
    1618import os.path
     
    125127        self.store_url = config.get("experiment_control", "store_url")
    126128        self.splitter_url = config.get("experiment_control", "ns2topdl_uri")
     129        self.grouper_url = config.get("experiment_control", "grouper_url")
    127130        self.fedkit = parse_tarfile_list(\
    128131                config.get("experiment_control", "fedkit"))
     
    183186            self.get_access = self.legacy_get_access
    184187        elif self.auth_type == 'abac':
    185             self.auth = abac_authorizer(load=self.auth_dir)
     188            self.auth = abac_authorizer(load=self.auth_dir,
     189                    update=os.path.join(self.auth_dir,'update'))
    186190        else:
    187191            raise service_error(service_error.internal,
     
    394398        except TypeError, e:
    395399            self.log.error("Pickling problem (TypeError): %s" % e)
     400
     401    # XXX this may belong somewhere else
     402
     403    def get_grouper_updates(self, fid):
     404        if self.grouper_url is None: return
     405        d = tempfile.mkdtemp()
     406        try:
     407            fstr = "%s" % fid
     408            # XXX locking
     409            zipname = os.path.join(d, 'grouper.zip')
     410            dest = os.path.join(self.auth_dir, 'update')
     411            resp = urlopen('%s?uid=%s' % (self.grouper_url, fstr))
     412            f = open(zipname, 'w')
     413            f.write(resp.read())
     414            f.close()
     415            zf = zipfile.ZipFile(zipname, 'r')
     416            zf.extractall(dest)
     417            zf.close()
     418        finally:
     419            shutil.rmtree(d)
    396420
    397421
     
    16221646        if not self.auth.import_credentials(data_list=req.get('credential', [])):
    16231647            self.log.debug("Failed to import delegation credentials(!)")
     1648        self.get_grouper_updates(fid)
     1649        self.auth.update()
    16241650        self.auth.save()
    16251651
     
    21222148        # Import information from the requester
    21232149        # import may partially succeed so always save credentials and warn
    2124         if not self.auth.import_credentials(data_list=req.get('credential', [])):
     2150        if not self.auth.import_credentials(data_list=req.get('credential',[])):
    21252151            self.log.debug("Failed to import delegation credentials(!)")
     2152        self.get_grouper_updates(fid)
     2153        self.auth.update()
    21262154        self.auth.save()
    21272155
     
    25632591
    25642592        self.log.info("Multi Info call started for %s" %  fid)
     2593        self.get_grouper_updates(fid)
     2594        self.auth.update()
     2595        self.auth.save()
    25652596        self.state_lock.acquire()
    25662597        for key in [ k for k in self.state.keys() if isinstance(k, fedid)]:
Note: See TracChangeset for help on using the changeset viewer.