Index: fedd/federation/experiment_control.py
===================================================================
--- fedd/federation/experiment_control.py	(revision 641bb66972e4959303f0889c21b37842c015b882)
+++ fedd/federation/experiment_control.py	(revision e02cd14c76fe2382e62f5e57ea53b1c682bf200c)
@@ -726,5 +726,5 @@
 
     def get_access(self, tb, nodes, tbparam, master, export_project,
-            access_user):
+            access_user, services):
         """
         Get access to testbed through fedd and set the parameters for that tb
@@ -769,4 +769,10 @@
                 # the type
                 req['exportProject'] = export_project
+		req['service'] = [
+			{ 'name': 'userconfig', 'visibility': 'export'},
+			{ 'name': 'SMB', 'visibility': 'export'},
+			{ 'name': 'seer', 'visibility': 'export'},
+			{ 'name': 'tmcd', 'visibility': 'export'},
+		    ]
 
             # node resources if any
@@ -820,4 +826,6 @@
 		"uri": uri,
 		}
+	if 'service' in r: 
+	    services.extend(r['service'])
 
 	# Add attributes to parameter space.  We don't allow attributes to
@@ -890,5 +898,6 @@
 	    self.response = None
 
-	def __call__(self, uri, aid, topo, master, attrs=None):
+	def __call__(self, uri, aid, topo, master, attrs=None, connInfo=None,
+		services=None):
 	    req = {
 		    'allocID': { 'fedid' : aid }, 
@@ -898,4 +907,15 @@
 		    'master': master,
 		}
+
+	    if connInfo:
+		req['connection'] = connInfo
+	    # Add services to request.  The master exports, everyone else
+	    # imports.
+	    if services:
+		svcs = [ x.copy() for x in services]
+		for s in svcs:
+		    if master: s['visibility'] = 'export'
+		    else: s['visibility'] = 'import'
+		req['service'] = svcs
 	    if attrs:
 		req['fedAttr'] = attrs
@@ -950,5 +970,5 @@
     def allocate_resources(self, allocated, master, eid, expid, 
             tbparams, topo, tmpdir, alloc_log=None, log_collector=None, 
-	    attrs=None):
+	    attrs=None, connInfo={}, services=[]):
 	def get_vlan(r):
 	    if r.has_key('StartSegmentResponseBody'):
@@ -1001,5 +1021,6 @@
 	    t = self.pooled_thread(
 		    target=ss,
-		    args =(uri, aid, topo[tb], False, attrs),
+		    args =(uri, aid, topo[tb], False, attrs, connInfo[tb],
+			services),
 		    name=tb, pdata=thread_pool, trace_file=self.trace_file)
 	    threads.append(t)
@@ -1054,5 +1075,7 @@
 			    caller=self.call_StartSegment,
 			    log_collector=log_collector), 
-			args=(uri, aid, topo[tb], False, attrs), name=tb,
+			args=(uri, aid, topo[tb], False, attrs, connInfo[tb],
+			    services),
+			name=tb,
 			pdata=thread_pool, trace_file=self.trace_file)
 		threads.append(t)
@@ -1090,5 +1113,6 @@
 			caller=self.call_StartSegment,
 			log_collector=log_collector),
-		    args =(uri, aid, topo[master], True, attrs),
+		    args =(uri, aid, topo[master], True, attrs, 
+			connInfo[master], services),
 		    name=master, pdata=thread_pool, trace_file=self.trace_file)
 	    threads.append(t)
@@ -1294,5 +1318,5 @@
 
     def get_access_to_testbeds(self, testbeds, access_user, 
-	    export_project, master, allocated, tbparams):
+	    export_project, master, allocated, tbparams, services):
 	"""
 	Request access to the various testbeds required for this instantiation
@@ -1303,16 +1327,15 @@
 	for tb in testbeds:
 	    self.get_access(tb, None, tbparams, master,
-		    export_project, access_user)
+		    export_project, access_user, services)
 	    allocated[tb] = 1
 
     def split_topology(self, top, topo, testbeds, eid, master, tbparams):
 	"""
-	Create the sub-topologies that are needed for experimetn instantiation.
-	Along the way attach startup commands to the computers in the
-	subtopologies.
+	Create the sub-topologies that are needed for experiment instantiation.
 	"""
 	for tb in testbeds:
 	    topo[tb] = top.clone()
 	    to_delete = [ ]
+	    # XXX: copy in for loop to simplify
 	    for e in topo[tb].elements:
 		etb = e.get_attribute('testbed')
@@ -1332,30 +1355,23 @@
 	    for e in [ e for e in topo[tb].elements \
 		    if isinstance(e,topdl.Computer)]:
-		if tb == master:
-		    cmd = 'sudo -H /usr/local/federation/bin/make_hosts /proj/%s/exp/%s/tmp/hosts >& /tmp/federate' % (tbparams[tb].get('project', 'project'), eid)
-		else:
-		    cmd = "sudo -H /bin/sh /usr/local/federation/bin/federate.sh >& /tmp/federate"
-		scmd = e.get_attribute('startup')
-		if scmd:
-		    cmd = "%s \\$USER '%s'" % (cmd, scmd)
-
-		e.set_attribute('startup', cmd)
 		if self.fedkit: self.add_kit(e, self.fedkit)
 
     def new_portal_node(self, st, dt, tbparams, master, eid, myname, desthost,
 	    portal_type, iface_desc=()):
+	"""
+	Return a new internet portal node and a dict with the connectionInfo to
+	be attached.
+	"""
 	sproject = tbparams[st].get('project', 'project')
-	dproject = tbparams[dt].get('project', 'project')
+	sdomain = tbparams[st].get('domain', ".example.com")
+	mdomain = tbparams[master].get('domain', '.example.com')
 	mproject = tbparams[master].get('project', 'project')
-	sdomain = tbparams[st].get('domain', ".example.com")
-	ddomain = tbparams[dt].get('domain', ".example.com")
-	mdomain = tbparams[master].get('domain', '.example.com')
 	muser = tbparams[master].get('user', 'root')
 	smbshare = tbparams[master].get('smbshare', 'USERS')
-	aid = tbparams[dt]['allocID']['fedid']
+
 	if st == master or dt == master:
 	    active = ("%s" % (st == master))
 	else:
-	    active = ("%s" %(st > dt))
+	    active = ("%s" % (st > dt))
 
 	ifaces = [ ]
@@ -1371,5 +1387,20 @@
 		    )
 	    ifaces.append(inf)
-	return topdl.Computer(
+	info = {
+		"type" : "ssh", 
+		"portal": myname,
+		'peer': "%s.%s.%s%s" %  (desthost.lower(), eid.lower(),
+			    sproject.lower(), sdomain.lower()),
+		'fedAttr': [ 
+			{ 'attribute': 'masterdomain', 'value': mdomain},
+			{ 'attribute': 'masterexperiment', 'value': 
+			    "%s/%s" % (mproject, eid)},
+			{ 'attribute': 'active', 'value': "%s" % active},
+			# Move to SMB service description
+			{ 'attribute': 'masteruser', 'value': muser},
+			{ 'attribute': 'smbshare', 'value': smbshare},
+		    ],
+		}
+	return (topdl.Computer(
 		name=myname,
 		attribute=[ 
@@ -1377,22 +1408,9 @@
 			for n, v in (\
 			    ('portal', 'true'),
-			    ('domain', sdomain),
-			    ('masterdomain', mdomain),
-			    ('masterexperiment', "%s/%s" % \
-				    (mproject, eid)),
-			    ('masteruser', muser),
-			    ('smbshare', smbshare),
-			    ('experiment', "%s/%s" % \
-				    (sproject, eid)),
-			    ('peer', "%s" % desthost),
-			    ('peer_segment', "%s" % aid),
-			    ('scriptdir', 
-				"/usr/local/federation/bin"),
-			    ('active', "%s" % active),
 			    ('portal_type', portal_type), 
 			)
 		    ],
 		interface=ifaces,
-		)
+		), info)
 
     def new_portal_substrate(self, st, dt, eid, tbparams):
@@ -1496,5 +1514,5 @@
 
     def insert_internet_portals(self, sub, topo, tbs, tbparams, master, eid,
-	    segment_substrate, portals):
+	    segment_substrate, portals, connInfo):
 	# More than one testbed is on this substrate.  Insert
 	# some portals into the subtopologies.  st == source testbed,
@@ -1505,4 +1523,6 @@
 	    if not portals.has_key(st): 
 		portals[st] = { }
+	    if not connInfo.has_key(st):
+		connInfo[st] = [ ]
 	    for dt in [ t for t in tbs.keys() if t != st]:
 		sproject = tbparams[st].get('project', 'project')
@@ -1531,5 +1551,5 @@
 		if portals[st].has_key(dt):
 		    # There's a portal set up to go to this destination.
-		    # See if there's room to multiples this connection on
+		    # See if there's room to multiplex this connection on
 		    # it.  If so, add an interface to the portal; if not,
 		    # set up to add a portal below.
@@ -1573,5 +1593,5 @@
 				(('ip4_address', tbs[dt]),))
 			)
-		    portal =  self.new_portal_node(st, dt, tbparams, 
+		    portal, info  =  self.new_portal_node(st, dt, tbparams, 
 			    master, eid, myname, desthost, portal_type,
 			    infs)
@@ -1583,6 +1603,7 @@
 		    topo[st].elements.append(portal)
 		    portals[st][dt].append(portal)
-
-    def add_control_portal(self, st, dt, master, eid, topo, tbparams):
+		    connInfo[st].append(info)
+
+    def add_control_portal(self, st, dt, master, eid, topo, tbparams, connInfo):
 	# Add to the master testbed
 	tsubstrate, segment_element = \
@@ -1591,5 +1612,5 @@
 	desthost = "%stunnel" % st
 
-	portal = self.new_portal_node(st, dt, tbparams, master,
+	portal, info = self.new_portal_node(st, dt, tbparams, master,
 		eid, myname, desthost, "control", 
 		((tsubstrate.name,(('portal','true'),)),))
@@ -1602,4 +1623,7 @@
 	topo[st].elements.append(segment_element)
 	topo[st].elements.append(portal)
+	if not connInfo.has_key(st):
+	    connInfo[st] = [ ]
+	connInfo[st].append(info)
 
     def new_dragon_portal(self, st, dt, master, eid, myip, dip, idx, 
@@ -1623,5 +1647,6 @@
 	return portal
 
-    def add_portals(self, top, topo, eid, master, tbparams, ip_allocator):
+    def add_portals(self, top, topo, eid, master, tbparams, ip_allocator, 
+	    connInfo):
 	"""
 	For each substrate in the main topology, find those that
@@ -1652,5 +1677,5 @@
 	    else:
 		self.insert_internet_portals(s, topo, tbs, tbparams, master,
-			eid, segment_substrate, portals)
+			eid, segment_substrate, portals, connInfo)
 
 	# Make sure that all the slaves have a control portal back to the
@@ -1738,7 +1763,7 @@
 		else:
 		    self.add_control_portal(master, tb, master, eid, topo, 
-			    tbparams)
+			    tbparams, connInfo)
 		    self.add_control_portal(tb, master, master, eid, topo, 
-			    tbparams)
+			    tbparams, connInfo)
 
 	# Connect the portal nodes into the topologies and clear out
@@ -2030,6 +2055,8 @@
             allocated = { }         # Testbeds we can access
 	    topo ={ }		    # Sub topologies
+	    connInfo = { }	    # Connection information
+	    services = [ ]
 	    self.get_access_to_testbeds(testbeds, access_user, 
-		    export_project, master, allocated, tbparams)
+		    export_project, master, allocated, tbparams, services)
 	    self.split_topology(top, topo, testbeds, eid, master, tbparams)
 
@@ -2066,5 +2093,6 @@
 		    self.auth.set_attribute(asignee, "%s/%s" % (configpath, f))
 
-	    self.add_portals(top, topo, eid, master, tbparams, ip_allocator)
+	    self.add_portals(top, topo, eid, master, tbparams, ip_allocator,
+		    connInfo)
 	    # Now get access to the dynamic testbeds
 	    for k, t in topo.items():
@@ -2074,5 +2102,5 @@
 		if tb: 
 		    self.get_access(tb, None, user, tbparams, master, 
-			    export_project, access_user)
+			    export_project, access_user, services)
 		    tbparams[k] = tbparams[tb]
 		    del tbparams[tb]
@@ -2168,5 +2196,6 @@
         t  = Thread(target=self.allocate_resources,
                 args=(allocated, master, eid, expid, tbparams, 
-                    topo, tmpdir, alloc_log, alloc_collector, attrs),
+                    topo, tmpdir, alloc_log, alloc_collector, attrs, connInfo,
+		    services),
                 name=eid)
         t.start()
