def node_list()

in azure-slurm/slurmcc/partition.py [0:0]


    def node_list(self) -> str:
        if not self.dynamic_feature:
            static_nodes = self._static_all_nodes()
            if not static_nodes:
                return ""
            return slutil.to_hostlist(self._static_all_nodes())
        # with dynamic nodes, we only look at those defined in the partition
        if not self.__dynamic_node_list_cache:
            if not slutil.is_slurmctld_up():
                logging.warning("While slurmctld is down, dynamic nodes can not be queried at this time.")
                return ""
            ret: List[str] = []
            all_slurm_nodes = Partition._slurm_nodes()
            for node in all_slurm_nodes:
                partitions = node.get("Partitions", "").split(",")
                if self.name in partitions:
                    # only include nodes that have the same vm_size declared as a feature
                    features = (node.get("AvailableFeatures") or "").lower().split(",")
                    if self.machine_type.lower() in features:
                        ret.append(node["NodeName"])
                    else:
                        matches_another_vm_size = set(self.nodearray_machine_types).intersection(set(features))
                        if matches_another_vm_size:
                            # this node has a declared vm_size, but it's not the one we're looking for.
                            continue

                        # we only use the highest priority vm_size as the default - let that 
                        # partition object handle this.
                        if self.machine_type.lower() != self.nodearray_machine_types[0]:
                            continue

                        # anything that starts with standard_ "looks" like a vm_size, at least for logging purposes
                        possible_vm_sizes = [f for f in features if f.startswith("standard_")]
                        if possible_vm_sizes:
                            # we do allow users to use features that start with standard_, but we 
                            # want to warn them at least. For example, someone puts standard_f2_2v instead of _v2
                            # or say someone unchecks the relevant vm_size from the CycleCloud cluster.
                            logging.warning("Found potential vm_size %s - however none match approved vm sizes %s. Is this a typo?",
                                             ",".join(possible_vm_sizes),
                                             ",".join(self.nodearray_machine_types))

                        # if we get here, we will just use our  machine type as the vm_size.
                        # HOWEVER we bump the logging up to warning if there are multiple vm_sizes defined
                        # for this nodearray, as users _should_ be specific about which vm size they want when
                        # allowing more than one per nodearray.
                        log_level = logging.DEBUG if len(self.nodearray_machine_types) > 1 else logging.WARNING
                        logging.log(log_level,
                                    "No vm_size feature for node %s is defined, assuming vm_size %s",
                                    node["NodeName"],
                                    self.machine_type)
                        ret.append(node["NodeName"])
                        
            self.__dynamic_node_list_cache = slutil.to_hostlist(ret) if ret else ""
            
        return self.__dynamic_node_list_cache