def get_hotpluggable_blocks(path): mem_blocks = [] for mem_blk in glob.glob(path): block = re.findall("\d+", os.path.basename(mem_blk))[0] block = re.sub(r'^\s*$', '', block) if memory.is_hot_pluggable(block): mem_blocks.append(block) return mem_blocks
def get_hotpluggable_blocks(path, ratio): mem_blocks = [] for mem_blk in glob.glob(path): block = re.findall(r"\d+", os.path.basename(mem_blk))[0] block = re.sub(r'^\s*$', '', block) if memory.is_hot_pluggable(block): mem_blocks.append(block) def f(num): if num % 2: return (num / 100 + 1) return (num / 100) count = f(len(mem_blocks) * ratio) return mem_blocks[:count]
def get_hotpluggable_blocks(path, ratio): mem_blocks = [] for mem_blk in glob.glob(path): block = re.findall(r"\d+", os.path.basename(mem_blk))[0] block = re.sub(r'^\s*$', '', block) if memory.is_hot_pluggable(block): mem_blocks.append(block) def chunks(num): """ Return number of blocks in chunks of 100 """ if num % 2: return num // 100 + 1 return num // 100 count = chunks(len(mem_blocks) * ratio) return mem_blocks[:count]