def repair_active_generation(
        self, force_operational=False, wait_until_operational=True,
    ):
        """
        Ensure that all healthy active-generation nodes are operational.

        ``force_operational`` If True, even non-healthy active-generation nodes
        will be made operational.
        ``wait_until_operational`` If False, doesn't wait for the nodes to
        become fully operational.

        Returns any nodes that were made operational by this action.
        """
        if self.active_is_fully_operational():
            logger.info("All active nodes are operational")
            return []

        nodes = self.get_inoperational_active_nodes()

        made_operational = []
        for node in nodes:
            if not node.aws_id:
                logger.warning(
                    "Node missing: %s- %s",
                    node.aws_type,
                    node.name,
                )
                continue
            if not node.is_operational:
                if node.is_healthy or force_operational:
                    logger.info("Making node operational: %s" % node)
                    node.make_operational(force_operational=force_operational)
                    made_operational.append(node)
                else:
                    logger.warning("Node unhealthy: %s" % node.boto_instance)
            else:
                logger.debug("Node operational: %s" % node)

        fixed_nodes = copy(made_operational)
        # Wait til of these nodes are actually operational
        if len(fixed_nodes) == 0:
            logger.info("No healthy non-operational nodes available")
            return []

        if not wait_until_operational:
            return fixed_nodes

        logger.info("Waiting until all nodes are actually operational")
        time_waited = 0
        while made_operational:
            if time_waited > MAKE_OPERATIONAL_TIMEOUT:
                raise WaitTimedOut(
                    "Timed out waiting on nodes: %s" % made_operational)
            _made_operational = made_operational[:]
            for node in _made_operational:
                if node.is_operational:
                    made_operational.remove(node)
            if made_operational:
                logger.info(
                    "%s node(s) still not operational. Waiting %ss",
                    len(made_operational),
                    WAIT_TIME,
                )
                time.sleep(WAIT_TIME)
                time_waited += WAIT_TIME

        return fixed_nodes
dataset/ETHPy150Open winhamwr/neckbeard/neckbeard/environment_manager.py/Deployment.repair_active_generation/original