Changeset 4fc2250 for fedd


Ignore:
Timestamp:
Sep 5, 2008 4:08:19 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:
987aaa1
Parents:
bcbf543
Message:

add slice/experiment name

Location:
fedd
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • fedd/fedd_create_experiment.py

    rbcbf543 r4fc2250  
    12361236                print >>self.trace_file, "Experiment started"
    12371237
     1238        # Generate an ID for the experiment (slice) and a certificate that the
     1239        # allocator can use to prove they own it.  We'll ship it back through
     1240        # the encrypted connection.
     1241        (expid, expcert) = generate_fedid("test", dir=tmpdir,
     1242                trace=self.trace_file)
     1243
     1244        if self.trace_file:
     1245            print >>self.trace_file, "removing %s" % tmpdir
     1246
     1247        # Walk up tmpdir, deleting as we go
     1248        for path, dirs, files in os.walk(tmpdir, topdown=False):
     1249            for f in files:
     1250                os.remove(os.path.join(path, f))
     1251            for d in dirs:
     1252                os.rmdir(os.path.join(path, d))
     1253        os.rmdir(tmpdir)
     1254       
    12381255        return { 'emulab' : [ tbparams[tb]['emulab'] \
    12391256                for tb in tbparams.keys() \
    12401257                    if tbparams[tb].has_key('emulab') ],\
    12411258                    'experiment': vtopo,\
    1242                     'vis' : vis }
     1259                    'vis' : vis,
     1260                    'experimentID' : { 'fedid': expid },\
     1261                    'experimentAccess': { 'X509' : expcert },\
     1262                }
    12431263
    12441264if __name__ == '__main__':
  • fedd/fedd_types.xsd

    rbcbf543 r4fc2250  
    319319        maxOccurs="1"/>
    320320      <xsd:element name="vis" type="tns:visType" minOccurs="0"
     321        maxOccurs="1"/>
     322      <xsd:element name="experimentID" type="tns:IDType"/>
     323      <xsd:element name="experimentAccess" type="tns:accessType" minOccurs="0"
    321324        maxOccurs="1"/>
    322325    </xsd:sequence>
  • fedd/fedd_util.py

    rbcbf543 r4fc2250  
    11#!/usr/local/bin/python
    22
    3 import sys
     3import os, sys
     4import subprocess
     5import tempfile
    46
    57from M2Crypto import SSL, X509, EVP
     
    225227    else:
    226228        return element
     229
     230def generate_fedid(subj, bits=2048, trace=None, dir=None):
     231    """
     232    Create a new certificate and derive a fedid from it.
     233
     234    The fedid and the certificte are returned as a tuple.
     235    """
     236
     237    keypath = None
     238    certpath = None
     239    try:
     240        try:
     241            kd, keypath = tempfile.mkstemp(dir=dir, prefix="key",
     242                    suffix=".pem")
     243            cd, certpath = tempfile.mkstemp(dir=dir, prefix="cert",
     244                    suffix=".pem")
     245
     246            cmd = ["openssl", "req", "-text", "-newkey", "rsa:%d" % bits,
     247                    "-keyout", keypath,  "-nodes", "-subj", "/CN=%s" % subj,
     248                    "-x509", "-days", "30", "-out", certpath]
     249
     250            if trace:
     251                print >>trace, "calling %s" % " ".join(cmd)
     252                call_out = trace
     253            else:
     254                call_out = open("/dev/null", "w")
     255               
     256            rv = subprocess.call(cmd, stdout=call_out, stderr=call_out)
     257            if rv == 0:
     258                cert = ""
     259                for p in (certpath, keypath):
     260                    f = open(p)
     261                    for line in f:
     262                        cert += line
     263               
     264                fid = fedid(file=certpath)
     265                return (fid, cert)
     266            else:
     267                return None
     268        except IOError, e:
     269            raise e
     270    finally:
     271        if keypath: os.remove(keypath)
     272        if certpath: os.remove(certpath)
Note: See TracChangeset for help on using the changeset viewer.