minermedic/miner_processor.py
def process_object_states(self, object, results):

        """
        Simple state machine that handles default Miner Actions
        when specific Actions are not defined in the ActionModel.

        Returns:
            Boolean

        """

        if object is None:
            # should not happen
            logger.error("OBJECT is None")
            return False

        if object.admin_disabled:
            return False

        if not self.has_object_init_time_passed(object, results):
            # do not execute the state machine for items that are still initializing...
            return False

        logger.debug("process states for object {}".format(object.unique_id))

        states = self.get_object_state(object, results)

        # STEP 1 - REACHABILITY
        if states.poll_error == 1:

            if states.ping_error == 1:

                if hasattr(object, "power_state") and hasattr(object, "connected_outlet"):
                    # TODO - add error message to results/object?
                    return object.powercycle()
                else:
                    if object.wake_on_lan():
                        return True
                    else:
                        # there may be an object/subclass specific PowerCycle
                        return object.powercycle()

            else:
                # object does not poll, but can ping, try to restart
                return object.restart_miner()

        # STEP 2 - CHECK TEMPS
        if states.temp_error == 1:
            message = "TEMPS too high on {}".format(object.ip)
            return object.powercycle()

        # STEP 3 - CHIPS
        if states.chip_error == 1:
            message = "CHIP errors on {}".format(object.ip)
            return object.restart_miner()

        # STEP 4 - HASHRATE
        if states.hashrate_error == 1:
            message = "HASHRATE problems on {}".format(object.ip)
            # Actions should be handled now by the action_model

        # STEP 5 - UI
        if states.ui_error == 1:
            message = "UI down on {}".format(object.ip)
            return object.restart_miner()

        # STEP 6 - PROFITABILITY
        profitability = results.get_result(object.id, 'profitability')
        if profitability is None and object.is_powered_off():
            # this means we did not poll and we still need to run the profitability check
            return execute_single_action(object, results, 'check_profit', 'CRYPTO_MINER')

        return False

        Simple state machine that handles default Miner Actions
        when specific Actions are not defined in the ActionModel.

        Returns:
            Boolean

        
Simple state machine that handles default Miner Actions
when specific Actions are not defined in the ActionModel.
Simple state machine that handles default Miner Actions when specific Actions are not defined in the ActionModel .
def process_object_states(self, object, results):
        if object is None:
            logger.error("OBJECT is None")
            return False
        if object.admin_disabled:
            return False
        if not self.has_object_init_time_passed(object, results):
            return False
        logger.debug("process states for object {}".format(object.unique_id))
        states = self.get_object_state(object, results)
        if states.poll_error == 1:
            if states.ping_error == 1:
                if hasattr(object, "power_state") and hasattr(object, "connected_outlet"):
                    return object.powercycle()
                else:
                    if object.wake_on_lan():
                        return True
                    else:
                        return object.powercycle()
            else:
                return object.restart_miner()
        if states.temp_error == 1:
            message = "TEMPS too high on {}".format(object.ip)
            return object.powercycle()
        if states.chip_error == 1:
            message = "CHIP errors on {}".format(object.ip)
            return object.restart_miner()
        if states.hashrate_error == 1:
            message = "HASHRATE problems on {}".format(object.ip)
        if states.ui_error == 1:
            message = "UI down on {}".format(object.ip)
            return object.restart_miner()
        profitability = results.get_result(object.id, 'profitability')
        if profitability is None and object.is_powered_off():
            return execute_single_action(object, results, 'check_profit', 'CRYPTO_MINER')
        return False
def process_object_states ( self , object , results ) : if object is None : logger . error ( "OBJECT is None" ) return False if object . admin_disabled : return False if not self . has_object_init_time_passed ( object , results ) : return False logger . debug ( "process states for object {}" . format ( object . unique_id ) ) states = self . get_object_state ( object , results ) if states . poll_error == 1 : if states . ping_error == 1 : if hasattr ( object , "power_state" ) and hasattr ( object , "connected_outlet" ) : return object . powercycle ( ) else : if object . wake_on_lan ( ) : return True else : return object . powercycle ( ) else : return object . restart_miner ( ) if states . temp_error == 1 : message = "TEMPS too high on {}" . format ( object . ip ) return object . powercycle ( ) if states . chip_error == 1 : message = "CHIP errors on {}" . format ( object . ip ) return object . restart_miner ( ) if states . hashrate_error == 1 : message = "HASHRATE problems on {}" . format ( object . ip ) if states . ui_error == 1 : message = "UI down on {}" . format ( object . ip ) return object . restart_miner ( ) profitability = results . get_result ( object . id , 'profitability' ) if profitability is None and object . is_powered_off ( ) : return execute_single_action ( object , results , 'check_profit' , 'CRYPTO_MINER' ) return False
Simple state machine that handles default Miner Actions
when specific Actions are not defined in the ActionModel.
Simple state machine that handles default Miner Actions when specific Actions are not defined in the ActionModel .
"""
        Simple state machine that handles default Miner Actions
        when specific Actions are not defined in the ActionModel.

        Returns:
            Boolean

        """ # should not happen # do not execute the state machine for items that are still initializing... # STEP 1 - REACHABILITY # TODO - add error message to results/object? # there may be an object/subclass specific PowerCycle # object does not poll, but can ping, try to restart # STEP 2 - CHECK TEMPS # STEP 3 - CHIPS # STEP 4 - HASHRATE # Actions should be handled now by the action_model # STEP 5 - UI # STEP 6 - PROFITABILITY # this means we did not poll and we still need to run the profitability check
None
self
object
results