def preprocess_backupOS_FTsystem(parser): """ preprocess backupOS FTsystem check FTsystem status start/stop FTsystem raise exception if FTsystem can not start/stop """ if parser["pre_check_backupOS_FTsystem"] == "yes": ssh = shell_server.get_ssh(parser["BackupOS_ip"], parser["BackupOS_usr"], parser["BackupOS_pwd"]) status = FTsystem.get_status(ssh) if status == "not running" and parser["pre_backupOS_FTsystem_start"] == "yes": FTsystem.start(ssh) time.sleep(float(parser["pre_backupOS_FTsystem_start_time"])) if FTsystem.get_status(ssh) == "not running": ssh.close() raise TA_error.Preprocess_Error("backupOS FTsystem can not start") if status == "running" and parser["pre_backupOS_FTsystem_start"] == "no": FTsystem.stop(ssh) time.sleep(float(parser["pre_backupOS_FTsystem_start_time"])) if FTsystem.get_status(ssh) == "running": ssh.close() raise TA_error.Preprocess_Error("backupOS FTsystem can not stop") ssh.close()
def preprocess_slaveOS_FTsystem(parser): """ preprocess backupOS FTsystem part check FTsystem status start/stop FTsystem raise exception if FTsystem can not start/stop :called func: preprocess_backupOS_OS :param parser: is a dict, get from Test config file """ if parser["pre_check_slaveOS_FTsystem"] == "yes": ssh = shell_server.get_ssh(parser["SlaveOS_ip"], parser["SlaveOS_usr"], parser["SlaveOS_pwd"]) #獲得ssh status = FTsystem.get_status(ssh) if status == "not running" and parser[ "pre_slaveOS_FTsystem_start"] == "yes": #若狀態不為running且根據參數必需是running則進入 FTsystem.start(ssh) #透過ssh開啟libvirt time.sleep(float(parser["pre_slaveOS_FTsystem_start_time"])) if FTsystem.get_status( ssh) == "not running": #若狀態不為running則raise exception ssh.close() raise TA_error.Preprocess_Error("slaveOS FTsystem can not start") if status == "running" and parser[ "pre_slaveOS_FTsystem_start"] == "no": #若狀態為running且根據參數必需不是running則進入 FTsystem.stop(ssh) time.sleep(float(parser["pre_slaveOS_FTsystem_start_time"])) if FTsystem.get_status( ssh) == "running": #若狀態為running則raise exception ssh.close() raise TA_error.Preprocess_Error( "slaveOS FTsystem can not stop") ssh.close()
def stop_libvirt_process(parser): ssh = shell_server.get_ssh(parser["PrimaryOS_ip"], parser["PrimaryOS_usr"], parser["PrimaryOS_pwd"]) #獲得ssh FTsystem.stop(ssh) if FTsystem.get_status(ssh) == "running": raise TA_error.Process_Error("libvirt in host OS cannot stop") ssh.close()
def FTsystem_running_in_hostOS(parser): """ FTsystem is running in hostOS or not return True/raise exception """ ssh = shell_server.get_ssh(parser["HostOS_ip"] , parser["HostOS_usr"] , parser["HostOS_pwd"]) if FTsystem.get_status(ssh) == "running": return True raise TA_error.Assert_Error("FTsystem is not running on hostOS")
def postprocess_hostOS_FTsystem(parser): """ postprocess PrimaryOS FTsystem part check FTsystem status start/stop FTsystem raise exception if FTsystem can not start/stop :called func: postprocess_hostOS :param parser: is a dict, get from Test config file """ if parser["pos_check_hostOS_FTsystem"] == "yes": ssh = shell_server.get_ssh(parser["PrimaryOS_ip"], parser["PrimaryOS_usr"], parser["PrimaryOS_pwd"]) #獲得ssh status = FTsystem.get_status(ssh) #獲得libvirt status if status == "not running" and parser[ "pos_hostOS_FTsystem_start"] == "yes": #若狀態不為running且根據參數pos_hostOS_FTsystem_start必須為running,則進入 FTsystem.start(ssh) #透過ssh開啟libvirt time.sleep(float(parser["pos_hostOS_FTsystem_start_time"])) if FTsystem.get_status( ssh) == "not running": #若狀態不為running則raise exception ssh.close() raise TA_error.Postprocess_Error( "PrimaryOS FTsystem can not start") if status == "running" and parser[ "pos_hostOS_FTsystem_start"] == "no": #若狀態為running且根據參數pos_hostOS_FTsystem_start必須不為running,則進入 FTsystem.stop(ssh) #透過ssh關閉libvirt time.sleep(float(parser["pos_hostOS_FTsystem_start_time"])) if FTsystem.get_status( ssh) == "running": #若狀態為running則raise exception ssh.close() raise TA_error.Postprocess_Error( "PrimaryOS FTsystem can not stop") ssh.close()
def FTsystem_running_in_hostOS(parser): """ FTsystem is running in hostOS or not :param parser: config :return: True/raise exception """ ssh = shell_server.get_ssh(parser["PrimaryOS_ip"], parser["PrimaryOS_usr"], parser["PrimaryOS_pwd"]) #獲取ssh if FTsystem.get_status(ssh) == "running": #透過ssh詢問FTsystem之狀態是否為running ssh.close() return True ssh.close() raise TA_error.Assert_Error("FTsystem is not running in hostOS")