Changeset a7c0bcb for fedd


Ignore:
Timestamp:
Dec 6, 2010 5:51:09 PM (14 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master
Children:
ac15159, c179764, cd60510
Parents:
35a5879
Message:

Allow users to pass topdl to fedd_create.py. fedd_create autodetects and composes the proper message. The experiment controller now just takes the topology as given.

Location:
fedd
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • fedd/fedd_create.py

    r35a5879 ra7c0bcb  
    1515        get_abac_certs
    1616from federation.util import abac_split_cert, abac_context_to_creds
     17from federation import topdl
     18
     19from xml.parsers.expat import ExpatError
    1720
    1821class fedd_create_opts(client_opts):
     
    154157
    155158if opts.file:
     159
     160    top = None
     161    # Try the file as a topdl description
    156162    try:
    157         lines = [ line for line in open(opts.file, 'r')]
    158         exp_desc = "".join(lines)
     163        top = topdl.topology_from_xml(filename=opts.file, top='experiment')
    159164    except EnvironmentError:
     165        # Can't read the file, fail now
    160166        sys.exit("Cannot read description file (%s)" %opts.file)
     167    except ExpatError:
     168        # The file is not topdl, fall and assume it's ns2
     169        pass
     170
     171    if top is None:
     172        try:
     173            lines = [ line for line in open(opts.file, 'r')]
     174            exp_desc = "".join(lines)
     175            # Parse all the strings that we can pull out of the file using the
     176            # service_re.
     177            svcs.extend([parse_service(service_re.match(l).group(1)) \
     178                    for l in lines if service_re.match(l)])
     179        except EnvironmentError:
     180            sys.exit("Cannot read description file (%s)" %opts.file)
    161181else:
    162182    sys.exit("Must specify an experiment description (--file)")
     
    183203    svcs.append(project_export_service(opts.master, opts.project))
    184204svcs.extend([ parse_service(s) for s in opts.service])
    185 
    186 # Parse all the strings that we can pull out of the file using the service_re.
    187 svcs.extend([parse_service(service_re.match(l).group(1)) \
    188         for l in lines if service_re.match(l)])
    189205
    190206# Create a testbed map if one is specified
     
    253269
    254270# Construct the Create message
    255 msg = { 'experimentdescription': { 'ns2description': exp_desc }, }
     271if top:
     272    msg = { 'experimentdescription' : { 'topdldescription': top.to_dict() }, }
     273else:
     274    msg = { 'experimentdescription': { 'ns2description': exp_desc }, }
    256275
    257276if svcs:
  • fedd/federation/experiment_control.py

    r35a5879 ra7c0bcb  
    15581558        descr=req.get('experimentdescription', None)
    15591559        if descr:
    1560             file_content=descr.get('ns2description', None)
     1560            if 'ns2description' in descr:
     1561                file_content=descr['ns2description']
     1562            elif 'topdldescription' in descr:
     1563                return topdl.Topology(**descr['topdldescription'])
     1564            else:
     1565                raise service_error(service_error.req,
     1566                        'Unknown experiment description type')
    15611567        else:
    15621568            raise service_error(service_error.req, "No experiment description")
Note: See TracChangeset for help on using the changeset viewer.