Index: fedd/federation/emulab_access.py
===================================================================
--- fedd/federation/emulab_access.py	(revision 0f0652800a69ae6a0ff602bafad72a74f2d316a0)
+++ fedd/federation/emulab_access.py	(revision 617592b008e12b7ccdf4592cac90f3280f0f46e9)
@@ -917,8 +917,12 @@
 
 	    rv = None
+	    print info
 	    for i in info:
-		if i.get('portal', "") == key:
+		if key == i.get('portal', "") or \
+			key in [e.get('element', "") \
+			for e in i.get('member', [])]:
 		    rv = i.copy()
 		    break
+
 	    else:
 		return rv
@@ -1049,32 +1053,78 @@
 
 
-    def generate_ns2(self, topo, expfn, softdir, master):
-	def dragon_commands(e):
-	    s = ""
-	    if isinstance(e, topdl.Computer):
-		for i in e.interface:
-		    vlan = i.get_attribute('dragon_vlan')
-		    if vlan:
-			type = i.get_attribute('dragon_type')
-			ip = i.get_attribute('ip4_address')
-			if type == 'link':
-			    s = ("tb-allow-external $%s dragonportal " + \
-				    "ip %s vlan %s\n") % \
-				    (topdl.to_tcl_name(e.name[0]), ip, vlan)
-			elif type == 'lan':
-			    s = ("tb-allow-external $%s dragonportal " + \
-				    "ip %s vlan %s usurp %s\n") % \
-				    (topdl.to_tcl_name(e.name[0]), ip, vlan,
-					i.substrate[0])
-			else:
-			    raise service_error(service_error_internal,
-				    "Unknown DRAGON type %s" % type)
-	    return s
-
-	def not_dragon(e):
-	    return all([not i.get_attribute('dragon_vlan') \
-		    for i in e.interface])
+    def generate_ns2(self, topo, expfn, softdir, master, connInfo):
+	class dragon_commands:
+	    """
+	    Functor to spit out approrpiate dragon commands for nodes listed in
+	    the connectivity description.  The constructor makes a dict mapping
+	    dragon nodes to their parameters and the __call__ checks each
+	    element in turn for membership.
+	    """
+	    def __init__(self, map):
+		self.node_info = map
+
+	    def __call__(self, e):
+		s = ""
+		if isinstance(e, topdl.Computer):
+		    if self.node_info.has_key(e.name[0]):
+			i = self.node_info[e.name[0]]
+			for ifname, vlan, type in i:
+			    print "Checking %s" % e.name[0]
+			    for i in e.interface:
+				print "interface s %s %s" % (i.name, ifname)
+				if i.name == ifname:
+				    addr = i.get_attribute('ip4_address')
+				    subs = i.substrate[0]
+				    break
+			    else:
+				raise service_error(service_error.internal,
+					"No interface %s on element %s" % \
+						(ifname, e.name[0]))
+			    if type =='link':
+				s = ("tb-allow-external $%s dragonportal " + \
+					"ip %s vlan %s\n") % \
+					(e.name[0], addr, vlan)
+			    elif type =='lan':
+				s = ("tb-allow-external $%s dragonportal " + \
+					"ip %s vlan %s usurp %s\n") % \
+					(e.name[0], addr, vlan, subs)
+			    else:
+				raise service_error(service_error_internal,
+					"Unknown DRAGON type %s" % type)
+		return s
+
+	class not_dragon:
+	    def __init__(self, map):
+		self.nodes = set(map.keys())
+
+	    def __call__(self, e):
+		return e.name[0] not in self.nodes
 
 	t = topo.clone()
+
+	dragon_map = { }
+	for i in [ i for i in connInfo if i['type'] == 'transit']:
+	    for a in i.get('fedAttr', []):
+		if a['attribute'] == 'vlan_id':
+		    vlan = a['value']
+		    break
+	    else:
+		raise service_error(service_error.internal, 
+			"No vlan tag")
+	    members = i.get('member', [])
+	    if len(members) > 1: type = 'lan'
+	    else: type = 'link'
+
+	    try:
+		for m in members:
+		    if dragon_map.has_key(m['element']):
+			dragon_map[m['element']].append(( m['interface'], 
+			    vlan, type))
+		    else:
+			dragon_map[m['element']] = [( m['interface'], 
+			    vlan, type),]
+	    except KeyError:
+		raise service_error(service_error.req,
+			"Missing connectivity info")
 
 	# The startcmds for master and slave testbeds
@@ -1109,8 +1159,8 @@
 			e.set_attribute('startup', node_cmd)
 
+		dinf = [i[0] for i in dragon_map.get(e.name[0], []) ]
 		# Remove portal interfaces that do not connect to DRAGON
 		e.interface = [i for i in e.interface \
-			if not i.get_attribute('portal') or \
-			    i.get_attribute('dragon_vlan')]
+			if not i.get_attribute('portal') or i.name in dinf ]
 
 	t.substrates = [ s.clone() for s in t.substrates ]
@@ -1125,6 +1175,6 @@
 
 	if self.attrs.has_key('dragon'):
-	    add_filter = not_dragon
-	    filters.append(dragon_commands)
+	    add_filter = not_dragon(dragon_map)
+	    filters.append(dragon_commands(dragon_map))
 	else:
 	    add_filter = None
@@ -1312,5 +1362,5 @@
 		    services)
 	    self.generate_ns2(topo, expfile, 
-		    "/proj/%s/software/%s/" % (proj, ename), master)
+		    "/proj/%s/software/%s/" % (proj, ename), master, connInfo)
 
 	    starter = self.start_segment(keyfile=self.ssh_privkey_file, 
Index: fedd/federation/experiment_control.py
===================================================================
--- fedd/federation/experiment_control.py	(revision 0f0652800a69ae6a0ff602bafad72a74f2d316a0)
+++ fedd/federation/experiment_control.py	(revision 617592b008e12b7ccdf4592cac90f3280f0f46e9)
@@ -831,5 +831,5 @@
 	# Add attributes to parameter space.  We don't allow attributes to
 	# overlay any parameters already installed.
-	for a in r['fedAttr']:
+	for a in r.get('fedAttr', []):
 	    try:
 		if a['attribute'] and \
@@ -923,5 +923,4 @@
 	    try:
 		self.log.debug("Calling StartSegment at %s " % uri)
-		print req
 		r = self.caller(uri, req, self.cert_file, self.cert_pwd,
 			self.trusted_certs)
@@ -1039,10 +1038,10 @@
 		vlan = get_vlan(ss.response)
 		if vlan is not None:
-		    for k, t in topo.items():
-			for e in t.elements:
-			    for i in e.interface:
-				vl = i.get_attribute('dragon_vlan')
-				if vl is not None and vl == to_repl:
-				    i.set_attribute('dragon_vlan', vlan)
+		    for v in connInfo.values():
+			for i in v:
+			    for a in i.get('fedAttr', []):
+				if a.get('attribute', "") == 'vlan_id' and \
+					a.get('value', "") == to_repl:
+				    a['value'] = vlan
 	    else:
 		break
@@ -1355,23 +1354,21 @@
 		    )
 	    ifaces.append(inf)
-	info = {
-		"type" : conn_type, 
-		"portal": myname,
-		'peer': desthost,
-		'fedAttr': [ 
-			{ 'attribute': 'masterdomain', 'value': mdomain},
-			{ 'attribute': 'masterexperiment', 'value': 
-			    "%s/%s" % (mproject, eid)},
-			{ 'attribute': 'active', 'value': active},
-			# Move to SMB service description
-			{ 'attribute': 'masteruser', 'value': muser},
-			{ 'attribute': 'smbshare', 'value': smbshare},
-		    ],
-		}
-
-	if conn_type == 'transit':
-	    info['member'] = [ { 'element': myname, 'interface': 'inf000'} ]
-	if conn_attrs:
-	    info['fedAttr'].extend(con_attrs)
+	if conn_type == "ssh":
+	    info = {
+		    "type" : conn_type, 
+		    "portal": myname,
+		    'peer': desthost,
+		    'fedAttr': [ 
+			    { 'attribute': 'masterdomain', 'value': mdomain},
+			    { 'attribute': 'masterexperiment', 'value': 
+				"%s/%s" % (mproject, eid)},
+			    { 'attribute': 'active', 'value': active},
+			    # Move to SMB service description
+			    { 'attribute': 'masteruser', 'value': muser},
+			    { 'attribute': 'smbshare', 'value': smbshare},
+			],
+		    }
+	else:
+	    info = None
 
 	return (topdl.Computer(
@@ -1455,5 +1452,5 @@
 
     def create_dragon_substrate(self, sub, topo, tbs, tbparams, master, eid,
-	    connInfo):
+	    connInfo, peer={ }):
 	"""
 	Add attribiutes to the various elements indicating that they are to be
@@ -1467,4 +1464,6 @@
 	    else: return None
 
+	mdomain = tbparams[master].get('domain', '.example.com')
+	mproject = tbparams[master].get('project', 'project')
 	# dn is the number of previously created dragon nets.  This routine
 	# creates a net numbered by dn
@@ -1473,7 +1472,10 @@
 	# the global topology
 	count = { }
+	node = { }
 	for e in [ i.element for i in sub.interfaces ]:
 	    tb = e.get_attribute('testbed')
 	    count[tb] = count.get(tb, 0) + 1
+	    node[tb] = i.get_attribute('ip4_address')
+
 
 	# Set the attributes in the copies that will allow setup of dragon
@@ -1484,4 +1486,9 @@
 		if not connInfo.has_key(tb):
 		    connInfo[tb] = [ ]
+
+		# This may need another look, but only a service gateway will
+		# look at the active parameter, and these are only inserted to
+		# connect to the master.
+		active = "%s" % ( tb == 'master')
 		info = {
 			'type': 'transit',
@@ -1489,10 +1496,17 @@
 			    'element': i.element.name[0], 
 			    'interface': i.name 
-			    } for i in s.interfaces ],
-			'fedAttr': [ { 
-			    'attribute': 'vlan_id',
-			    'value': 'unassigned%d' % dn
-			    } ]
+			    } for i in s.interfaces \
+				    if isinstance(i.element, topdl.Computer) ],
+			'fedAttr': [ 
+			    { 'attribute': 'vlan_id', 
+				'value': 'unassigned%d' % dn },
+			    { 'attribute': 'masterdomain', 'value': mdomain},
+			    { 'attribute': 'masterexperiment', 'value': 
+				"%s/%s" % (mproject, eid)},
+			    { 'attribute': 'active', 'value': active},
+			    ],
 			}
+		if peer.has_key(tb):
+		    info['peer'] = peer[tb]
 		connInfo[tb].append(info)
 	    else:
@@ -1631,8 +1645,5 @@
 		    ('portal','true'),
 		    ('ip4_address', "%s" % ip_addr(myip)),)),),
-		conn_type="transit",
-		conn_attrs = [ {
-		    'attribute': 'vlan_id', 'value': 'unassigned%d' % idx
-		    }])
+		conn_type="transit")
 	if self.fedkit:
 	    self.add_kit(portal, self.fedkit)
@@ -1640,5 +1651,5 @@
 	    self.add_kit(portal, self.gatewaykit)
 
-	return portal, info
+	return portal
 
     def add_portals(self, top, topo, eid, master, tbparams, ip_allocator, 
@@ -1721,13 +1732,9 @@
 				],
 			    )
-		    portal, info = self.new_dragon_portal(tb, master,
+		    portal = self.new_dragon_portal(tb, master,
 			    master, eid, dip, mip, idx, csub, tbparams)
 		    topo[tb].substrates.append(csub)
 		    topo[tb].elements.append(portal)
 		    topo[tb].elements.append(seg)
-		    if not connInfo.has_key(tb):
-			connInfo[tb] = [info]
-		    else:
-			connInfo[tb].append(info)
 
 		    mcsub = csub.clone()
@@ -1752,16 +1759,15 @@
 				],
 			    )
-		    portal, info = self.new_dragon_portal(master, tb, master,
+		    portal = self.new_dragon_portal(master, tb, master,
 			    eid, mip, dip, idx, mcsub, tbparams)
 		    topo[master].substrates.append(mcsub)
 		    topo[master].elements.append(portal)
 		    topo[master].elements.append(seg)
-		    if not connInfo.has_key(master):
-			connInfo[master] = [info]
-		    else:
-			connInfo[master].append(info)
+		    for t in (master, tb):
+			topo[t].incorporate_elements()
 
 		    self.create_dragon_substrate(csub, topo, 
-			    {tb: 1, master:1}, tbparams, master, eid)
+			    {tb: 1, master:1}, tbparams, master, eid, connInfo,
+			    {tb: ip_addr(mip), master: ip_addr(dip)})
 		else:
 		    self.add_control_portal(master, tb, master, eid, topo, 
@@ -2104,5 +2110,5 @@
 		tb = t.get_attribute('testbed')
 		if tb: 
-		    self.get_access(tb, None, user, tbparams, master, 
+		    self.get_access(tb, None, tbparams, master, 
 			    export_project, access_user, services)
 		    tbparams[k] = tbparams[tb]
@@ -2196,4 +2202,10 @@
 	    ]
 
+	# transit and disconnected testbeds may not have a connInfo entry.
+	# Fill in the blanks.
+	for t in allocated.keys():
+	    if not connInfo.has_key(t):
+		connInfo[t] = { }
+
         # Start a thread to do the resource allocation
         t  = Thread(target=self.allocate_resources,
