def get_available_nodes(self, slices_size=1): """ Returns a list of currently available nodes by slice of slices_size ex: for slices of size 4 ['cn[100-103]','cn[109,150-152]'] Args: (int) slices_size: slices size Returns: (str) list of nodes_id """ cmd = "sinfo -h -t IDLE" cmd_output = Popen(cmd, cwd=os.getcwd(), shell=True, stdout=PIPE, universal_newlines=True) if cmd_output.wait(): return [] nodeset = NodeSet() for line in cmd_output.stdout: nodeset_str = re.split(r'\s+', line.strip())[5] nodeset.update(nodeset_str) split_c = int(len(nodeset) / slices_size) nodes_list = [str(ns) for ns in nodeset.split(split_c)] return nodes_list
def get_available_nodes(self, slices_size=1): """ Returns a list of currently available nodes by slice of slices_size ex: for slices of size 4 ['cn[100-103]','cn[109,150-152]'] Args: (int) slices_size: slices size Returns: (str) list of nodes_id """ cmd_str = "sinfo -h -t IDLE" ret_code, stdout, _ = utils.run_cmd(cmd_str, os.getcwd()) if ret_code: print("!!Warning: unclebech was not able to get avaiable nodes") return [] nodeset = NodeSet() for line in stdout: nodeset_str = re.split(r'\s+', line.strip())[5] nodeset.update(nodeset_str) split_c = int(len(nodeset) / slices_size) nodes_list = [str(ns) for ns in nodeset.split(split_c)] return nodes_list