def manageQuit(cls, action): """Quit the overlay nicely Tells everyone about this :param action: Quit action """ assert isinstance(action, a.Quit) cls.logger.debug("Managing Quit task") cls.logger.info("Exiting the overlay") try: Client.broadcast(Bye("", Identification.PROBE_ID), toMyself=False) except ProbeConnectionException as e: cls.logger.warning("Could not sent Bye message %s", e) # Other commands to close all connections, etc Client.allMessagesSent() ProbeStorage.clearAllProbes() cls.logger.info("All probes cleared, all connections closed.") ProbeStorage.addSelfProbe() cls.logger.info("Re-added the localhost probe, ready to proceed again")
def manageQuit(cls, action): """Quit the overlay nicely Tells everyone about this :param action: Quit action """ assert isinstance(action, a.Quit) cls.logger.debug("Managing Quit task") cls.logger.info("Exiting the overlay") try: Client.broadcast(Bye("", Identification.PROBE_ID), toMyself = False) except ProbeConnectionException as e: cls.logger.warning("Could not sent Bye message %s", e) # Other commands to close all connections, etc Client.allMessagesSent() ProbeStorage.clearAllProbes() cls.logger.info("All probes cleared, all connections closed.") ProbeStorage.addSelfProbe() cls.logger.info("Re-added the localhost probe, ready to proceed again")
def manageAddToOverlay(cls, action): assert isinstance(action, a.AddToOverlay) cls.logger.ddebug("Add probe to overlay") try: probeId = Retry.retry(times=Consts.GET_REMOTE_ID_RETRY, interval=Consts.GET_REMOVE_ID_RETRY_INTERVAL, failure=ProbeConnectionException, eraise=ProbeConnectionException)( Client.getRemoteId)(action.probeIp) # probeId = Client.getRemoteId(action.probeIp) cls.logger.info("Adding probe %s at %s to overlay", probeId, action.probeIp) addMessage = Add(Identification.PROBE_ID, probeId, action.probeIp) #use action directly because of timing issues selfAddAction = a.Add( action.probeIp, probeId, Hello(probeId, list(ProbeStorage.getAllOtherProbes()), Identification.PROBE_ID, echo=Identification.PROBE_ID if action.mergeOverlays else None)) # selfAddMessage = copy.deepcopy(addMessage) # selfAddAction.hello = Hello(probeId, # list(ProbeStorage.getAllOtherProbes()), # Identification.PROBE_ID, # echo = Identification.PROBE_ID if action.mergeOverlays else None) # Do broadcast before adding the probe so that it doesn't receive unnecessary message # addMessage = m.Add(Identification.PROBE_ID, probeId, message.targetIp, hello=True) # print(ProbeStorage.getIdAllOtherProbes()) Client.broadcast(addMessage) #treat message after so that the new guy does not receive bogus add message #treat the add for this addToOverlay before any other AddToOverlay # import calls.messagetoaction as MTA cls.addTask(selfAddAction) #try to fix adding host too quickly Scheduler.addToOverlay() cls.logger.debug("Probe %s added to overlay", probeId) except ProbeConnectionException as e: cls.logger.warning("Adding probe failed %s : %s", action.probeIp, e)
def manageAddToOverlay(cls, action): assert isinstance(action, a.AddToOverlay) cls.logger.ddebug("Add probe to overlay") try: probeId = Retry.retry(times = Consts.GET_REMOTE_ID_RETRY, interval = Consts.GET_REMOVE_ID_RETRY_INTERVAL, failure = ProbeConnectionException, eraise = ProbeConnectionException)(Client.getRemoteId)(action.probeIp) # probeId = Client.getRemoteId(action.probeIp) cls.logger.info("Adding probe %s at %s to overlay", probeId, action.probeIp) addMessage = Add(Identification.PROBE_ID, probeId, action.probeIp) #use action directly because of timing issues selfAddAction = a.Add(action.probeIp, probeId, Hello(probeId, list(ProbeStorage.getAllOtherProbes()), Identification.PROBE_ID, echo = Identification.PROBE_ID if action.mergeOverlays else None) ) # selfAddMessage = copy.deepcopy(addMessage) # selfAddAction.hello = Hello(probeId, # list(ProbeStorage.getAllOtherProbes()), # Identification.PROBE_ID, # echo = Identification.PROBE_ID if action.mergeOverlays else None) # Do broadcast before adding the probe so that it doesn't receive unnecessary message # addMessage = m.Add(Identification.PROBE_ID, probeId, message.targetIp, hello=True) # print(ProbeStorage.getIdAllOtherProbes()) Client.broadcast(addMessage) #treat message after so that the new guy does not receive bogus add message #treat the add for this addToOverlay before any other AddToOverlay # import calls.messagetoaction as MTA cls.addTask(selfAddAction) #try to fix adding host too quickly Scheduler.addToOverlay() cls.logger.debug("Probe %s added to overlay", probeId) except ProbeConnectionException as e: cls.logger.warning("Adding probe failed %s : %s", action.probeIp, e)
def manageBroadcast(cls, action): """Decapsulate broadcast message""" assert isinstance(action, a.Broadcast) Client.broadcast(action.broadcast)