Exemple #1
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()
Exemple #2
0
def preprocess_NFS_OS(parser):
    if FTOS.OS_is_running(parser["NFS_ip"], parser) == False:
        #FTOS.L1_boot(parser["NFS_NetworkAdaptor"])
        if FTOS.OS_is_running(parser["NFS_ip"], parser) == False:
            raise TA_error.Preprocess_Error("NFS node can not start")
    if FTOS.ssh_is_ready(parser["NFS_ip"], parser["NFS_usr"],
                         parser["NFS_pwd"], parser) == False:
        raise TA_error.Preprocess_Error("NFS node ssh can not access")

    ssh = shell_server.get_ssh(parser["NFS_ip"], parser["NFS_usr"],
                               parser["NFS_pwd"])  #獲得ssh
Exemple #3
0
def preprocess_hostOS_hw(parser):
    """
    perprocess hostOS hardware part

    :called func: preprocess_hostOS
    :param parser: is a dict, get from Test config file
      """
    if parser["pre_check_hostOS_hw"] == "yes":
        if mmsh.stateshmgr(parser["PrimaryOS_shmgr_name"]) == "stop":
            raise TA_error.Preprocess_Error("PrimaryOS hw shmgr stop")
        if mmsh.stateipmc(parser["PrimaryOS_ipmc_name"]) == "stop":
            raise TA_error.Preprocess_Error("PrimaryOS hw ipmc stop")
Exemple #4
0
def preprocess_hostOS_vm_running(parser):
    """
    preprocess vm become running

    :called func: preprocess_hostOS_vm
    :param parser: is a dict, get from Test config file
    """
    ssh = shell_server.get_ssh(parser["PrimaryOS_ip"], parser["PrimaryOS_usr"],
                               parser["PrimaryOS_pwd"])  #獲得ssh

    if FTVM.is_running(parser["vm_name"], parser["PrimaryOS_ip"], ssh):
        print 59
        if "pre_hostOS_VM_restart" in parser.keys(
        ) and parser["pre_hostOS_VM_restart"] == "yes":  #根據參數若VM需重新啟動
            print 54
            prepocess_hostOS_vm_restart(parser)
            print 55
            time.sleep(float(parser["pre_hostOS_VM_boot_time"]))
    elif FTVM.is_shutoff(parser["vm_name"], parser["PrimaryOS_ip"], ssh):
        print 56
        prepocess_hostOS_vm_start(parser)
        print 57
        time.sleep(float(parser["pre_hostOS_VM_boot_time"]))
    print 58
    if not FTVM.is_running(parser["vm_name"], parser["PrimaryOS_ip"], ssh):
        ssh.close()
        raise TA_error.Preprocess_Error("PrimaryOS VM: %s can not start" %
                                        parser["vm_name"])

    ssh.close()
Exemple #5
0
def preprocess_backupOS_OS_boot(parser):
    """
    preprocess backupOS OS boot

    :called func: preprocess_hostOS_OS
    :param parser: is a dict, get from Test config file
    """
    if not FTOS.is_running(parser["BackupOS_name"]):
        if FTOS.is_shutdown(parser["BackupOS_name"]):
            status = FTOS.boot(parser["BackupOS_name"])
            if status != "success":
                raise TA_error.Preprocess_Error(
                    "BackupOS OS boot command fail")
        time.sleep(float(parser["pre_backupOS_boot_time"]))
        if not FTOS.is_running(parser["BackupOS_name"]):
            raise TA_error.Preprocess_Error("BackupOS OS can not boot")
Exemple #6
0
def preprocess_hostOS_OS_shutdown(parser):
    """
    preprocess hostOS OS shutdown part

    :called func: preprocess_hostOS_OS
    :param parser: is a dict, get from Test config file
    """
    if not FTOS.is_shutdown(parser["PrimaryOS_name"]):  #若host不為關機狀態
        if FTOS.is_running(parser["PrimaryOS_name"]):
            status = FTOS.shutdown(parser["PrimaryOS_name"])
            if status != "success":
                raise TA_error.Preprocess_Error(
                    "PrimaryOS OS shutdown command fail")
        time.sleep(float(parser["pre_hostOS_shutdown_time"]))
        if not FTOS.is_shutdown(parser["PrimaryOS_name"]):
            raise TA_error.Preprocess_Error("PrimaryOS OS can not shutdown")
def postprocess_slaveOS_vm_shutdown(parser):
    """
  	postprocess backupOS vm become shutdown

  	:called func: postprocess_backupOS_vm
  	:param parser: is a dict, get from Test config file
  	"""
    ssh = shell_server.get_ssh(parser["SlaveOS_ip"], parser["SlaveOS_usr"],
                               parser["SlaveOS_pwd"])  #獲得ssh
    if FTVM.is_running(parser["vm_name"], parser["SlaveOS_ip"], ssh):
        FTVM.destroy(parser["vm_name"], parser["SlaveOS_ip"], ssh)
        time.sleep(float(parser["pos_slaveOS_VM_shutdown_time"]))
    elif FTVM.is_paused(parser["vm_name"], parser["SlaveOS_ip"], ssh):
        FTVM.resume(parser["vm_name"], parser["SlaveOS_ip"], ssh)
        FTVM.destroy(parser["vm_name"], parser["SlaveOS_ip"], ssh)
        time.sleep(float(parser["pos_slaveOS_VM_shutdown_time"]))
    times = 0
    while times < 30:
        print "check slave os vm status"
        if FTVM.is_running(parser["vm_name"], parser["SlaveOS_ip"], ssh):
            print "destroy slave os vm "
            FTVM.destroy(parser["vm_name"], parser["SlaveOS_ip"], ssh)
            break
        time.sleep(float(1))
        times += 1
    if not FTVM.is_shutoff(parser["vm_name"], parser["SlaveOS_ip"], ssh):
        ssh.close()
        raise TA_error.Postprocess_Error("SlaveOS %s can not shutdown" %
                                         parser["vm_name"])
    ssh.close()
Exemple #8
0
def preprocess_slaveOS_HAagent(parser):
    ssh = shell_server.get_ssh(parser["SlaveOS_ip"], parser["SlaveOS_usr"],
                               parser["SlaveOS_pwd"])  #獲得ssh
    if HAagent.is_running(ssh, parser):
        ssh.close()
        return True
    ssh.close()
    raise TA_error.Preprocess_Error("Slave OS HAAgent process not ready")
Exemple #9
0
def preprocess_slave_OS(parser):
    """
    preprocess  , Host os part , check slave node is booted
    :param parser : is a dict , get from test config file
    """
    if FTOS.OS_is_running(parser["SlaveOS_ip"], parser) == False:
        if parser["IPMI_supported"] == "yes":
            ssh = shell_server.get_ssh(parser["PrimaryOS_ip"],
                                       parser["PrimaryOS_usr"],
                                       parser["PrimaryOS_pwd"])  #獲得ssh
            FTOS.IPMI_boot(parser["SlaveOS_ipmb"], ssh)
            ssh.close()
        elif parser["IPMI_supported"] == "no":
            FTOS.L1_boot(parser["SlaveOS_NetworkAdaptor"])
    if FTOS.OS_is_running(parser["SlaveOS_ip"], parser) == False:
        raise TA_error.Preprocess_Error("SlaveOS node cannot boot")
    if FTOS.ssh_is_ready(parser["SlaveOS_ip"], parser["SlaveOS_usr"],
                         parser["SlaveOS_pwd"], parser) == False:
        raise TA_error.Preprocess_Error("Slave node ssh can not access")
def postprocess_slaveOS_HAAgent(parser):
    ssh = shell_server.get_ssh(parser["SlaveOS_ip"], parser["SlaveOS_usr"],
                               parser["SlaveOS_pwd"])  #獲得ssh
    if HAagent.is_running(ssh, parser):
        HAagent.exit(parser, ssh)
        if HAagent.is_running(ssh, parser):
            ssh.close()
            raise TA_error.Postprocess_Error("Slave HAAgent cannot shutdown")
    else:
        pass
Exemple #11
0
def detect_non_primary_node_add_node(parser):
    """
	detect use non-primary node add node success or not
	:param parser: config
	:return: True/raise exception
	"""
    success = HAagent_info.is_node_exists(parser["Cluster_name"],
                                          parser["SlaveOS_name"], parser)

    if not success:
        return True
    raise TA_error.Assert_Error("non primary node add node fail")
Exemple #12
0
def preprocess_hostOS_vm_login(parser):
    """
    preprocess check hostOS vm is login

    :called func: preprocess_hostOS_OS_vm
    :param parser: is a dict, get from Test config file
    """
    if not FTVM.is_login(parser["vm_name"], parser["TA_ip"],
                         parser["TA_msg_sock_port"],
                         int(parser["pre_hostOS_VM_login_time"])):
        raise TA_error.Preprocess_Error("PrimaryOS %s is not login" %
                                        parser["vm_name"])