Changeset a3ad8bd


Ignore:
Timestamp:
Dec 4, 2009 2:21:11 PM (14 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
Children:
c17efe6
Parents:
4ac0a41
Message:

checkpoint, adding new operation - prequel to splitting the create call to allow delegation

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • fedd/fedd_client.py

    r4ac0a41 ra3ad8bd  
    8282        self.add_option("--trace", action="store_const", dest="tracefile",
    8383                const=sys.stderr, help="Print SOAP exchange to stderr")
     84class fedd_new_opts(fedd_client_opts):
     85    def __init__(self):
     86        fedd_client_opts.__init__(self)
     87        self.add_option("-e", "--experiment_cert", dest="out_certfile",
     88                type="string", help="output certificate file")
     89        self.add_option("-E", "--experiment_name", dest="exp_name",
     90                type="string", help="Suggested experiment name")
    8491
    8592class fedd_create_opts(fedd_client_opts):
     
    13141321                sys.exit("No log returned")
    13151322
    1316 class create(fedd_rpc):
     1323class new(fedd_rpc):
    13171324    def __init__(self):
    1318         fedd_rpc.__init__(self, "Create")
     1325        fedd_rpc.__init__(self, "New")
    13191326    def __call__(self):
    13201327        access_keys = []
    13211328        # Process the options using the customized option parser defined above
    1322         parser = fedd_create_opts(access_keys, self.add_ssh_key,
    1323                 self.add_x509_cert)
     1329        parser = fedd_new_opts()
    13241330
    13251331        (opts, args) = parser.parse_args()
     
    13291335                sys.exit("Cannot read trusted certificates (%s)" % opts.trusted)
    13301336
    1331         if not opts.project :
    1332             parser.error('--project is required')
    1333 
    13341337        if opts.debug > 0: opts.tracefile=sys.stderr
    13351338
    13361339        (user, cert) = self.get_user_info(access_keys)
    1337 
    1338         if opts.user: user = opts.user
    13391340
    13401341        if opts.cert != None: cert = opts.cert
     
    13451346        if os.access(cert, os.R_OK):
    13461347            fid = fedid(file=cert)
    1347             if opts.use_fedid == True:
    1348                 user = fid
    13491348        else:
    13501349            sys.exit("Cannot read certificate (%s)" % cert)
    13511350
    1352         if opts.file:
    1353             exp_desc = ""
    1354             try:
    1355                 f = open(opts.file, 'r')
    1356                 for line in f:
    1357                     exp_desc += line
    1358                 f.close()
    1359             except IOError:
    1360                 sys.exit("Cannot read description file (%s)" %opts.file)
    1361         else:
    1362             sys.exit("Must specify an experiment description (--file)")
    1363 
    1364         if not opts.master:
    1365             sys.exit("Must specify a master testbed (--master)")
    1366 
    13671351        out_certfile = opts.out_certfile
    13681352
    1369         msg = {
    1370                 'experimentdescription': { 'ns2description': exp_desc },
    1371                 'master': opts.master,
    1372                 'exportProject': { 'localname': opts.project },
    1373                 'user' : [ {\
    1374                         'userID': pack_id(user), \
    1375                         'access': [ { a.type: a.buf } for a in access_keys]\
    1376                         } ]
    1377                 }
     1353        msg = { }
    13781354
    13791355        if opts.exp_name:
     
    14121388            print "status: %s" % st
    14131389
     1390
     1391class create(fedd_rpc):
     1392    def __init__(self):
     1393        fedd_rpc.__init__(self, "Create")
     1394    def __call__(self):
     1395        access_keys = []
     1396        # Process the options using the customized option parser defined above
     1397        parser = fedd_create_opts(access_keys, self.add_ssh_key,
     1398                self.add_x509_cert)
     1399
     1400        (opts, args) = parser.parse_args()
     1401
     1402        if opts.trusted:
     1403            if ( not os.access(opts.trusted, os.R_OK) ) :
     1404                sys.exit("Cannot read trusted certificates (%s)" % opts.trusted)
     1405
     1406        if not opts.project :
     1407            parser.error('--project is required')
     1408
     1409        if opts.debug > 0: opts.tracefile=sys.stderr
     1410
     1411        (user, cert) = self.get_user_info(access_keys)
     1412
     1413        if opts.user: user = opts.user
     1414
     1415        if opts.cert != None: cert = opts.cert
     1416
     1417        if cert == None:
     1418            sys.exit("No certificate given (--cert) or found")
     1419
     1420        if os.access(cert, os.R_OK):
     1421            fid = fedid(file=cert)
     1422            if opts.use_fedid == True:
     1423                user = fid
     1424        else:
     1425            sys.exit("Cannot read certificate (%s)" % cert)
     1426
     1427        if opts.file:
     1428            exp_desc = ""
     1429            try:
     1430                f = open(opts.file, 'r')
     1431                for line in f:
     1432                    exp_desc += line
     1433                f.close()
     1434            except IOError:
     1435                sys.exit("Cannot read description file (%s)" %opts.file)
     1436        else:
     1437            sys.exit("Must specify an experiment description (--file)")
     1438
     1439        if not opts.master:
     1440            sys.exit("Must specify a master testbed (--master)")
     1441
     1442        out_certfile = opts.out_certfile
     1443
     1444        msg = {
     1445                'experimentdescription': { 'ns2description': exp_desc },
     1446                'master': opts.master,
     1447                'exportProject': { 'localname': opts.project },
     1448                'user' : [ {\
     1449                        'userID': pack_id(user), \
     1450                        'access': [ { a.type: a.buf } for a in access_keys]\
     1451                        } ]
     1452                }
     1453
     1454        if opts.exp_name:
     1455            msg['experimentID'] = { 'localname': opts.exp_name }
     1456
     1457        if opts.debug > 1: print >>sys.stderr, msg
     1458
     1459        try:
     1460            resp_dict = self.do_rpc(msg,
     1461                    opts.url, opts.transport, cert, opts.trusted,
     1462                    serialize_only=opts.serialize_only,
     1463                    tracefile=opts.tracefile)
     1464        except self.RPCException, e:
     1465            exit_with_fault(\
     1466                    {'desc': e.desc, 'errstr': e.errstr, 'code': e.code})
     1467        except RuntimeError, e:
     1468            sys.exit("Error processing RPC: %s" % e)
     1469
     1470        if opts.debug > 1: print >>sys.stderr, resp_dict
     1471
     1472        ea = resp_dict.get('experimentAccess', None)
     1473        if out_certfile and ea and ea.has_key('X509'):
     1474            try:
     1475                f = open(out_certfile, "w")
     1476                print >>f, ea['X509']
     1477                f.close()
     1478            except IOError:
     1479                sys.exit('Could not write to %s' %  out_certfile)
     1480        eid = resp_dict.get('experimentID', None)
     1481        if eid:
     1482            for id in eid:
     1483                for k in id.keys():
     1484                    print "%s: %s" % (k, id[k])
     1485        st = resp_dict.get('experimentStatus', None)
     1486        if st:
     1487            print "status: %s" % st
     1488
    14141489class split(fedd_rpc):
    14151490    def __init__(self):
     
    17491824
    17501825cmds = {\
     1826        'new': new(),\
    17511827        'create': create(),\
    17521828        'split': split(),\
  • fedd/federation/experiment_control.py

    r4ac0a41 ra3ad8bd  
    332332        # Dispatch tables
    333333        self.soap_services = {\
     334                'New': soap_handler('New', self.new_experiment),
    334335                'Create': soap_handler('Create', self.create_experiment),
    335336                'Vtopo': soap_handler('Vtopo', self.get_vtopo),
     
    342343
    343344        self.xmlrpc_services = {\
     345                'New': xmlrpc_handler('New', self.new_experiment),
    344346                'Create': xmlrpc_handler('Create', self.create_experiment),
    345347                'Vtopo': xmlrpc_handler('Vtopo', self.get_vtopo),
     
    498500        for fid in self.accessdb.keys():
    499501            self.auth.set_attribute(fid, 'create')
     502            self.auth.set_attribute(fid, 'new')
    500503
    501504    def read_mapdb(self, file):
     
    868871            }
    869872
    870        
    871873    def release_access(self, tb, aid, uri=None):
    872874        """
     
    12141216
    12151217
    1216     def create_experiment_state(self, fid, req, expid, expcert):
     1218    def create_experiment_state(self, fid, req, expid, expcert,
     1219            state='starting'):
    12171220        """
    12181221        Create the initial entry in the experiment's state.  The expid and
     
    12211224        includes a suggested local name that is used if possible.  If the local
    12221225        name is already taken by an experiment owned by this user that has
    1223         failed, it is overwriutten.  Otherwise new letters are added until a
     1226        failed, it is overwritten.  Otherwise new letters are added until a
    12241227        valid localname is found.  The generated local name is returned.
    12251228        """
     
    12501253                    'experimentID' : \
    12511254                            [ { 'localname' : eid }, {'fedid': expid } ],
    1252                     'experimentStatus': 'starting',
     1255                    'experimentStatus': state,
    12531256                    'experimentAccess': { 'X509' : expcert },
    12541257                    'owner': fid,
     
    12711274                    'experimentID' : \
    12721275                            [ { 'localname' : eid }, {'fedid': expid } ],
    1273                     'experimentStatus': 'starting',
     1276                    'experimentStatus': state,
    12741277                    'experimentAccess': { 'X509' : expcert },
    12751278                    'owner': fid,
     
    18581861
    18591862
     1863    def new_experiment(self, req, fid):
     1864        """
     1865        The external interface to empty initial experiment creation called from
     1866        the dispatcher.
     1867
     1868        Creates a working directory, splits the incoming description using the
     1869        splitter script and parses out the avrious subsections using the
     1870        lcasses above.  Once each sub-experiment is created, use pooled threads
     1871        to instantiate them and start it all up.
     1872        """
     1873        if not self.auth.check_attribute(fid, 'new'):
     1874            raise service_error(service_error.access, "New access denied")
     1875
     1876        try:
     1877            tmpdir = tempfile.mkdtemp(prefix="split-")
     1878        except IOError:
     1879            raise service_error(service_error.internal, "Cannot create tmp dir")
     1880
     1881        try:
     1882            access_user = self.accessdb[fid]
     1883        except KeyError:
     1884            raise service_error(service_error.internal,
     1885                    "Access map and authorizer out of sync in " + \
     1886                            "create_experiment for fedid %s"  % fid)
     1887
     1888        pid = "dummy"
     1889        gid = "dummy"
     1890
     1891        req = req.get('NewRequestBody', None)
     1892        if not req:
     1893            raise service_error(service_error.req,
     1894                    "Bad request format (no NewRequestBody)")
     1895
     1896        # Generate an ID for the experiment (slice) and a certificate that the
     1897        # allocator can use to prove they own it.  We'll ship it back through
     1898        # the encrypted connection.
     1899        (expid, expcert) = generate_fedid("test", dir=tmpdir, log=self.log)
     1900
     1901        #now we're done with the tmpdir, and it should be empty
     1902        if self.cleanup:
     1903            self.log.debug("[new_experiment]: removing %s" % tmpdir)
     1904            os.rmdir(tmpdir)
     1905        else:
     1906            self.log.debug("[new_experiment]: not removing %s" % tmpdir)
     1907
     1908        eid = self.create_experiment_state(fid, req, expid, expcert,
     1909                state='empty')
     1910
     1911        # Let users touch the state
     1912        self.auth.set_attribute(fid, expid)
     1913        self.auth.set_attribute(expid, expid)
     1914        # Override fedids can manipulate state as well
     1915        for o in self.overrides:
     1916            self.auth.set_attribute(o, expid)
     1917
     1918        rv = {
     1919                'experimentID': [
     1920                    {'localname' : eid }, { 'fedid': copy.copy(expid) }
     1921                ],
     1922                'experimentStatus': 'empty',
     1923                'experimentAccess': { 'X509' : expcert }
     1924            }
     1925
     1926        return rv
     1927
     1928
    18601929    def create_experiment(self, req, fid):
    18611930        """
  • wsdl/fedd.wsdl

    r4ac0a41 ra3ad8bd  
    3232    <part name="ReleaseAccessResponseBody" type="xsd1:releaseResponseType"/>
    3333  </message>
     34
     35  <message name="NewRequestMessage">
     36    <part name="NewRequestBody" type="xsd1:newRequestType"/>
     37  </message>
     38
     39  <message name="NewResponseMessage">
     40    <part name="NewResponseBody" type="xsd1:newResponseType"/>
     41  </message>
     42
     43
    3444  <message name="CreateRequestMessage">
    3545    <part name="CreateRequestBody" type="xsd1:createRequestType"/>
     
    126136      <fault name="ReleaseAccessFeddFault" message="tns:FaultMessage"/>
    127137    </operation>
     138    <operation name="New">
     139      <documentation>
     140        A request to create a federated experiment in an empty state so
     141        resources can be attached and attributes delegated.  On success the
     142        identity of the new experiment is returned.
     143      </documentation>
     144      <input message="tns:NewRequestMessage"/>
     145      <output message="tns:NewResponseMessage"/>
     146      <fault name="NewFeddFault" message="tns:FaultMessage"/>
     147    </operation>
    128148    <operation name="Create">
    129149      <documentation>
     
    257277        </fault>
    258278      </operation>
     279      <operation name="New">
     280        <documentation>
     281          The bindings of this operation are straightforward SOAP RPC 1.1.
     282        </documentation>
     283        <soap:operation soapAction="New"/>
     284        <input>
     285          <soap:body use="literal" parts="tns:NewRequestBody"
     286            namespace="http://www.isi.edu/faber/fedd.wsdl"
     287            encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
     288        </input>
     289        <output>
     290          <soap:body use="literal" parts="tns:NewResponseBody"
     291            namespace="http://www.isi.edu/faber/fedd.wsdl"
     292            encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
     293        </output>
     294        <fault name="NewFeddFault">
     295          <soap:fault use="literal"  name="tns:FeddFault"
     296            namespace="http://www.isi.edu/faber/fedd.wsdl"
     297            encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
     298        </fault>
     299      </operation>
    259300      <operation name="Create">
    260301        <documentation>
  • wsdl/fedd_types.xsd

    r4ac0a41 ra3ad8bd  
    6363    </xsd:annotation>
    6464    <xsd:restriction base="xsd:string">
     65      <xsd:enumeration value="empty"/>
    6566      <xsd:enumeration value="active"/>
    6667      <xsd:enumeration value="starting"/>
     
    350351      <xsd:element name="topdldescription" type="topdl:topologyType"/>
    351352    </xsd:choice>
     353  </xsd:complexType>
     354
     355  <xsd:complexType name="newRequestType">
     356    <xsd:annotation>
     357      <xsd:documentation>
     358        Request for an experiment to which credentials can be delegated and
     359        resources attached.  A local name may be included as a human readable
     360        accessor, local to this experiment controller.  It is a suggestion and
     361        may be modified.  experimentID can only be a local name.
     362
     363        Credentials are seed credentials to begin the proof.
     364      </xsd:documentation>
     365    </xsd:annotation>
     366    <xsd:sequence>
     367      <xsd:element name="experimentID" type="tns:IDType" minOccurs="0"
     368        maxOccurs="1"/>
     369      <xsd:element name="credential" type="xsd:base64Binary" minOccurs="0"
     370        maxOccurs="unbounded"/>
     371    </xsd:sequence>
     372  </xsd:complexType>
     373
     374  <xsd:complexType name="newResponseType">
     375    <xsd:annotation>
     376      <xsd:documentation>
     377        Result of a new experiment creation.  A successful sreation will have
     378        an experimentState of "empty", 2 experimentIDs, one a fedid and one a
     379        local name, and an experimentAccess that allows the creator to act as
     380        the experiment.
     381      </xsd:documentation>
     382    </xsd:annotation>
     383    <xsd:sequence>
     384      <xsd:element name="experimentID" type="tns:IDType" minOccurs="0"
     385        maxOccurs="unbounded"/>
     386      <xsd:element name="experimentStatus" type="tns:statusType"/>
     387      <xsd:element name="experimentAccess" type="tns:accessType"/>
     388    </xsd:sequence>
    352389  </xsd:complexType>
    353390
Note: See TracChangeset for help on using the changeset viewer.