def create_storagepool_lvm(node, stp, vg): cmd = 'linstor storage-pool create lvm %s %s %s' % (node, stp, vg) action = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) result = action.stdout if reg.judge_cmd_result_war(str(result)): print(result.decode('utf-8')) #发生ERROR的情况 if reg.judge_cmd_result_err(str(result)): #使用不存的vg if reg.get_err_not_vg(str(result), node, vg): print(reg.get_err_not_vg(str(result), node, vg)) subprocess.check_output('linstor storage-pool delete %s %s' % (node, stp), shell=True) else: print(result.decode('utf-8')) print('FAIL') return result.decode() #成功 elif reg.judge_cmd_result_suc(str(result)): print('SUCCESS') return True
def execute_cmd(cmd): action = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) result = action.stdout.read() if reg.judge_cmd_result_suc(str(result)): return True elif reg.judge_cmd_result_err(str(result)): print(result.decode('utf-8')) return result.decode() if reg.judge_cmd_result_war(str(result)): messege_war = reg.get_war_mes(result.decode('utf-8')) print(messege_war) return messege_war
def create_resource(cmd): action = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) result = action.stdout if reg.judge_cmd_result_war(str(result)): print(reg.get_war_mes(result.decode('utf-8'))) if reg.judge_cmd_result_suc(str(result)): print('Resource %s was successfully created on Node %s' % (res, node_one)) elif reg.judge_cmd_result_err(str(result)): str_fail_cause = reg.get_err_detailes(result.decode('utf-8')) dict_fail = {node_one: str_fail_cause} flag.update(dict_fail)