示例#1
0
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()
示例#2
0
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()
示例#3
0
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()
示例#4
0
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()