def start_topology(self, tid, client_ip, user): """Handles starting up the specified topology id. Returns a 2-tuple. The first element is None and the second is a string if an error occurs; otherwise the first element is the topology.""" try: topo = Topology(tid, self.raw_socket, client_ip, user) topo.interactors = [] # list of TI connections to this topo except TopologyCreationException as e: return (None, str(e)) except db.Topology.DoesNotExist: return (None, 'topology %d does not exist' % tid) except db.IPAssignment.DoesNotExist: return (None, 'topology %d is missing an IP assignment' % tid) except db.IPBlockAllocation.DoesNotExist: return (None, 'topology %d is not allocated any IPs' % tid) except: msg = 'topology instantiation unexpectedly failed' log_exception(logging.ERROR, msg) return (None, msg) if topo.has_gateway(): self.resolver.register_topology(topo) with self.topologies_lock: self.topologies[tid] = topo self.topologies_changed = True return (topo, None)