コード例 #1
0
    def operationCall(self, session_id, nodes_list, operation_name, parameters_map):
        '''
        Calling asynchronous operation on nodes list

        @session_id (string) identifier of session (operation instance id)
        @nodes_list (list of string) list of nodes hostnames (or IP addresses)
        @operation_name (string) name of operation
        @parameters_map (dict {<param_name>:<param_value>}) operation parameters

        @return ret_code (integer) code of result
        @return ret_message (string) result description
        '''
        try:
            logger.debug('FriClient: [%s] calling %s operation at nodes %s'%(session_id, operation_name, nodes_list))

            packet = self.__form_fri_packet(session_id, operation_name, parameters_map)

            logger.debug('FriClient: [%s] FRI packet: %s' % (session_id,packet))

            for node in nodes_list:
                n_packet = packet.copy()
                n_packet['node'] = node
                self.__async_packets.put((node, n_packet))

            return (RC_OK, '')
        except Exception, err:
            err_message = 'FriClient failed on operation call: %s'%err
            logger.error(err_message)

            return (RC_ERROR, err_message)
コード例 #2
0
ファイル: nodesMonitor.py プロジェクト: fabregas/old_projects
    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:
コード例 #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:
コード例 #4
0
    def run(self):
        logger.debug('%s started!'%self.getName())

        self._update_pending_operations()

        while self._is_started:
            try:
                (session_id, operation) = self._active_operations.get_timeouted_operation()

                if not session_id:
                    time.sleep(1)
                    continue

                self._finish_operation(session_id, operation)
            except Exception, err:
                err_message = '%s failed: %s'%(self.getName(), err)
                logger.error(err_message)
コード例 #5
0
ファイル: nodesMonitor.py プロジェクト: fabregas/old_projects
    def run(self):
        logger.info('NodesMonitor started!')

        while not self.__stoped:
            try:
                t0_point = datetime.now()

                rows = self.__dbconn.select("SELECT N.hostname, N.current_state FROM nm_node N, nm_cluster C \
                                    WHERE N.cluster_id=C.id AND N.admin_status=%s AND C.status=%s",
                                    (ANS_ACTIVE, CS_ACTIVE))

                logger.debug('NodesMonitor: Selected %i nodes for checking state'%len(rows))

                for row in rows:
                    self.__nodes_queue.put((row[0], row[1]))

                self.__nodes_queue.join()
            except Exception, err:
                logger.error('NodesMonitor failed: %s' % err)
            finally:
コード例 #6
0
ファイル: friBase.py プロジェクト: fabregas/old_projects
    def run(self):
        logger.info('%s started!'%self.getName())
        while True:
            session_id = None
            node = None
            ret_params_map = {}
            ret_code = RC_OK
            ret_message = ''

            try:
                sock = self.queue.get()

                if sock == STOP_THREAD_EVENT:
                    logger.info('%s stopped!'%self.getName())
                    break

                data = ''
                while True:
                    received = sock.recv(BUF_SIZE)
                    if not received:
                        break

                    data += received

                    if len(received) < BUF_SIZE:
                        break

                logger.debug('%s receive: %s'%(self.getName(),data))

                if not data:
                    raise Exception('empty data block')

                json_object = json.loads(data)

                self.__onProcessResult(json_object)
            except Exception, err:
                ret_message = '%s error: %s' % (self.getName(), err)
                ret_code = RC_ERROR
                logger.error(ret_message)
            finally:
コード例 #7
0
    def __process_event(self, uuid, hostname, login, password, mac_address, ip_address, processor, memory):
        hw_info = 'Processor: %s\nMemory: %s'%(processor, memory)

        rows = self.__dbconn.select("SELECT hostname FROM nm_node WHERE node_uuid=%s", (uuid,))

        if not rows:
            #this is new node, create it in database in NEW status
            self.__dbconn.modify("INSERT INTO nm_node (node_uuid, hostname, login, password, mac_address, ip_address, admin_status, current_state, hw_info)\
                                    VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
                                    (uuid, hostname, login, password, mac_address, ip_address, NAS_NEW, NCS_UP, hw_info))

        else:
            #we already has this node in database, update it
            self.__dbconn.modify("UPDATE nm_node SET hostname=%s, login=%s, password=%s, mac_address=%s, ip_address=%s, hw_info=%s, current_state=%s\
                                    WHERE node_uuid=%s", (hostname, login, password, mac_address, ip_address, hw_info, NCS_UP, uuid))


            caller = self._get_operation_caller()
            if caller:
                logger.debug('Synchronize %s node parameters'%hostname)
                ret_code, ret_message = caller.call_nodes_operation(ADMIN, [hostname], SYNC_OPER, {})
                logger.debug('call SYNC operation result: [%s] %s'%(ret_code, ret_message))
コード例 #8
0
ファイル: dbusAgent.py プロジェクト: fabregas/old_projects
 def __debug_error(self):
     err_message =  '-'*80 + '\n'
     err_message += ''.join(apply(traceback.format_exception, sys.exc_info()))
     err_message += '-'*80 + '\n'
     logger.debug(err_message)