def __init__ (self, swid, info, address=('127.0.0.1', 8888)): port = address[1] self.listenTo(core.cs640_ofhandler) self.swid = swid self.srclients = [] self.listen_port = port self.intfname_to_port = {} self.port_to_intfname = {} self.server = create_vns_server(port, self._handle_recv_msg, self._handle_new_client, self._handle_client_disconnected) self.interfaces = [] for intf in info.keys(): ip, mask, mac, rate, port = info[intf] ip = pack_ip(ip) mask = pack_ip(mask) mac = pack_mac(mac) self.interfaces.append(VNSInterface(intf, mac, ip, mask)) # Mapping between of-port and intf-name self.intfname_to_port[intf] = port self.port_to_intfname[port] = intf log.info('created server') return
def __init__ (self, address=('127.0.0.1', 8888)): port = address[1] self.listenTo(core.VNetOFNetHandler) self.devsByConn = {} self.devsByName = {} self.server = create_vns_server(port, self.recv_msg, self.handle_new_client, self.handle_client_disconnect) log.info("VNet server listening on %s:%d" % (address[0],address[1])) return
def __init__(self, address=('127.0.0.1', 8888)): port = address[1] self.listenTo(core.VNetOFNetHandler) self.devsByConn = {} self.devsByName = {} self.server = create_vns_server(port, self.recv_msg, self.handle_new_client, self.handle_client_disconnect) log.info("VNet server listening on %s:%d" % (address[0], address[1])) return
def __init__(self): # Initialise the DB thread DBService.start() # close out any hanging stats records (shouldn't be any unless the # server was shutdown abnormally with no chance to cleanup) DBService.run_and_wait(lambda: db.UsageStats.objects.filter(active=True).update(active=False)) # free any hanging temporary topologies def __free_hanging_temp_topos(topos): for t in topos: AddressAllocation.free_topology(t.id) DBService.run_and_wait(lambda:__free_hanging_temp_topos(db.Topology.objects.filter(temporary=True)), priority=0) self.topologies = {} # maps active topology ID to its Topology object self.resolver = TopologyResolver() # maps MAC/IP addresses to a Topology self.clients = {} # maps active conn to the topology ID it is conn to self.server = create_vns_server(VNS_DEFAULT_PORT, self.handle_recv_msg, self.handle_new_client, self.handle_client_disconnected) self.ti_clients = {} # maps active TI conns to the topology ID it is conn to self.ti_server = create_ti_server(TI_DEFAULT_PORT, self.handle_recv_ti_msg, self.handle_new_client, self.handle_ti_client_disconnected) if BORDER_DEV_NAME: self.__start_raw_socket(BORDER_DEV_NAME) # run pcap in another thread (it will run forever) reactor.callInThread(self.__run_pcap, BORDER_DEV_NAME) else: self.raw_socket = None # lock used to prevent self.topologies from being *changed* by the main # twisted thread while the topology queue service thread is reading it self.topologies_lock = Lock() # communicates from the main twisted thread to the topology queue # service thread that the topologies dictionary has changed self.topologies_changed = False # The topology queue service thread will wait on this condition for a # a chosen/dequeued job to be finish (so it can pick the next one). self.service_condition = Condition() # Is set when a job is enqueued. Is cleared when the queues are empty. # The topology queue service thread will clear this event if it makes a # a pass over all the queues and they are empty. If it makes a pass # and this event is cleared, then it will wait on this event. self.job_available_event = Event() # run the topology queue service thread reactor.callInThread(self.__run_topology_queue_service_thread) self.periodic_callback()
def __init__(self, address=('127.0.0.1', 8888)): port = address[1] self.listenTo(core.csc458_ofhandler) self.srclients = [] self.listen_port = port self.intfname_to_port = {} self.port_to_intfname = {} self.server = create_vns_server(port, self._handle_recv_msg, self._handle_new_client, self._handle_client_disconnected) log.info('created server') return
def __init__ (self, address=('127.0.0.1', 8888)): port = address[1] self.listenTo(core.cs144_ofhandler) self.srclients = [] self.listen_port = port self.intfname_to_port = {} self.port_to_intfname = {} self.server = create_vns_server(port, self._handle_recv_msg, self._handle_new_client, self._handle_client_disconnected) log.info('created server') return
def __init__(self): # close out any hanging stats records (shouldn't be any unless the # server was shutdown abnormally with no chance to cleanup) db.UsageStats.objects.filter(active=True).update(active=False) # free any hanging temporary topologies for t in db.Topology.objects.filter(temporary=True): AddressAllocation.free_topology(t.id) self.topologies = {} # maps active topology ID to its Topology object self.resolver = TopologyResolver() # maps MAC/IP addresses to a Topology self.clients = {} # maps active conn to the topology ID it is conn to self.server = create_vns_server(VNS_DEFAULT_PORT, self.handle_recv_msg, self.handle_new_client, self.handle_client_disconnected) self.ti_clients = {} # maps active TI conns to the topology ID it is conn to self.ti_server = create_ti_server(TI_DEFAULT_PORT, self.handle_recv_ti_msg, self.handle_new_client, self.handle_ti_client_disconnected) if BORDER_DEV_NAME: self.__start_raw_socket(BORDER_DEV_NAME) # run pcap in another thread (it will run forever) reactor.callInThread(self.__run_pcap, BORDER_DEV_NAME) else: self.raw_socket = None # lock used to prevent self.topologies from being *changed* by the main # twisted thread while the topology queue service thread is reading it self.topologies_lock = Lock() # communicates from the main twisted thread to the topology queue # service thread that the topologies dictionary has changed self.topologies_changed = False # The topology queue service thread will wait on this condition for a # a chosen/dequeued job to be finish (so it can pick the next one). self.service_condition = Condition() # Is set when a job is enqueued. Is cleared when the queues are empty. # The topology queue service thread will clear this event if it makes a # a pass over all the queues and they are empty. If it makes a pass # and this event is cleared, then it will wait on this event. self.job_available_event = Event() # run the topology queue service thread reactor.callInThread(self.__run_topology_queue_service_thread) self.periodic_callback()
def __init__(self, swid, info, address=('127.0.0.1', 8888)): port = address[1] self.listenTo(core.cs640_ofhandler) self.swid = swid self.srclients = [] self.listen_port = port self.intfname_to_port = {} self.port_to_intfname = {} self.server = create_vns_server(port, self._handle_recv_msg, self._handle_new_client, self._handle_client_disconnected) self.interfaces = [] for intf in info.keys(): ip, mask, mac, rate, port = info[intf] ip = pack_ip(ip) mask = pack_ip(mask) mac = pack_mac(mac) self.interfaces.append(VNSInterface(intf, mac, ip, mask)) # Mapping between of-port and intf-name self.intfname_to_port[intf] = port self.port_to_intfname[port] = intf log.info('created server') return
def __init__(self, top_file): self.topo = Topology(top_file) self.server = create_vns_server(VNS_DEFAULT_PORT, self.handle_recv_msg)