Best approach would be to define a set in your Controller Class and add the DPIDs of all switches there. So every time you have an event in the _handle_ConnectionUp you can get the DPID of the switch and add it accordingly.
In your main controller class init function
self.switches = set()
and the _handle_ConnectionUp function
def _handle_ConnectionUp(self, event):
"""
Fired up openflow connection with the switch
save the switch dpid
Args:
event: openflow ConnectionUp event
Returns: Nada
"""
self.switches.add(pox.lib.util.dpid_to_str(event.dpid))
Accordingly you should catch the event of Connection Down to remove the switch if needed. To get a list of all openflow events mixins currently available in the Dart version of the POX controller go to https://github.com/noxrepo/pox/blob/dart/pox/openflow/init.py line 336 at event mixins
_eventMixin_events = set([
ConnectionUp,
ConnectionDown,
FeaturesReceived,
PortStatus,
FlowRemoved,
PacketIn,
BarrierIn,
ErrorIn,
RawStatsReply,
SwitchDescReceived,
FlowStatsReceived,
AggregateFlowStatsReceived,
TableStatsReceived,
PortStatsReceived,
QueueStatsReceived,
FlowRemoved,
])
For further assistance you can check the code of a fully functional SDN controller with Dart POX I have written for the Python Meetup in Thessaloniki Greece and can be found at https://github.com/tsartsaris/pythess-SDN