Ejemplo n.º 1
0
    def on_mdp_request(self, msg):
        """ Handle Requests over MQ 
            @param msg : MQ req message
        """
        # XplPlugin handles MQ Req/rep also
        XplPlugin.on_mdp_request(self, msg)

        ### packages details
        # retrieve the packages details
        if msg.get_action() == "package.detail.get":
            self.log.info(u"Packages details request : {0}".format(msg))
            self._mdp_reply_packages_detail()

        ### device_types
        # retrieve the device_types
        elif msg.get_action() == "device_types.get":
            self.log.info(u"Device types request : {0}".format(msg))
            self._mdp_reply_device_types(msg)

        ### clients list and details
        # retrieve the clients list
        elif msg.get_action() == "client.list.get":
            self.log.info(u"Clients list request : {0}".format(msg))
            self._mdp_reply_clients_list()

        # retrieve the clients details
        elif msg.get_action() == "client.detail.get":
            self.log.info(u"Clients details request : {0}".format(msg))
            self._mdp_reply_clients_detail()

        # start clients
        elif msg.get_action() == "plugin.start.do":
            self.log.info(u"Plugin startup request : {0}".format(msg))
            self._mdp_reply_plugin_start(msg)
Ejemplo n.º 2
0
    def on_mdp_request(self, msg):
        """ Called when a MQ req/rep message is received
        """
        XplPlugin.on_mdp_request(self, msg)
        if msg.get_action() == "client.cmd":
            print(msg)
            reason = None
            status = True
            data = msg.get_data()
            if 'blacklist' in data:
                bl = data['blacklist']
            else:
                reason = u"Invalid command : no blacklist key in message"
                status = False

            if status == True:
                try:
                    with open(self.blacklist_file, 'ab') as fp_blacklist:
                        fp_blacklist.write("\n{0};{1}".format("manual blacklisting", bl))
                except:
                    reason = u"Error while completing blacklist file : {0}. Error is : {1}".format(self.blacklist_file, traceback.format_exc())
                    self.log.error(reason)
                    status = False
                self.load_blacklist()


            self.log.info("Reply to command")
            reply_msg = MQMessage()
            reply_msg.set_action('client.cmd.result')
            reply_msg.add_data('status', status)
            reply_msg.add_data('reason', reason)
            self.reply(reply_msg.get())

            if status == True:
                thread.start_new_thread(self.open_modems, ())
Ejemplo n.º 3
0
    def on_mdp_request(self, msg):
        """ Handle Requests over MQ
            @param msg : MQ req message
        """
        try:
            with self._db.session_scope():
                # XplPlugin handles MQ Req/rep also
                XplPlugin.on_mdp_request(self, msg)

                # configuration
                if msg.get_action() == "config.get":
                    self._mdp_reply_config_get(msg)
                elif msg.get_action() == "config.set":
                    self._mdp_reply_config_set(msg)
                elif msg.get_action() == "config.delete":
                    self._mdp_reply_config_delete(msg)
                # devices list
                elif msg.get_action() == "device.get":
                    self._mdp_reply_devices_result(msg)
                # device get params
                elif msg.get_action() == "device.params":
                    self._mdp_reply_devices_params_result(msg)
                # device create
                elif msg.get_action() == "device.create":
                    self._mdp_reply_devices_create_result(msg)
        except exception as e:
            msg = "Exception in on_mdp_request: {0}".format(e)
            self.log.error(msg)
            self.log.error(traceback.format_exc())
            print msg
Ejemplo n.º 4
0
    def on_mdp_request(self, msg):
        # XplPlugin handles MQ Req/rep also
        XplPlugin.on_mdp_request(self, msg)

        if msg.get_action() == "reload":
            self.load()
            msg = MQMessage()
            msg.set_action('reload.result')
            self.reply(msg.get())
        elif msg.get_action() == "cmd.send":
            self._send_xpl_command(msg)
Ejemplo n.º 5
0
    def on_mdp_request(self, msg):
	# XplPlugin handles MQ Req/rep also
        XplPlugin.on_mdp_request(self, msg)

        if msg.get_action() == "reload":
            self.load()
            msg = MQMessage()
            msg.set_action( 'reload.result' )
            self.reply(msg.get())
	elif msg.get_action() == "cmd.send":
            self._send_xpl_command(msg)
Ejemplo n.º 6
0
 def on_mdp_request(self, msg):
     """ Method called when an mq request comes in
     XplPlugin also needs this info, so we need to do a passthrough
     """
     try:
         XplPlugin.on_mdp_request(self, msg)
         if msg.get_action() == "test":
             pass
         if msg.get_action() == "cmd.send":
             self._send_xpl_command(msg)
     except Exception as exp:
         self.log.error(traceback.format_exc())
Ejemplo n.º 7
0
    def on_mdp_request(self, msg):
    # XplPlugin handles MQ Req/rep also
        try:
            XplPlugin.on_mdp_request(self, msg)

            if msg.get_action() == "reload":
                self.load()
                msg = MQMessage()
                msg.set_action( 'reload.result' )
                self.reply(msg.get())
            elif msg.get_action() == "cmd.send":
                self._send_xpl_command(msg)
        except:
            self.log.error(traceback.format_exc())
Ejemplo n.º 8
0
    def on_mdp_request(self, msg):
        """ Handle Requests over MQ
            @param msg : MQ req message
        """
        with self._db.session_scope():
            # XplPlugin handles MQ Req/rep also
            XplPlugin.on_mdp_request(self, msg)

            # configuration
            if msg.get_action() == "config.get":
                self._mdp_reply_config_get(msg)
            elif msg.get_action() == "config.set":
                self._mdp_reply_config_set(msg)
            elif msg.get_action() == "config.delete":
                self._mdp_reply_config_delete(msg)
            # devices list
            elif msg.get_action() == "device.get":
                self._mdp_reply_devices_result(msg)
Ejemplo n.º 9
0
    def on_mdp_request(self, msg):
        """ Handle Requests over MQ
            @param msg : MQ req message
        """
        with self._db.session_scope():
            # XplPlugin handles MQ Req/rep also
            XplPlugin.on_mdp_request(self, msg)

            # configuration
            if msg.get_action() == "config.get":
                self._mdp_reply_config_get(msg)
            elif msg.get_action() == "config.set":
                self._mdp_reply_config_set(msg)
            elif msg.get_action() == "config.delete":
                self._mdp_reply_config_delete(msg)
            # devices list
            elif msg.get_action() == "device.get":
                self._mdp_reply_devices_result(msg)