def nodes()

in hostfactory/host_provider/src/cluster.py [0:0]


    def nodes(self, request_ids):
        responses = {}
        for request_id in request_ids:
            def _get_nodes_by_request_id(req_id, action):
                try:
                    affected_nodes = self.node_mgr.get_nodes_by_request_id(req_id)
                    self.logger.debug("Nodes %s %s", action, affected_nodes)
                    return affected_nodes
                except Exception as e:
                    if "No operation found for request id" in str(e):
                        self.logger.debug("No new nodes have been %s", action)
                        return None 
                    raise
                    
            # : Optional[str]
            request_id_start = f"{request_id}-start"
            request_id_create = f"{request_id}-create"
            nodes_started = _get_nodes_by_request_id(request_id_start, "started")
            nodes_created = _get_nodes_by_request_id(request_id_create, "created")
            if nodes_created is None and nodes_started is None:
                raise RuntimeError(f"Could not find request id {request_id}")

            responses[request_id] = []
            if nodes_started: 
                responses[request_id].extend(nodes_started)
            if nodes_created: 
                responses[request_id].extend(nodes_created)
            self.logger.debug(responses)
        return responses