Index: fedd/fedd_create_experiment.py
===================================================================
--- fedd/fedd_create_experiment.py	(revision d0ae12d132a15761aec26000e42160013fd808de)
+++ fedd/fedd_create_experiment.py	(revision 6546868137c38bcdc7bdcdf452364e3d3c8f777a)
@@ -36,9 +36,7 @@
 	    muxmax=2,
 	    project_user = "faber",
-	    # scp_exec="/bin/echo",
 	    scp_exec="/usr/bin/scp",
 	    scripts_dir="./", 
 	    splitter=None,
-	    # ssh_exec="/bin/echo",
 	    ssh_exec="/usr/bin/ssh",
 	    ssh_identity_file=None,
@@ -49,5 +47,4 @@
 	    tclsh="/usr/local/bin/otclsh",
 	    tcl_splitter="/usr/testbed/lib/ns2ir/parse.tcl",
-	    tmpdir="/tmp",
 	    trusted_certs=None,
 	    ):
@@ -69,6 +66,4 @@
 	self.tcl_splitter = tcl_splitter
 	self.tbmap = tbmap
-	self.tmpdir = tmpdir 
-	self.tmpdir += "/split%d/" % os.getpid()
 	self.trusted_certs=trusted_certs
 
@@ -165,5 +160,5 @@
 	return True
 
-    def start_segment(self, tb, eid, tbparams, timeout=0):
+    def start_segment(self, tb, eid, tbparams, tmpdir, timeout=0):
 	host = "%s%s" % (tbparams[tb]['host'], tbparams[tb]['domain'])
 	user = tbparams[tb]['user']
@@ -192,6 +187,5 @@
 	print "transferring experiment to %s" % tb
 
-	if not self.scp_file("%s/%s/%s" % (self.tmpdir, tb, tclfile),
-		user, host):
+	if not self.scp_file("%s/%s/%s" % (tmpdir, tb, tclfile), user, host):
 	    return False
 	# Clear and create the tarfiles and rpm directories
@@ -207,19 +201,19 @@
 	    # Remote experiment is active.  Modify it.
 	    for f in base_confs:
-		if not self.scp_file("%s/%s" % (self.tmpdir, f), user, host,
+		if not self.scp_file("%s/%s" % (tmpdir, f), user, host,
 			"%s/%s" % (proj_dir, f)):
 		    return False
 	    if not self.ship_scripts(host, user, proj_dir):
 		return False
-	    if not self.ship_configs(host, user, "%s/%s" % (self.tmpdir, tb),
+	    if not self.ship_configs(host, user, "%s/%s" % (tmpdir, tb),
 		    proj_dir):
 		return False
-	    if os.path.isdir("%s/tarfiles" % self.tmpdir):
+	    if os.path.isdir("%s/tarfiles" % tmpdir):
 		if not self.ship_configs(host, user,
-			"%s/tarfiles" % self.tmpdir, tarfiles_dir):
-		    return False
-	    if os.path.isdir("%s/rpms" % self.tmpdir):
+			"%s/tarfiles" % tmpdir, tarfiles_dir):
+		    return False
+	    if os.path.isdir("%s/rpms" % tmpdir):
 		if not self.ship_configs(host, user,
-			"%s/rpms" % self.tmpdir, tarfiles_dir):
+			"%s/rpms" % tmpdir, tarfiles_dir):
 		    return False
 	    print "Modifying %s on %s" % (eid, tb)
@@ -232,19 +226,19 @@
 	    # Remote experiment swapped out.  Modify it and swap it in.
 	    for f in base_confs:
-		if not self.scp_file("%s/%s" % (self.tmpdir, f), user, host,
+		if not self.scp_file("%s/%s" % (tmpdir, f), user, host,
 			"%s/%s" % (proj_dir, f)):
 		    return False
 	    if not self.ship_scripts(host, user, proj_dir):
 		return False
-	    if not self.ship_configs(host, user, "%s/%s" % (self.tmpdir, tb),
+	    if not self.ship_configs(host, user, "%s/%s" % (tmpdir, tb),
 		    proj_dir):
 		return False
-	    if os.path.isdir("%s/tarfiles" % self.tmpdir):
+	    if os.path.isdir("%s/tarfiles" % tmpdir):
 		if not self.ship_configs(host, user,
-			"%s/tarfiles" % self.tmpdir, tarfiles_dir):
-		    return False
-	    if os.path.isdir("%s/rpms" % self.tmpdir):
+			"%s/tarfiles" % tmpdir, tarfiles_dir):
+		    return False
+	    if os.path.isdir("%s/rpms" % tmpdir):
 		if not self.ship_configs(host, user,
-			"%s/rpms" % self.tmpdir, tarfiles_dir):
+			"%s/rpms" % tmpdir, tarfiles_dir):
 		    return False
 	    print "Modifying %s on %s" % (eid, tb)
@@ -265,11 +259,11 @@
 
 	    # Tarfiles must be present for creation to work
-	    if os.path.isdir("%s/tarfiles" % self.tmpdir):
+	    if os.path.isdir("%s/tarfiles" % tmpdir):
 		if not self.ship_configs(host, user,
-			"%s/tarfiles" % self.tmpdir, tarfiles_dir):
-		    return False
-	    if os.path.isdir("%s/rpms" % self.tmpdir):
+			"%s/tarfiles" % tmpdir, tarfiles_dir):
+		    return False
+	    if os.path.isdir("%s/rpms" % tmpdir):
 		if not self.ship_configs(host, user,
-			"%s/rpms" % self.tmpdir, tarfiles_dir):
+			"%s/rpms" % tmpdir, tarfiles_dir):
 		    return False
 	    print "Creating %s on %s" % (eid, tb)
@@ -280,10 +274,10 @@
 	    # After startexp the per-experiment directories exist
 	    for f in base_confs:
-		if not self.scp_file("%s/%s" % (self.tmpdir, f), user, host,
+		if not self.scp_file("%s/%s" % (tmpdir, f), user, host,
 			"%s/%s" % (proj_dir, f)):
 		    return False
 	    if not self.ship_scripts(host, user, proj_dir):
 		return False
-	    if not self.ship_configs(host, user, "%s/%s" % (self.tmpdir, tb),
+	    if not self.ship_configs(host, user, "%s/%s" % (tmpdir, tb),
 		    proj_dir):
 		return False
@@ -903,9 +897,14 @@
 
     def create_experiment(self, req, fid):
+	try:
+	    tmpdir = tempfile.mkdtemp(prefix="split-")
+	except IOError:
+	    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 = self.tmpdir + "/keys/" + gw_pubkey_base
-	gw_secretkey = self.tmpdir + "/keys/" + gw_secretkey_base
-	tclfile = self.tmpdir + "/experiment.tcl"
+	gw_pubkey = tmpdir + "/keys/" + gw_pubkey_base
+	gw_secretkey = tmpdir + "/keys/" + gw_secretkey_base
+	tclfile = tmpdir + "/experiment.tcl"
 	tbparams = { }
 
@@ -921,9 +920,9 @@
 	fail_soft = False
 	# XXX
-	startem = False
+	startem = True
+
 
 	try:
-	    os.mkdir(self.tmpdir)
-	    os.mkdir(self.tmpdir+"/keys")
+	    os.mkdir(tmpdir+"/keys")
 	except OSError:
 	    raise service_error(service_error.internal,
@@ -961,12 +960,12 @@
 	started = { }
 
-	parse_current_testbed = self.current_testbed(eid, self.tmpdir)
+	parse_current_testbed = self.current_testbed(eid, tmpdir)
 	parse_allbeds = self.allbeds(self.get_access)
-	parse_gateways = self.gateways(eid, smbshare, master, self.tmpdir,
+	parse_gateways = self.gateways(eid, smbshare, master, tmpdir,
 		gw_pubkey_base, gw_secretkey_base, self.copy_file)
 	parse_vtopo = self.shunt_to_file("^#\s+Begin\s+Vtopo",
-		    "^#\s+End\s+Vtopo", self.tmpdir + "/vtopo.xml")
+		    "^#\s+End\s+Vtopo", tmpdir + "/vtopo.xml")
 	parse_hostnames = self.shunt_to_file("^#\s+Begin\s+hostnames",
-		    "^#\s+End\s+hostnames", self.tmpdir + "/hosts")
+		    "^#\s+End\s+hostnames", tmpdir + "/hosts")
 	parse_tarfiles = self.shunt_to_list("^#\s+Begin\s+tarfiles",
 		"^#\s+End\s+tarfiles")
@@ -994,5 +993,5 @@
 			"Bad tcl parse? %s" % line)
 
-	self.genviz(self.tmpdir + "/vtopo.xml", self.tmpdir + "/viz.xml")
+	self.genviz(tmpdir + "/vtopo.xml", tmpdir + "/viz.xml")
 	if not startem: return True
 
@@ -1000,13 +999,13 @@
 	try:
 	    for t in parse_tarfiles.list:
-		if not os.path.exists("%s/tarfiles" % self.tmpdir):
-		    os.mkdir("%s/tarfiles" % self.tmpdir)
+		if not os.path.exists("%s/tarfiles" % tmpdir):
+		    os.mkdir("%s/tarfiles" % tmpdir)
 		self.copy_file(t, "%s/tarfiles/%s" % \
-			(self.tmpdir, os.path.basename(t)))
+			(tmpdir, os.path.basename(t)))
 	    for r in parse_rpms.list:
-		if not os.path.exists("%s/rpms" % self.tmpdir):
-		    os.mkdir("%s/rpms" % self.tmpdir)
+		if not os.path.exists("%s/rpms" % tmpdir):
+		    os.mkdir("%s/rpms" % tmpdir)
 		self.copy_file(r, "%s/rpms/%s" % \
-			(self.tmpdir, os.path.basename(r)))
+			(tmpdir, os.path.basename(r)))
 	except IOError, e:
 	    raise service_error(service_error.internal, 
@@ -1016,5 +1015,5 @@
 	for tb in allocated.iterkeys():
 	    if tb != master:
-		if self.start_segment(tb, eid, tbparams, 0):
+		if self.start_segment(tb, eid, tbparams, tmpdir, 0):
 		    started[tb] = True
 		else:
@@ -1022,5 +1021,5 @@
 
 	if len(started) == len(allocated)-1:
-	    if self.start_segment(master, eid, tbparams):
+	    if self.start_segment(master, eid, tbparams, tmpdir):
 		started[master] = True
 	
