def run_text_step(ssh, file_text_step, param=None, interval=None): step_list = Utils.read_file(file_text_step) for cmd in step_list: cmd = cmd.strip() if cmd: if param: for key, value in param.iteritems(): #Util._logger.info(str(key) + ": " + str(value)) if key.startswith('tag_'): value = str(value) cmd = cmd.replace(key, value) #print cmd ssh.send_expect_prompt(cmd) if interval: time.sleep(interval)
def get_node_name_list(path_config_file): pattern1 = re.compile("\s*\,\s*") pattern2 = re.compile("\[(?P<range>[0-9\-]+)\]") pattern3 = re.compile(r"-") node_list = [] line_list = Utils.read_file(path_config_file) for line in line_list: line.strip() if line == "": continue if line.startswith("#"): continue if pattern1.search(line): node_list_1 = pattern1.split(line) node_list = node_list + node_list_1 elif pattern2.search(line): m = pattern2.search(line) rangex = m.group("range") hostname_prefix = line.replace("[" + rangex + "]", "") range_item_list = pattern3.split(rangex) for i in range(int(range_item_list[0]), int(range_item_list[1])+1): hostname = hostname_prefix + str(i).zfill(2) node_list.append(hostname) else: node_list.append(line) return sorted(node_list)