Index: fedd/federation/experiment_control.py
===================================================================
--- fedd/federation/experiment_control.py	(revision d31a171939b979b5cd8ec9b18f6072e661275889)
+++ fedd/federation/experiment_control.py	(revision 5ecb9a3b2a114374ea588072cccdcaed78f5e071)
@@ -203,4 +203,5 @@
 			"creating local one.")
 		auth = authorizer()
+	    self.get_access = self.legacy_get_access
 	elif self.auth_type == 'abac':
 	    self.auth = abac_authorizer(load=self.auth_dir)
@@ -1451,20 +1452,13 @@
         return rv
 
-    def create_experiment(self, req, fid):
-        """
-        The external interface to experiment creation called from the
-        dispatcher.
-
-        Creates a working directory, splits the incoming description using the
-        splitter script and parses out the various subsections using the
-	classes above.  Once each sub-experiment is created, use pooled threads
-	to instantiate them and start it all up.
-        """
-
-        req = req.get('CreateRequestBody', None)
-        if not req:
-            raise service_error(service_error.req,
-                    "Bad request format (no CreateRequestBody)")
-
+    @staticmethod
+    def get_create_key(req):
+	"""
+	Parse the experiment identifiers out of the request (the request body
+	tag has been removed).  Specifically this pulls either the fedid or the
+	localname out of the experimentID field.  A fedid is preferred.  If
+	neither is present or the request does not contain the fields,
+	service_errors are raised.
+	"""
         # Get the experiment access
         exp = req.get('experimentID', None)
@@ -1472,10 +1466,6 @@
             if exp.has_key('fedid'):
                 key = exp['fedid']
-		expid = key
-		eid = None
             elif exp.has_key('localname'):
                 key = exp['localname']
-		eid = key
-		expid = None
             else:
                 raise service_error(service_error.req, "Unknown lookup type")
@@ -1483,57 +1473,16 @@
             raise service_error(service_error.req, "No request?")
 
-	# Import information from the requester
-	if self.auth.import_credentials(data_list=req.get('credential', [])):
-	    self.auth.save()
-
-        self.check_experiment_access(fid, key)
-
-	# Install the testbed map entries supplied with the request into a copy
-	# of the testbed map.
-	tbmap = dict(self.tbmap)
-	for m in req.get('testbedmap', []):
-	    if 'testbed' in m and 'uri' in m:
-		tbmap[m['testbed']] = m['uri']
-
-        try:
-            tmpdir = tempfile.mkdtemp(prefix="split-")
-            os.mkdir(tmpdir+"/keys")
-        except EnvironmentError:
-            raise service_error(service_error.internal, "Cannot create tmp dir")
-
-        gw_pubkey_base = "fed.%s.pub" % self.ssh_type
-        gw_secretkey_base = "fed.%s" % self.ssh_type
-        gw_pubkey = tmpdir + "/keys/" + gw_pubkey_base
-        gw_secretkey = tmpdir + "/keys/" + gw_secretkey_base
-        tclfile = tmpdir + "/experiment.tcl"
-        tbparams = { }
-        try:
-            access_user = self.accessdb[fid]
-        except KeyError:
-            raise service_error(service_error.internal,
-                    "Access map and authorizer out of sync in " + \
-                            "create_experiment for fedid %s"  % fid)
-
-        pid = "dummy"
-        gid = "dummy"
-
-        # The tcl parser needs to read a file so put the content into that file
-        descr=req.get('experimentdescription', None)
-        if descr:
-            file_content=descr.get('ns2description', None)
-            if file_content:
-                try:
-                    f = open(tclfile, 'w')
-                    f.write(file_content)
-                    f.close()
-                except EnvironmentError:
-                    raise service_error(service_error.internal,
-                            "Cannot write temp experiment description")
-            else:
-                raise service_error(service_error.req, 
-                        "Only ns2descriptions supported")
-        else:
-            raise service_error(service_error.req, "No experiment description")
-
+	return key
+
+    def get_experiment_ids_and_start(self, key, tmpdir):
+	"""
+	Get the experiment name, id and access certificate from the state, and
+	set the experiment state to 'starting'.  returns a triple (fedid,
+	localname, access_cert_file). The access_cert_file is a copy of the
+	contents of the access certificate, created in the tempdir with
+	restricted permissions.  If things are confused, raise an exception.
+	"""
+
+	expid = eid = None
 	self.state_lock.acquire()
 	if self.state.has_key(key):
@@ -1551,11 +1500,7 @@
 	self.state_lock.release()
 
-	if not (eid and expid):
-	    raise service_error(service_error.internal, 
-		    "Cannot find local experiment info!?")
-
 	# make a protected copy of the access certificate so the experiment
 	# controller can act as the experiment principal.
-	if expcert and self.auth_type != 'legacy':
+	if expcert:
 	    expcert_file = self.make_temp_certfile(expcert, tmpdir)
 	    if not expcert_file:
@@ -1565,6 +1510,159 @@
 	    expcert_file = None
 
+	return (eid, expid, expcert_file)
+
+    def get_topology(self, req, tmpdir):
+	"""
+	Get the ns2 content and put it into a file for parsing.  Call the local
+	or remote parser and return the topdl.Topology.  Errors result in
+	exceptions.  req is the request and tmpdir is a work directory.
+	"""
+
+        # The tcl parser needs to read a file so put the content into that file
+        descr=req.get('experimentdescription', None)
+        if descr:
+            file_content=descr.get('ns2description', None)
+        else:
+            raise service_error(service_error.req, "No experiment description")
+
+
+	if self.splitter_url:
+	    self.log.debug("Calling remote topdl translator at %s" % \
+		    self.splitter_url)
+	    top = self.remote_ns2topdl(self.splitter_url, file_content)
+	else:
+	    tclfile = os.path.join(tmpdir, "experiment.tcl")
+            if file_content:
+                try:
+                    f = open(tclfile, 'w')
+                    f.write(file_content)
+                    f.close()
+                except EnvironmentError:
+                    raise service_error(service_error.internal,
+                            "Cannot write temp experiment description")
+            else:
+                raise service_error(service_error.req, 
+                        "Only ns2descriptions supported")
+	    pid = "dummy"
+	    gid = "dummy"
+	    eid = "dummy"
+
+	    tclcmd = [self.tclsh, self.tcl_splitter, '-t', '-x', 
+		str(self.muxmax), '-m', 'dummy']
+
+	    tclcmd.extend([pid, gid, eid, tclfile])
+
+	    self.log.debug("running local splitter %s", " ".join(tclcmd))
+	    # This is just fantastic.  As a side effect the parser copies
+	    # tb_compat.tcl into the current directory, so that directory
+	    # must be writable by the fedd user.  Doing this in the
+	    # temporary subdir ensures this is the case.
+	    tclparser = Popen(tclcmd, stdout=PIPE, close_fds=True, 
+		    cwd=tmpdir)
+	    split_data = tclparser.stdout
+
+	    top = topdl.topology_from_xml(file=split_data, top="experiment")
+	    os.remove(tclfile)
+
+	return top
+
+    def get_testbed_services(self, req):
+	"""
+	Parse the services section of the request into into two dicts mapping
+	testbed to lists of federated_service objects.  The first lists all
+	exporters of services, and the second all exporters of services that
+	need control portals int the experiment.
+	"""
+	masters = { }
+	pmasters = { }
+	for s in req.get('service', []):
+	    # If this is a service request with the importall field
+	    # set, fill it out.
+
+	    if s.get('importall', False):
+		s['import'] = [ tb for tb in testbeds \
+			if tb not in s.get('export',[])]
+		del s['importall']
+
+	    # Add the service to masters
+	    for tb in s.get('export', []):
+		if s.get('name', None):
+
+		    params = { }
+		    for a in s.get('fedAttr', []):
+			params[a.get('attribute', '')] = a.get('value','')
+
+		    fser = federated_service(name=s['name'],
+			    exporter=tb, importers=s.get('import',[]),
+			    params=params)
+		    if fser.name == 'hide_hosts' \
+			    and 'hosts' not in fser.params:
+			fser.params['hosts'] = \
+				",".join(tb_hosts.get(fser.exporter, []))
+		    if tb in masters: masters[tb].append(fser)
+		    else: masters[tb] = [fser]
+
+		    if fser.portal:
+			if tb not in pmasters: pmasters[tb] = [ fser ]
+			else: pmasters[tb].append(fser)
+		else:
+		    self.log.error('Testbed service does not have name " + \
+			    "and importers')
+	return masters, pmasters
+
+
+    def create_experiment(self, req, fid):
+        """
+        The external interface to experiment creation called from the
+        dispatcher.
+
+        Creates a working directory, splits the incoming description using the
+        splitter script and parses out the various subsections using the
+	classes above.  Once each sub-experiment is created, use pooled threads
+	to instantiate them and start it all up.
+        """
+
+        req = req.get('CreateRequestBody', None)
+        if req:
+	    key = self.get_create_key(req)
+	else:
+            raise service_error(service_error.req,
+                    "Bad request format (no CreateRequestBody)")
+
+	# Import information from the requester
+	if self.auth.import_credentials(data_list=req.get('credential', [])):
+	    self.auth.save()
+
+	# Make sure that the caller can talk to us
+        self.check_experiment_access(fid, key)
+
+	# Install the testbed map entries supplied with the request into a copy
+	# of the testbed map.
+	tbmap = dict(self.tbmap)
+	for m in req.get('testbedmap', []):
+	    if 'testbed' in m and 'uri' in m:
+		tbmap[m['testbed']] = m['uri']
+
+	# a place to work
+        try:
+            tmpdir = tempfile.mkdtemp(prefix="split-")
+            os.mkdir(tmpdir+"/keys")
+        except EnvironmentError:
+            raise service_error(service_error.internal, "Cannot create tmp dir")
+
+        gw_pubkey_base = "fed.%s.pub" % self.ssh_type
+        gw_secretkey_base = "fed.%s" % self.ssh_type
+        gw_pubkey = tmpdir + "/keys/" + gw_pubkey_base
+        gw_secretkey = tmpdir + "/keys/" + gw_secretkey_base
+        tbparams = { }
+
+	eid, expid, expcert_file = \
+		self.get_experiment_ids_and_start(key, tmpdir)
+
+	# This catches exceptions to clear the placeholder if necessary
         try: 
-            # This catches exceptions to clear the placeholder if necessary
+	    if not (eid and expid):
+		raise service_error(service_error.internal, 
+			"Cannot find local experiment info!?")
             try:
                 self.generate_ssh_keys(gw_secretkey, self.ssh_type)
@@ -1573,95 +1671,26 @@
                         "Bad key type (%s)" % self.ssh_type)
 
-	    # Copy the service request
-	    tb_services = [ s for s in req.get('service',[]) ]
-	    # Translate to topdl
-            if self.splitter_url:
-                self.log.debug("Calling remote topdl translator at %s" % \
-                        self.splitter_url)
-                top = self.remote_ns2topdl(self.splitter_url, file_content)
-            else:
-                tclcmd = [self.tclsh, self.tcl_splitter, '-t', '-x', 
-                    str(self.muxmax), '-m', 'dummy']
-
-                tclcmd.extend([pid, gid, eid, tclfile])
-
-                self.log.debug("running local splitter %s", " ".join(tclcmd))
-                # This is just fantastic.  As a side effect the parser copies
-                # tb_compat.tcl into the current directory, so that directory
-                # must be writable by the fedd user.  Doing this in the
-                # temporary subdir ensures this is the case.
-                tclparser = Popen(tclcmd, stdout=PIPE, close_fds=True, 
-                        cwd=tmpdir)
-                split_data = tclparser.stdout
-
-		top = topdl.topology_from_xml(file=split_data, top="experiment")
-
+	    top = self.get_topology(req, tmpdir)
+
+	    # Assign the IPs
 	    hosts, ip_allocator = self.allocate_ips_to_topo(top)
 	    # Find the testbeds to look up
-            testbeds = set([ a.value for e in top.elements \
-		    for a in e.attribute \
-			if a.attribute == 'testbed'])
-
 	    tb_hosts = { }
-	    for tb in testbeds:
-		tb_hosts[tb] = [ e.name for e in top.elements \
-			if isinstance(e, topdl.Computer) and \
-			    e.get_attribute('testbed') and \
-			    e.get_attribute('testbed') == tb]
-
-	    masters = { }	    # testbeds exporting services
-	    pmasters = { }	    # Testbeds exporting services that 
-				    # need portals
-	    for s in tb_services:
-		# If this is a service request with the importall field
-		# set, fill it out.
-
-		if s.get('importall', False):
-		    s['import'] = [ tb for tb in testbeds \
-			    if tb not in s.get('export',[])]
-		    del s['importall']
-
-		# Add the service to masters
-		for tb in s.get('export', []):
-		    if s.get('name', None):
-			if tb not in masters:
-			    masters[tb] = [ ]
-
-			params = { }
-			if 'fedAttr' in s:
-			    for a in s['fedAttr']:
-				params[a.get('attribute', '')] = \
-					a.get('value','')
-
-			fser = federated_service(name=s['name'],
-				exporter=tb, importers=s.get('import',[]),
-				params=params)
-			if fser.name == 'hide_hosts' \
-				and 'hosts' not in fser.params:
-			    fser.params['hosts'] = \
-				    ",".join(tb_hosts.get(fser.exporter, []))
-			masters[tb].append(fser)
-
-			if fser.portal:
-			    if tb not in pmasters: pmasters[tb] = [ fser ]
-			    else: pmasters[tb].append(fser)
-		    else:
-			self.log.error('Testbed service does not have name " + \
-				"and importers')
-
-
+	    testbeds = [ ]
+	    for e in top.elements:
+		if isinstance(e, topdl.Computer):
+		    tb = e.get_attribute('testbed') or 'default'
+		    if tb in tb_hosts: tb_hosts[tb].append(e.name)
+		    else: 
+			tb_hosts[tb] = [ e.name ]
+			testbeds.append(tb)
+
+	    masters, pmasters = self.get_testbed_services(req)
             allocated = { }         # Testbeds we can access
 	    topo ={ }		    # Sub topologies
 	    connInfo = { }	    # Connection information
 
-	    if self.auth_type == 'legacy':
-		self.get_legcay_access_to_testbeds(testbeds, access_user, 
-			allocated, tbparams, masters, tbmap)
-	    elif self.auth_type == 'abac':
-		self.get_access_to_testbeds(testbeds, fid, allocated, 
-			tbparams, masters, tbmap, expid, expcert_file)
-	    else:
-		raise service_error(service_error.internal, 
-			"Unknown auth_type %s" % self.auth_type)
+	    self.get_access_to_testbeds(testbeds, fid, allocated, 
+		    tbparams, masters, tbmap, expid, expcert_file)
 
 	    self.split_topology(top, topo, testbeds)
Index: fedd/federation/experiment_control_legacy.py
===================================================================
--- fedd/federation/experiment_control_legacy.py	(revision d31a171939b979b5cd8ec9b18f6072e661275889)
+++ fedd/federation/experiment_control_legacy.py	(revision 5ecb9a3b2a114374ea588072cccdcaed78f5e071)
@@ -48,5 +48,6 @@
     """
 
-    def get_legacy_access(self, tb, tbparam, access_user, masters, tbmap):
+    def get_legacy_access(self, tb, tbparam, fid, masters, tbmap, expid=None,
+	    expcert=None):
         """
         Get access to testbed through fedd and set the parameters for that tb
@@ -67,4 +68,11 @@
 		raise service_error(service_error.req,
 			"More than one project export is not supported")
+
+	try:
+	    access_user = self.accessdb[fid]
+	except KeyError:
+	    raise service_error(service_error.internal,
+		    "Access map and authorizer out of sync in " + \
+			    "create_experiment for fedid %s"  % fid)
 
         uri = tbmap.get(testbed_base(tb), None)
@@ -187,14 +195,2 @@
 
 
-    def get_legacy_access_to_testbeds(self, testbeds, access_user, allocated, 
-	    tbparams, masters, tbmap):
-	"""
-	Request access to the various testbeds required for this instantiation
-	(passed in as testbeds).  User, access_user, expoert_project and master
-	are used to construct the correct requests.  Per-testbed parameters are
-	returned in tbparams.
-	"""
-	for tb in testbeds:
-	    self.get_access(tb, tbparams, access_user, masters, tbmap)
-	    allocated[tb] = 1
-
