def process(self, arg):
        '''This is the only resource method called by the controller.'''

        action = arg.get('action')
        params = arg.get('attributes', {}) or {}
        monitor = arg.get('monitor')

        if monitor is not None:
            params['monitor'] = monitor

        self.res_id = arg.get('id')

        msg = "[%s] %s" % (self.__resource__.upper(), self.action_map[action])
        if self.res_id:
            msg += " '%s'" % self.res_id
        if params:
            msg += " (%s)" % self._fmt_attrs(params)

        self.logger.info(msg)

        self._lock = True
        self.response = self.set_response()
        try:
            result = getattr(self, action)(res_id=self.res_id,
                                           attributes=params)

            self.response = self.set_response(result)

            msg = "[%s] %s" % (self.__resource__.upper(), action.capitalize())
            if self.res_id:
                msg += " '%s'" % self.res_id
            msg += ": OK"
            self.logger.info(msg)

        except ResourceException as err:
            self.response = self.set_response(error='%s' % err)
            self.logger.info("[%s] %s '%s': RESOURCE ERROR [%s]" %
                             (self.__resource__.upper(),
                              action.capitalize(),
                              self.res_id,
                              self.response['error'].rstrip('\n')))

        except Exception as err:
            self.response = self.set_response(error='%s' % err)
            traceback.print_exc(file=sys.stdout)
            self.logger.info("[%s] %s '%s': UNKNOWN ERROR [%s]" %
                             (self.__resource__.upper(),
                              action.capitalize(),
                              self.res_id,
                              self.response['error'].rstrip('\n')))
        finally:
            self._lock = False

        # Copy the value to return
        response = self.response

        # Reset status and response
        self.response = {}

        return response
dataset/ETHPy150Open comodit/synapse-agent/synapse/resources/resources.py/ResourcesController.process/original