Index: fedd/federation/emulab_access.py
===================================================================
--- fedd/federation/emulab_access.py	(revision f771e2fb0197af667561fdefaf54abf04531475d)
+++ fedd/federation/emulab_access.py	(revision 8cf2b90e2251f7161f682631e113489faf064cc3)
@@ -463,4 +463,27 @@
 	return resp
 
+    def do_release_project(self, del_project, del_users, del_types):
+	"""
+	If a project and users has to be deleted, make the call.
+	"""
+	msg = { 'project': { }}
+	if del_project:
+	    msg['project']['name']= {'localname': del_project}
+	users = [ ]
+	for u in del_users.keys():
+	    users.append({ 'userID': { 'localname': u },\
+		'access' :  \
+			[ {'sshPubkey' : s } for s in del_users[u]]\
+	    })
+	if users: 
+	    msg['project']['user'] = users
+	if len(del_types) > 0:
+	    msg['resources'] = { 'node': \
+		    [ {'hardware': [ h ] } for h in del_types ]\
+		}
+	if self.allocate_project.release_project:
+	    msg = { 'ReleaseProjectRequestBody' : msg}
+	    self.allocate_project.release_project(msg)
+
     def ReleaseAccess(self, req, fid):
         # The dance to get into the request body
@@ -470,112 +493,77 @@
             raise service_error(service_error.req, "No request!?")
 
-        if req.has_key('destinationTestbed'):
-            dt = unpack_id(req['destinationTestbed'])
-        else:
-            dt = None
-
-        if dt == None or dt in self.testbed:
-            # Local request
-            try:
-                if req['allocID'].has_key('localname'):
-                    auth_attr = aid = req['allocID']['localname']
-                elif req['allocID'].has_key('fedid'):
-                    aid = unicode(req['allocID']['fedid'])
-                    auth_attr = req['allocID']['fedid']
-                else:
-                    raise service_error(service_error.req,
-                            "Only localnames and fedids are understood")
-            except KeyError:
-                raise service_error(service_error.req, "Badly formed request")
-
-            self.log.debug("[access] deallocation requested for %s", aid)
-            if not self.auth.check_attribute(fid, auth_attr):
-                self.log.debug("[access] deallocation denied for %s", aid)
-                raise service_error(service_error.access, "Access Denied")
-
-            # If we know this allocation, reduce the reference counts and
-            # remove the local allocations.  Otherwise report an error.  If
-            # there is an allocation to delete, del_users will be a dictonary
-            # of sets where the key is the user that owns the keys in the set.
-            # We use a set to avoid duplicates.  del_project is just the name
-            # of any dynamic project to delete.  We're somewhat lazy about
-            # deleting authorization attributes.  Having access to something
-            # that doesn't exist isn't harmful.
-            del_users = { }
-            del_project = None
-            del_types = set()
-
-            if self.allocation.has_key(aid):
-                self.log.debug("Found allocation for %s" %aid)
-                self.state_lock.acquire()
-                for k in self.allocation[aid]['keys']:
-                    kk = "%s:%s" % k
-                    self.keys[kk] -= 1
-                    if self.keys[kk] == 0:
-                        if not del_users.has_key(k[0]):
-                            del_users[k[0]] = set()
-                        del_users[k[0]].add(k[1])
-                        del self.keys[kk]
-
-                if self.allocation[aid].has_key('project'):
-                    pname = self.allocation[aid]['project']
-                    self.projects[pname] -= 1
-                    if self.projects[pname] == 0:
-                        del_project = pname
-                        del self.projects[pname]
-
-                if self.allocation[aid].has_key('types'):
-                    for t in self.allocation[aid]['types']:
-                        self.types[t] -= 1
-                        if self.types[t] == 0:
-                            if not del_project: del_project = t[0]
-                            del_types.add(t[1])
-                            del self.types[t]
-
-                del self.allocation[aid]
-                self.write_state()
-                self.state_lock.release()
-                # If we actually have resources to deallocate, prepare the call.
-                if del_project or del_users:
-                    msg = { 'project': { }}
-                    if del_project:
-                        msg['project']['name']= {'localname': del_project}
-                    users = [ ]
-                    for u in del_users.keys():
-                        users.append({ 'userID': { 'localname': u },\
-                            'access' :  \
-                                    [ {'sshPubkey' : s } for s in del_users[u]]\
-                        })
-                    if users: 
-                        msg['project']['user'] = users
-                    if len(del_types) > 0:
-                        msg['resources'] = { 'node': \
-                                [ {'hardware': [ h ] } for h in del_types ]\
-                            }
-                    if self.allocate_project.release_project:
-                        msg = { 'ReleaseProjectRequestBody' : msg}
-                        self.allocate_project.release_project(msg)
-		# And remove the access cert
-		cf = "%s/%s.pem" % (self.certdir, aid)
-		self.log.debug("Removing %s" % cf)
-		os.remove(cf)
-                return { 'allocID': req['allocID'] } 
-            else:
-                raise service_error(service_error.req, "No such allocation")
-
-        else:
-            if self.allow_proxy:
-                resp = self.proxy_ReleaseAccess.call_service(dt, req,
-                            self.cert_file, self.cert_pwd,
-                            self.trusted_certs)
-                if resp.has_key('ReleaseAccessResponseBody'):
-                    return resp['ReleaseAccessResponseBody']
-                else:
-                    return None
-            else:
-                raise service_error(service_error.access,
-                        "Access proxying denied")
-
-    def generate_ns2(self, topo, expfn, softdir, master, connInfo):
+	try:
+	    if req['allocID'].has_key('localname'):
+		auth_attr = aid = req['allocID']['localname']
+	    elif req['allocID'].has_key('fedid'):
+		aid = unicode(req['allocID']['fedid'])
+		auth_attr = req['allocID']['fedid']
+	    else:
+		raise service_error(service_error.req,
+			"Only localnames and fedids are understood")
+	except KeyError:
+	    raise service_error(service_error.req, "Badly formed request")
+
+	self.log.debug("[access] deallocation requested for %s", aid)
+	if not self.auth.check_attribute(fid, auth_attr):
+	    self.log.debug("[access] deallocation denied for %s", aid)
+	    raise service_error(service_error.access, "Access Denied")
+
+	# If we know this allocation, reduce the reference counts and
+	# remove the local allocations.  Otherwise report an error.  If
+	# there is an allocation to delete, del_users will be a dictonary
+	# of sets where the key is the user that owns the keys in the set.
+	# We use a set to avoid duplicates.  del_project is just the name
+	# of any dynamic project to delete.  We're somewhat lazy about
+	# deleting authorization attributes.  Having access to something
+	# that doesn't exist isn't harmful.
+	del_users = { }
+	del_project = None
+	del_types = set()
+
+	self.state_lock.acquire()
+	if aid in self.allocation:
+	    self.log.debug("Found allocation for %s" %aid)
+	    for k in self.allocation[aid]['keys']:
+		kk = "%s:%s" % k
+		self.keys[kk] -= 1
+		if self.keys[kk] == 0:
+		    if not del_users.has_key(k[0]):
+			del_users[k[0]] = set()
+		    del_users[k[0]].add(k[1])
+		    del self.keys[kk]
+
+	    if 'project' in self.allocation[aid]:
+		pname = self.allocation[aid]['project']
+		self.projects[pname] -= 1
+		if self.projects[pname] == 0:
+		    del_project = pname
+		    del self.projects[pname]
+
+	    if 'types' in self.allocation[aid]:
+		for t in self.allocation[aid]['types']:
+		    self.types[t] -= 1
+		    if self.types[t] == 0:
+			if not del_project: del_project = t[0]
+			del_types.add(t[1])
+			del self.types[t]
+
+	    del self.allocation[aid]
+	    self.write_state()
+	    self.state_lock.release()
+	    # If we actually have resources to deallocate, prepare the call.
+	    if del_project or del_users:
+		self.do_release_project(del_project, del_users, del_types)
+	    # And remove the access cert
+	    cf = "%s/%s.pem" % (self.certdir, aid)
+	    self.log.debug("Removing %s" % cf)
+	    os.remove(cf)
+	    return { 'allocID': req['allocID'] } 
+	else:
+	    self.state_lock.release()
+	    raise service_error(service_error.req, "No such allocation")
+
+
+    def generate_ns2(self, topo, expfn, softdir, connInfo):
 	class dragon_commands:
 	    """
@@ -634,6 +622,5 @@
 		    break
 	    else:
-		raise service_error(service_error.internal, 
-			"No vlan tag")
+		raise service_error(service_error.internal, "No vlan tag")
 	    members = i.get('member', [])
 	    if len(members) > 1: type = 'lan'
@@ -642,5 +629,5 @@
 	    try:
 		for m in members:
-		    if dragon_map.has_key(m['element']):
+		    if m['element'] in dragon_map:
 			dragon_map[m['element']].append(( m['interface'], 
 			    vlan, type))
@@ -782,12 +769,17 @@
 
     def configure_seer_services(self, services, topo, softdir):
-	local_seer = False
-	collect_seer = False
-	seer_master= False
+	"""
+	Make changes to the topology required for the seer requests being made.
+	Specifically, add any control or master nodes required and set up the
+	start commands on the nodes to interconnect them.
+	"""
+	local_seer = False	# True if we need to add a control node
+	collect_seer = False	# True if there is a seer-master node
+	seer_master= False	# True if we need to add the seer-master
 	for s in services:
 	    s_name = s.get('name', '')
 	    s_vis = s.get('visibility','')
 
-	    if s_name  == 'local_seer_control'  and s_vis == 'export':
+	    if s_name  == 'local_seer_control' and s_vis == 'export':
 		local_seer = True
 	    elif s_name == 'seer_master':
@@ -973,5 +965,5 @@
 		    services)
 	    self.generate_ns2(topo, expfile, 
-		    "/proj/%s/software/%s/" % (proj, ename), master, connInfo)
+		    "/proj/%s/software/%s/" % (proj, ename), connInfo)
 
 	    starter = self.start_segment(keyfile=self.ssh_privkey_file, 
