"""Represent and manage nodes of the target cluster."""
import pyslurm

from node import Node


class Nodes(object):
    """A service object to inspect and manage worker nodes."""

    def __init__(self):
        """Initialize the Nodes object."""
        self.nodes = pyslurm.node()

    def list(self):
        """List the nodes available on the cluster."""
        current_nodes = self.nodes.get()
        return [Node(current_nodes[n]) for n in current_nodes]

@@ -88,16 +88,105 @@
 t Node%0A%0A
+import slurmscale as ss%0A# ss.set_stream_logger(__name__)  # Uncomment to enable logging%0A%0A
 %0Aclass N
@@ -380,24 +380,36 @@
 ef list(self
+, idle=False
 ):%0A        %22
@@ -410,16 +410,25 @@
      %22%22%22
+%0A        
 List the
@@ -459,19 +459,17 @@
 cluster.
-%22%22%22
+%0A
 %0A       
@@ -473,100 +473,649 @@
     
-current_nodes = self.nodes.get()%0A        return %5BNode(current_nodes%5Bn%5D) for n in current_nodes%5D
+:type subnet_id: %60%60bool%60%60%0A        :param subnet_id: If set, return only IDLE nodes.%0A%0A        :rtype: %60%60list%60%60 of :class:%60.Node%60%0A        :return: A list of %60%60Node%60%60 objects.%0A        %22%22%22%0A        slurm_nodes = self.nodes.get()%0A        current_nodes = %5B%5D%0A%0A        for n in slurm_nodes:%0A            if idle and slurm_nodes.get(n).get('state') == 'IDLE':%0A                ss.log.trace(%22node %7B0%7D is IDLE%22.format(n))%0A                current_nodes.append(Node(slurm_nodes%5Bn%5D))%0A            elif not idle:%0A                ss.log.trace(%22node %7B0%7D is not IDLE%22.format(n))%0A                current_nodes.append(Node(slurm_nodes%5Bn%5D))%0A        return current_nodes
 %0A

Add idle filter for nodes.list method