Ignore:
Timestamp:
Feb 13, 2010 2:42:32 PM (14 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
Children:
94a00cb
Parents:
dac2316
Message:

Access controllers importing userconfig will download the file containingthe
configuration now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/emulab_access.py

    rdac2316 rfe28bb2  
    7171        self.userconfdir = config.get("access","userconfdir")
    7272        self.userconfcmd = config.get("access","userconfcmd")
     73        self.userconfurl = config.get("access","userconfurl")
    7374        self.ssh_privkey_file = config.get("access","ssh_privkey_file")
    7475        self.ssh_pubkey_file = config.get("access","ssh_pubkey_file")
     
    326327                    self.auth.set_attribute(o, fedid(hexstr=k))
    327328                if self.allocation[k].has_key('userconfig'):
    328                     sfid = hexstr=self.allocation[k]['userconfig']
     329                    sfid = self.allocation[k]['userconfig']
    329330                    fid = fedid(hexstr=sfid)
    330                     self.auth.set_attribute(fid, sfid)
     331                    self.auth.set_attribute(fid, "/%s" % sfid)
    331332
    332333
     
    525526                stdout=cf, stderr=dev_null, close_fds=True)
    526527
    527         self.auth.set_attribute(confid, str(confid))
     528        self.auth.set_attribute(confid, "/%s" % str(confid))
    528529
    529530        return confid, confcert
     
    554555                        outs['server'] = "http://boss:7777"
    555556                    elif sname == 'userconfig':
    556                         if self.userconfdir and self.userconfcmd:
     557                        if self.userconfdir and self.userconfcmd \
     558                                and self.userconfurl:
    557559                            cid, cert = self.export_userconf(project)
    558                             outs['server'] = "%s/%s" %(self.testbed, str(cid))
     560                            outs['server'] = "%s/%s" % \
     561                                    (self.userconfurl, str(cid))
    559562                            outs['fedAttr'] = [
    560563                                    { 'attribute': 'cert', 'value': cert },
     
    11481151
    11491152    def StartSegment(self, req, fid):
    1150         def get_url(url, cf, destdir):
     1153        def get_url(url, cf, destdir, fn=None):
    11511154            po = urlparse(url)
    1152             fn = po.path.rpartition('/')[2]
     1155            if not fn:
     1156                fn = po.path.rpartition('/')[2]
    11531157            try:
    11541158                conn = httplib.HTTPSConnection(po.hostname, port=po.port,
     
    11651169                lf.close()
    11661170            except IOError, e:
     1171                print e
    11671172                raise service_error(service_error.internal,
    1168                         "Erro writing tempfile: %s" %e)
     1173                        "Error writing tempfile: %s" %e)
    11691174            except httplib.HTTPException, e:
     1175                print e
    11701176                raise service_error(service_error.internal,
    11711177                        "Error retrieving data: %s" % e)
     
    12271233                if a['attribute'] == 'experiment_name':
    12281234                    ename = a['value']
     1235
     1236            # If the userconf service was imported, collect the configuration
     1237            # data.
     1238            for s in services:
     1239                if s.get("name", "") == 'userconfig' \
     1240                        and s.get('visibility',"") == 'import':
     1241                    u = s.get('server', None)
     1242                    print "url %s" % u
     1243                    for a in s.get('fedAttr', []):
     1244                        if a.get('attribute',"") == 'cert':
     1245                            cert = a.get('value', None)
     1246                            break
     1247                    else:
     1248                        cert = None
     1249
     1250                    if not cert:
     1251                        raise service_error(service_error.req,
     1252                                "No certificate for retreiving userconfig")
     1253                    try:
     1254                        tfos, tn = tempfile.mkstemp(suffix=".pem")
     1255                        tf = os.fdopen(tfos, 'w')
     1256                        print >>tf, cert
     1257                        tf.close()
     1258                        print "tn %s" % tn
     1259                        get_url(u, tn, tmpdir, "userconf")
     1260                    except IOError, e:
     1261                        raise service_error(service.error.internal,
     1262                                "Cannot create temp file for " +
     1263                                "userconfig certificates: %s e")
     1264                    finally:
     1265                        if tn: os.remove(tn)
     1266                    break
     1267
     1268
    12291269
    12301270            proj = None
Note: See TracChangeset for help on using the changeset viewer.