Esempio n. 1
0
    def updateOperationProgress(self, progress_percent, ret_message='', ret_code=0, ret_params={}):
        '''
        Updating operation progress. Send progress information to management node by FRI protocol
                                    DON'T REIMPLEMENT THIS METHOD

        @progress_percent (integer) - operation progress in percents (100 = finished operation)
        @ret_code (integer) - indicate state of operation processing
                                (if 0 then already ok, else operation is failed)
        @ret_message (string) - description of operation progress
        @ret_params (dict {param_name: param_value}) - return parameters
        '''

        fri_caller = FriCaller()

        packet = {  'id': self.__session_id,
                    'node': self.__node,
                    'progress': progress_percent,
                    'ret_code': ret_code,
                    'ret_message': ret_message,
                    'ret_parameters': ret_params}

        code, message = fri_caller.call(FARNSWORTH_HOSTNAME, packet, NODES_MANAGER_PORT, timeout=WAIT_TIMEOUT)

        if code:
            logger.error('%s.updateOperationProgress failed with code=%s and message=%s'%
                            (self.__class__.__name__, code, message))
Esempio n. 2
0
    def run(self):
        logger.info('%s started!'%self.getName())

        fri_caller = FriCaller()

        packet = {'id':0, 'node': '',
                  'operation': 'LIVE'}

        while True:
            try:
                item = self.queue.get()
                if item == FINISH_FLAG:
                    logger.info('%s stoped!'%self.getName())
                    break

                hostname, last_state = item

                ret_code, ret_message = fri_caller.call(hostname, packet, timeout=self.wait_timeout)

                if ret_code:
                    logger.debug('Node with hostname %s is not live!!!'%hostname)
                else:
                    logger.debug('Node with hostname %s is live!'%hostname)

                if ret_code and (last_state == CNS_ON):
                    self.__change_node_state(hostname, CNS_OFF)

                elif (not ret_code) and (last_state == CNS_OFF):
                    self.__change_node_state(hostname, CNS_ON)
            except Exception, err:
                logger.error('%s failed: %s'%(self.getName(), err))
            finally:
Esempio n. 3
0
    def run(self):
        """Thread class run method. Call asynchronous cluster operation"""

        fri_client = FriCaller()

        logger.info('%s started!'%self.getName())
        while True:
            try:
                item = self.queue.get()
                if item == STOP_THREAD_EVENT:
                    logger.info('%s stopped!'%self.getName())
                    break

                #unpack item
                node, packet = item

                err_code, err_message = fri_client.call(node, packet)

                if err_code != RC_OK:
                    logger.error('%s: error while sending %s to node %s. Details: %s' % (self.getName(), packet, node, err_message))
                else:
                    logger.debug('%s: node %s is called successful' % (self.getName(), node))
            except Exception, err:
                err_message = '%s failed: %s'%(self.getName(), err)
                logger.error(err_message)
            finally: