Index: fedd/federation/access.py
===================================================================
--- fedd/federation/access.py	(revision 6c57fe9deaa34079254d04e9785091c1e9717115)
+++ fedd/federation/access.py	(revision f9ef40b3f313c74ac1d4f6ec50841ede5fb89cda)
@@ -1136,4 +1136,57 @@
             return rv
 
+    def generate_portal_configs(self, topo, pubkey_base, secretkey_base, 
+	    tmpdir):
+	for p in [ e for e in topo.elements \
+		if isinstance(e, topdl.Computer) and e.get_attribute('portal')]:
+	    myname = e.name[0]
+	    peer = e.get_attribute('peer')
+	    lexp = e.get_attribute('experiment')
+	    lproj, leid = lexp.split('/', 1)
+	    ldomain = e.get_attribute('domain')
+	    scriptdir = e.get_attribute('scriptdir')
+	    active = e.get_attribute('active')
+	    type = e.get_attribute('type')
+	    segid = fedid(hexstr=e.get_attribute('peer_segment'))
+	    for e in topo.elements:
+		if isinstance(e, topdl.Segment) and e.id.fedid == segid:
+		    seg = e
+		    break
+	    else:
+		raise service_error(service_error.req, 
+			"Can't find segment for portal %s" % myname)
+
+	    rexp = seg.get_attribute('experiment')
+	    rproj, reid = rexp.split("/", 1)
+	    rdomain = seg.get_attribute('domain')
+	    cfn = "%s/%s.%s.%s%s.gw.conf" % \
+		    (tmpdir, myname, leid, lproj, ldomain)
+	    try:
+		f = open(cfn, "w")
+		print >>f, "Active: %s" % active
+		print >>f, "BossName: boss"
+		print >>f, "FsName: fs"
+		print >>f, "EventServerName: event-server%s" % ldomain
+		print >>f, "RemoteEventServerName: event-server%s" % rdomain
+		print >>f, "SeerControl: control.%s.%s%s" % \
+			(leid.lower(), lproj.lower(), ldomain)
+		print >>f, "Type: %s" % type
+		print >>f, "RemoteExperiment: %s" % rexp
+		print >>f, "LocalExperiment: %s" % lexp
+		print >>f, "RemoteConfigFile: " + \
+			"/proj/%s/exp/%s/tmp/%s.%s.%s%s.gw.conf" \
+			% (rproj, reid, peer.lower(), reid.lower(),
+				rproj.lower(), rdomain)
+		print >>f, "Peer: %s.%s.%s%s" % \
+			(peer.lower(), reid.lower(), rproj.lower(), rdomain)
+		print >>f, "Pubkeys: /proj/%s/exp/%s/tmp/%s" % \
+			(lproj, leid, pubkey_base)
+		print >>f, "Privkey: /proj/%s/exp/%s/tmp/%s" % \
+			(lproj, leid, secretkey_base)
+		f.close()
+	    except IOError, e:
+		raise service_error(service_error.internal,
+			"Can't write protal config %s: %s" % (cfn, e))
+
     def StartSegment(self, req, fid):
 	def get_url(url, cf, tmpdir):
@@ -1161,4 +1214,5 @@
 
 	configs = set(('hosts', 'ssh_pubkey', 'ssh_secretkey'))
+	keys = set(('ssh_pubkey', 'ssh_secretkey'))
 
 
@@ -1200,4 +1254,10 @@
 	    if a['attribute'] in configs:
 		get_url(a['value'], certfile, tmpdir)
+	    if a['attribute'] == 'ssh_pubkey':
+		pubkey_base = a['attribute'].rpartition('/')[2]
+	    if a['attribute'] == 'ssh_secretkey':
+		secretkey_base = a['attribute'].rpartition('/')[2]
+
+	self.generate_portal_configs(topo, pubkey_base, secretkey_base, tmpdir)
 
 	return { 'allocID': req['allocID'] }
Index: fedd/federation/experiment_control.py
===================================================================
--- fedd/federation/experiment_control.py	(revision 6c57fe9deaa34079254d04e9785091c1e9717115)
+++ fedd/federation/experiment_control.py	(revision f9ef40b3f313c74ac1d4f6ec50841ede5fb89cda)
@@ -2161,4 +2161,5 @@
 		req['fedAttr'] = attrs
 
+	    print req
 	    r = self.caller(uri, req, self.cert_file, self.cert_pwd,
 		    self.trusted_certs)
@@ -2230,5 +2231,5 @@
 		    trusted_certs=self.trusted_certs,
 		    caller=self.call_StartSegment)
-	    if not starter(uri, aid, topo[master]):
+	    if not starter(uri, aid, topo[master], attrs):
                 failed.append(master)
 
@@ -2613,11 +2614,8 @@
 			sproject = tbparams[st].get('project', 'project')
 			dproject = tbparams[dt].get('project', 'project')
-			sdomain = ".%s.%s%s" % (eid, sproject,
-				tbparams[st].get('domain', ".example.com"))
-			ddomain = ".%s.%s%s" % (eid, dproject,
-				tbparams[dt].get('domain', ".example.com"))
-			mdomain = "%s.%s%s" % (eid, 
-				tbparams[master].get('project', 'project'),
-				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')
 			# XXX: active and type need to be unkludged
 			active = ("%s" % (st == master))
@@ -2626,5 +2624,11 @@
 			    # testbed in there.
 			    tsubstrate = \
-				    topdl.Substrate(name='%s-%s' % (st, dt))
+				    topdl.Substrate(name='%s-%s' % (st, dt),
+					    attribute= [
+						topdl.Attribute(
+						    attribute='portal',
+						    value='true')
+						]
+					    )
 			    segment_element = topdl.Segment(
 				    id= tbparams[dt]['allocID'],
@@ -2652,9 +2656,13 @@
 					for n, v in (\
 					    ('portal', 'true'),
+					    ('domain', sdomain),
 					    ('masterdomain', mdomain),
+					    ('masterexperiment', "%s/%s" % \
+						    (mproject, eid)),
 					    ('experiment', "%s/%s" % \
 						    (sproject, eid)),
-					    ('peer', "%s.%s" % \
-						    (desthost, ddomain)),
+					    ('peer', "%s" % desthost),
+					    ('peer_segment', "%s" % \
+						    tbparams[dt]['allocID']['fedid']),
 					    ('scriptdir', 
 						"/usr/local/federation/bin"),
@@ -2674,5 +2682,9 @@
 				    topdl.Interface(
 					substrate=\
-					    segment_substrate[st][dt].name
+					    segment_substrate[st][dt].name,
+					attribute=[
+					    topdl.Attribute(attribute='portal',
+						value='true')
+					    ]
 					),
 				    ],
