'The discovery module simply sends out LLDP packets, and triggers
LinkEvents for discovered switches. It\'s our job to take these
LinkEvents and update pox.topology.'

def _handle_openflow_discovery_LinkEvent(self, event):

    link = event.link
    sw1 = self.topology.getEntityByID(link.dpid1)
    sw2 = self.topology.getEntityByID(link.dpid2)
    if ((sw1 is None) or (sw2 is None)):
        return
    if ((link.port1 not in sw1.ports) or (link.port2 not in sw2.ports)):
        return
    if event.added:
        sw1.ports[link.port1].addEntity(sw2, single=True)
        sw2.ports[link.port2].addEntity(sw1, single=True)
    elif event.removed:
        sw1.ports[link.port1].entities.discard(sw2)
        sw2.ports[link.port2].entities.discard(sw1)
