Esempio n. 1
0
 def throw_paired_event(self, params):
     # the paired event is sent to both the peer in the connection
     event_s = {RCMPEventHandler.EVENT_KEY: PAIRED_EVENT, self.I_ADDRESS_KEY: params[self.PI_S_ADDRESS_KEY],
                self.PI_NAME_KEY: params[self.PI_R_NAME_KEY], self.PI_ADDRESS_KEY: params[self.PI_R_ADDRESS_KEY]}
     self._logger.info("Throwing paired event = %s" % event_s)
     # threading.Thread(target=self.notify, args=(event_s, )).start()
     threading.Thread(target=self.paired, args=(event_s, )).start()
     event_r = {RCMPEventHandler.EVENT_KEY: PAIRED_EVENT, self.I_ADDRESS_KEY: params[self.PI_R_ADDRESS_KEY],
                self.PI_NAME_KEY: params[self.PI_S_NAME_KEY], self.PI_ADDRESS_KEY: params[self.PI_S_ADDRESS_KEY]}
     self._logger.info("Throwing paired event = %s" % event_r)
     threading.Thread(target=self.paired, args=(event_r, )).start()
Esempio n. 2
0
 def target_on_stop_all_wd(self, params):
     # the platform node target of a clean up is always the master
     threading.Thread(target=self.wdm.delete_all_watchdogs).start()
     reason = "Stop all wd ack"
     result = RCMPMessage()
     result.create_ok_response(reason)
     return result
Esempio n. 3
0
 def target_on_rollback_update(self, params):
     # the platform node target of an update is always the master
     threading.Thread(target=self.execute_rollback_update, args=(params, )).start()
     reason = "Rollback update ack"
     result = RCMPMessage()
     result.create_ok_response(reason)
     return result
Esempio n. 4
0
 def process_request(self, request, client_address):
     """Start a new thread to process the request."""
     # this is specific when an handler has to process a request
     t = threading.Thread(target=self.process_request_thread,
                          args=(request, client_address))
     t.daemon = self.daemon_threads
     self.handlers[request] = t
     t.start()
Esempio n. 5
0
 def target_on_update(self, params):
     # when the master receives the update means that the connection between the 2 peers
     # has accepted and we must finalize the flow saving this connection and starting
     # the service logic associated with the robot in this connection
     # the platform node target of an update is always the master
     threading.Thread(target=self.execute_update, args=(params, )).start()
     reason = "Update ack"
     result = RCMPMessage()
     result.create_ok_response(reason)
     return result
Esempio n. 6
0
 def throw_update_event(self, params):
     event = {RCMPEventHandler.EVENT_KEY: UPDATE_EVENT,
              self.I_ADDRESS_KEY: self.pni[RCMPlatformNode.PNI_MASTER_NODE_IP]
              if not self.pni[RCMPlatformNode.PNI_IS_MASTER] else self.pni[RCMPlatformNode.PNI_ADDRESS],
              self.PI_S_NAME_KEY: self.pni[RCMPlatformNode.PNI_NAME],
              self.PI_S_ADDRESS_KEY: self.pni[RCMPlatformNode.PNI_ADDRESS],
              self.PI_R_NAME_KEY: params[self.PI_R_NAME_KEY],
              self.PI_R_ADDRESS_KEY: params[self.PI_R_ADDRESS_KEY]}
     self._logger.info("Throwing update event = %s" % event)
     threading.Thread(target=self.update, args=(event, )).start()
Esempio n. 7
0
 def target_on_rollback_update_all(self, params):
     # the platform node target of a rollback update all is always the master
     # the all version means that we have to rollback all the update between
     # we are rolling back all the update of the master platform node, so we take the
     # name of the current platform node and use it to have the connections associated
     # with it
     params[self.PI_S_NAME_KEY] = self.pni[RCMPlatformNode.PNI_NAME]
     params[self.PI_REACHABLE_KEY] = self.pni[RCMPlatformNode.PNI_TYPE]
     threading.Thread(target=self.execute_rollback_update_all, args=(params, )).start()
     reason = "Rollback update all ack"
     result = RCMPMessage()
     result.create_ok_response(reason)
     return result