Esempio n. 1
0
    def notify(self, evt):
        Job.notify(self, evt)
        log.debug("Notified of event: %s" % str(evt.__class__))
        if isinstance(evt, simple.ConnectCompleteEvent) and \
            evt.getSource() == self.connect_job:
            self.conn = evt.getConnection()
            self.run()
        elif isinstance(evt, simple.ConnectFailedEvent) and \
              evt.getSource() == self.connect_job:
            log.error("Failed to connect to agent")
            print "Failed to connect to agent"
            self.getAgent().setState(agent.STOPPING)

        elif isinstance(evt, agent.MessageReceivedEvent) and \
              isinstance(evt.getMessage(), message.Response):

            if isinstance(evt.getMessage(), agent.OkResponse) and \
               self.key == evt.getMessage().getRequestKey():
                print "Shutdown Acknowledged"
                self.getAgent().setState(agent.STOPPING)

            elif isinstance(evt.getMessage(), agent.DeniedResponse) and \
               self.key == evt.getMessage().getRequestKey():
                print "Shutdown Denied"
                self.getAgent().setState(agent.STOPPING)
Esempio n. 2
0
 def notify(self, evt):
     Job.notify(self, evt)
     if isinstance(evt, simple.ConnectCompleteEvent):
         self.conn = evt.getConnection()
         self.run()
     elif isinstance(evt, agent.MessageReceivedEvent):
         if isinstance(evt.getMessage(), simple.StatusResponse) and \
            self.key == evt.getMessage().getRequestKey():
             print "Status Acknowledged"
             print str(evt.getMessage())
             self.getAgent().setState(agent.STOPPING)
         if isinstance(evt.getMessage(), agent.DeniedResponse) and \
            self.key == evt.getMessage().getRequestKey():
             print "Status Denied"
             self.getAgent().setState(agent.STOPPING)