def _handler_switch_enter(self, ev): """ Handler for event.EventSwitchEnter Add a node to the topology. """ switch = Switch(ev.switch) # Check switch capabilities self.switches[ev.switch.dp.id] = switch # HARDCODED for p in switch.switch.ports: if self._check_if_ap_port(p): ap_conf = self._get_ap_conf(switch, p) switch.is_ap = True switch.ap_conf = ap_conf self.accesspoints[ev.switch.dp.id] = switch elif self._check_if_gw_port(p): gw_conf = self._get_gw_conf(switch, p) switch.is_gw = True switch.gw_conf = gw_conf self.gateways[ev.switch.dp.id] = switch self._initialise_switch_of_tables(switch) ev_tu = EventSwitchEnter(switch) self.send_event_to_observers(ev_tu) ev_tu = EventTopologyUpdate(self.switches) self.send_event_to_observers(ev_tu) self.logger.info("Switch <" + str(hex(switch.switch.dp.id)) + "> connected")