Exemple #1
0
    def _handleUpdate(self, mid):
        if srvdata.existsMonitorData(mid):
            sinfodao, ip, port = srvdata.getMonitorData(mid)
            srvdata.keepAliveMonitor(mid)

            s = None
            try:
                self._sendUpdateToMonitor(ip, port)

            except socket.error:
                logging.debug("Error updating %s:%s" % (ip, port))
                self.sock.sendall(
                    helper.getMonitorUnreachableError(
                        "Error connecting to %s:%s" % (ip, port)))
            except socket.timeout:
                logging.debug("Timeout updating %s:%s" % (ip, port))
                self.sock.sendall(
                    helper.getMonitorUnreachableError(
                        "Error connecting to %s:%s [Timeout]" % (ip, port)))
            finally:
                if s: s.close()
        else:
            self.sock.sendall(
                helper.getMonitorNotFoundError("Monitor %s does not exists" %
                                               mid))
Exemple #2
0
    def _handleUpdate(self, mid):
        if srvdata.existsMonitorData(mid):
            sinfodao, ip, port = srvdata.getMonitorData(mid)
            srvdata.keepAliveMonitor(mid)

            s = None
            try:
                self._sendUpdateToMonitor(ip, port)

            except socket.error:
                logging.debug("Error updating %s:%s" % (ip, port))
                self.sock.sendall(
                        helper.getMonitorUnreachableError(
                            "Error connecting to %s:%s" % (ip, port)
                        )
                    )
            except socket.timeout:
                logging.debug("Timeout updating %s:%s" % (ip, port))
                self.sock.sendall(
                        helper.getMonitorUnreachableError(
                            "Error connecting to %s:%s [Timeout]" % (ip, port)
                        )
                    )
            finally:
                if s: s.close()
        else:
            self.sock.sendall(
                        helper.getMonitorNotFoundError(
                            "Monitor %s does not exists" % mid)
                    )
Exemple #3
0
    def _handleGet(self, mid):

        if srvdata.existsMonitorData(mid):
            sinfodao, ip, port = srvdata.getMonitorData(mid)
            xmlbuilder = common.SysInfoXMLBuilder()
            xmlbuilder.setXMLData(sinfodao)

            data = "IP: %s\nPORT: %s\n%s" % (ip, port,
                                             xmlbuilder.getAsString())

            msg = helper.getOkMessage('Data of %s' % mid, data)
            self.sock.sendall(msg)
        else:
            self.sock.sendall(
                helper.getMonitorNotFoundError("Monitor %s is not registered" %
                                               mid))
Exemple #4
0
    def _handleGet(self, mid):

        if srvdata.existsMonitorData(mid):
            sinfodao, ip, port = srvdata.getMonitorData(mid)
            xmlbuilder = common.SysInfoXMLBuilder()
            xmlbuilder.setXMLData(sinfodao)

            data = "IP: %s\nPORT: %s\n%s" % (ip, port, xmlbuilder.getAsString())

            msg = helper.getOkMessage('Data of %s' % mid, data)
            self.sock.sendall( msg )
        else:
            self.sock.sendall( 
                helper.getMonitorNotFoundError(
                    "Monitor %s is not registered" % mid)
                )
Exemple #5
0
    def _updateMonitor(self, mid):

        if srvdata.existsMonitorData(mid):
            srvdata.keepAliveMonitor(mid)

            data = common.recvEnd(self.sock, gdata.ETX).strip()
            #logging.debug("%s:%d Data:\n%s" % (self.addr[0], self.addr[1], data))

            infoparser = common.SysInfoXMLParser()
            infoparser.parseXML(data)
            infodao = infoparser.getSysInfoData()
            srvdata.updateMonitorData(mid, infodao)
            self.sock.sendall(helper.getOkMessage("Update successful"))
            logging.debug("Update %s successful" % mid)
        else:
            self.sock.sendall(
                helper.getMonitorNotFoundError(
                    "There isn't any monitor with id: %s" % mid))
Exemple #6
0
    def _updateMonitor(self, mid):
        
        if srvdata.existsMonitorData(mid):
            srvdata.keepAliveMonitor(mid)

            data = common.recvEnd(self.sock, gdata.ETX).strip()
            #logging.debug("%s:%d Data:\n%s" % (self.addr[0], self.addr[1], data))

            infoparser = common.SysInfoXMLParser()
            infoparser.parseXML(data)
            infodao = infoparser.getSysInfoData()
            srvdata.updateMonitorData(mid, infodao)
            self.sock.sendall( helper.getOkMessage("Update successful") )                   
            logging.debug("Update %s successful" % mid)
        else:
            self.sock.sendall( 
                helper.getMonitorNotFoundError(
                    "There isn't any monitor with id: %s" % mid)
                )