Esempio n. 1
0
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()
Esempio n. 2
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()
Esempio n. 3
0
def vm_shudown_in_hostOS(parser):
	"""
	vm is running in hostOS or not

	return True/raise exception
	"""
	if FTVM.is_shutoff(parser["vm_name"], parser["HostOS_ip"]):
		return True
	raise TA_error.Assert_Error("VM (name : %s) is not shutdown on hostOS" % parser["vm_name"])
Esempio n. 4
0
def postprocess_hostOS_vm_running(parser):
	"""
	postrocess vm become running
	"""
	if FTVM.is_running(parser["vm_name"], parser["HostOS_ip"]):
		FTVM.restart(parser["vm_name"], parser["HostOS_ip"])
	elif FTVM.is_shutoff(parser["vm_name"], parser["HostOS_ip"]):
		FTVM.start(parser["vm_name"], parser["HostOS_ip"])
	time.sleep(float(parser["pos_hostOS_VM_boot_time"]))
	if not FTVM.is_running(parser["vm_name"], parser["HostOS_ip"]):
		raise TA_error.Postprocess_Error("HostOS %s can not start" % parser["vm_name"])
Esempio n. 5
0
def postprocess_backupOS_vm_shutdown(parser):
	"""
	postprocess backupOS vm shutdown
	"""
	if FTVM.is_running(parser["vm_name"], parser["backupOS_ip"]):
		FTVM.shutdown(parser["vm_name"], parser["backupOS_ip"])
	elif FTVM.is_paused(parser["vm_name"], parser["backupOS_ip"]):
		FTVM.resume(parser["vm_name"], parser["backupOS_ip"])
		FTVM.shutdown(parser["vm_name"], parser["backupOS_ip"])
	time.sleep(float(parser["pos_backupOS_VM_shutdown_time"]))
	if not FTVM.is_shutoff(parser["vm_name"], parser["backupOS_ip"]):
		raise TA_error.Postprocess_Error("backupOS %s can not shutdown" % parser["vm_name"])
Esempio n. 6
0
def preprocess_hostOS_vm_shutdown(parser):
    """
  preprocess hostOS vm become shutdown
  """
    if FTVM.is_running(parser["vm_name"], parser["HostOS_ip"]):
        FTVM.shutdown(parser["vm_name"], parser["HostOS_ip"])
        time.sleep(float(parser["pre_hostOS_VM_shutdown_time"]))
    elif FTVM.is_paused(parser["vm_name"], parser["HostOS_ip"]):
        FTVM.resume(parser["vm_name"], parser["HostOS_ip"])
        FTVM.shutdown(parser["vm_name"], parser["HostOS_ip"])
        time.sleep(float(parser["pre_hostOS_VM_shutdown_time"]))
    if not FTVM.is_shutoff(parser["vm_name"], parser["HostOS_ip"]):
        raise TA_error.Preprocess_Error("HostOS %s can not shutdown" % parser["vm_name"])
Esempio n. 7
0
def vm_shudown_in_SlaveOS(parser):
    """
	vm is running in SlaveOS or not
	:param parser: config
	:return: True/raise exception
	"""
    ssh = shell_server.get_ssh(parser["SlaveOS_ip"], parser["SlaveOS_usr"],
                               parser["SlaveOS_pwd"])  #獲得ssh
    if FTVM.is_shutoff(parser["vm_name"], parser["SlaveOS_ip"],
                       ssh):  #若回傳之狀態是shut off,則test oracle通過,否則raise exception
        return True
    raise TA_error.Assert_Error("VM (name : %s) is not shutdown in SlaveOS" %
                                parser["vm_name"])
Esempio n. 8
0
def detect_rm_non_running_ftvm(parser):
    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):
        raise TA_error.Assert_Error("VM : %s running in PrimaryOS" %
                                    parser["vm_name"])
    if FTVM.is_shutoff(parser["vm_name"], parser["PrimaryOS_ip"], ssh):
        out = HAagent.remove_ftvm(parser["vm_name"], parser, ssh)
        expected = HAagent_terminal.Vm_not_exist

        success = (out == expected)
        if success:
            return True
        raise TA_error.Assert_Error("rm non running vm fail")
Esempio n. 9
0
def non_primary_start_ftvm(parser):
    """
	check non primary node(backup node) can start ftvm or not
	:param parser: config
	:return: True/raise exception
	"""
    ssh = shell_server.get_ssh(parser["BackupOS_ip"], parser["BackupOS_usr"],
                               parser["BackupOS_pwd"])  #獲得ssh
    if FTVM.is_running(parser["vm_name"], parser["BackupOS_ip"], ssh):
        raise TA_error.Assert_Error("VM : %s already in running" %
                                    parser["vm_name"])
    if FTVM.is_shutoff(parser["vm_name"], parser["BackupOS_ip"], ssh):
        out = FTVM.ftstart(parser["BackupOS_name"], parser["vm_name"],
                           parser["BackupOS_ip"], ssh)
        expected = HAagent_terminal.Not_primary

        success = (out == expected) and FTVM.is_shutoff(
            parser["vm_name"], parser["BackupOS_ip"],
            ssh)  # shell message and FTVM shutoff
        if success:
            return True
    raise TA_error.Assert_Error("non primary start ftvm : %s fail" %
                                parser["vm_name"])
Esempio n. 10
0
def postprocess_Host_OS_reboot(parser):
    """
	post process host os part
	: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 not FTVM.is_shutoff(parser["vm_name"], parser["PrimaryOS_ip"], ssh):
        raise TA_error.Postprocess_Error(
            "vm %s in PrimaryOS cannot shutdown " % parser["vm_name"])
    if parser["pos_hostOS_restart"] == "yes":
        if FTOS.OS_is_running(parser["PrimaryOS_ip"], parser):
            FTOS.reboot(ssh)
Esempio n. 11
0
def postprocess_backupOS_vm_running(parser):
    """
	postrocess vm become running

	:called func: postprocess_BackupOS_vm
	:param parser: is a dict, get from Test config file
	"""
    ssh = shell_server.get_ssh(parser["BackupOS_ip"], parser["BackupOS_usr"],
                               parser["BackupOS_pwd"])  #獲得ssh
    if FTVM.is_running(parser["vm_name"], parser["BackupOS_ip"], ssh):
        FTVM.restart(parser["vm_name"], parser["BackupOS_ip"], ssh)
    elif FTVM.is_shutoff(parser["vm_name"], parser["BackupOS_ip"], ssh):
        FTVM.start(parser["vm_name"], parser["BackupOS_ip"], ssh)
    time.sleep(float(parser["pos_BackupOS_VM_boot_time"]))
    if not FTVM.is_running(parser["vm_name"], parser["BackupOS_ip"], ssh):
        ssh.close()
        raise TA_error.Postprocess_Error("BackupOS vm : %s can not start" %
                                         parser["vm_name"])
    ssh.close()
Esempio n. 12
0
def postprocess_slaveOS_vm_running(parser):
    """
	Slave OS vm become running
	"""
    ssh = shell_server.get_ssh(parser["SlaveOS_ip"], parser["SlaveOS_usr"],
                               parser["SlaveOS_pwd"])

    if FTVM.is_running(parser["vm_name"], parser["SlaveOS_ip"], ssh):
        print 59
    elif FTVM.is_shutoff(parser["vm_name"], parser["SlaveOS_ip"], ssh):
        print 56
        postprocess_slaveOS_vm_start(parser)
        print 57
        time.sleep(float(parser["pos_slaveOS_VM_boot_time"]))
    if not FTVM.is_running(parser["vm_name"], parser["SlaveOS_ip"], ssh):
        ssh.close()
        raise TA_error.Postprocess_Error("SlaveOS VM: %s can not start" %
                                         parser["vm_name"])
    ssh.close()
Esempio n. 13
0
def rm_non_running_ftvm(parser):
    """
	detect remove non running ftvm
	:param parser: config
	:return: True/raise exception
	"""
    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):
        raise TA_error.Assert_Error("VM : %s already in running" %
                                    parser["vm_name"])
    if FTVM.is_shutoff(parser["vm_name"], parser["PrimaryOS_ip"], ssh):
        out = FTVM.ftshutdown(parser["vm_name"], parser["PrimaryOS_ip"], ssh)
        expected = HAagent_terminal.Vm_not_exist

        success = (out == expected)
        if success:
            return True
    raise TA_error.Assert_Error("remove non running ftvm : %s fail" %
                                parser["vm_name"])
Esempio n. 14
0
def non_primary_rm_ftvm(parser):
    """
	detect non primary remove ftvm
	:param parser: config
	:return: True/raise exception
	"""
    ssh = shell_server.get_ssh(parser["BackupOS_ip"], parser["BackupOS_usr"],
                               parser["BackupOS_pwd"])  #獲得ssh
    if FTVM.is_shutoff(parser["vm_name"], parser["BackupOS_ip"], ssh):
        raise TA_error.Assert_Error("VM : %s shutoff" % parser["vm_name"])
    if FTVM.is_running(parser["vm_name"], parser["BackupOS_ip"], ssh):
        out = FTVM.ftshutdown(parser["vm_name"], parser["BackupOS_ip"], ssh)
        expected = HAagent_terminal.Not_primary

        success = (out == expected) and FTVM.is_running(
            parser["vm_name"], parser["BackupOS_ip"],
            ssh)  #shell message and FTVM running
        if success:
            return True
    raise TA_error.Assert_Error("remove non running ftvm : %s fail" %
                                parser["vm_name"])
Esempio n. 15
0
def preprocess_slaveOS_vm_shutdown(parser):
    """
    preprocess backupOS vm become shutdown

    :called func: preprocess_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["pre_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["pre_slaveOS_VM_shutdown_time"]))
    if not FTVM.is_shutoff(parser["vm_name"], parser["SlaveOS_ip"], ssh):
        ssh.close()
        raise TA_error.Preprocess_Error("SlaveOS %s can not shutdown" %
                                        parser["vm_name"])
    ssh.close()
Esempio n. 16
0
def preprocess_slaveOS_vm_running(parser):
    """
    preprocess vm become running

    :called func: preprocess_slaveOS_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):
        pass
        print 59
    elif FTVM.is_shutoff(parser["vm_name"], parser["SlaveOS_ip"], ssh):
        print 56
        prepocess_slaveOS_vm_start(parser)
        print 57
        time.sleep(float(parser["pre_slaveOS_VM_boot_time"]))
    print 58
    if not FTVM.is_running(parser["vm_name"], parser["SlaveOS_ip"], ssh):
        ssh.close()
        raise TA_error.Preprocess_Error("SlaveOS VM: %s can not start" %
                                        parser["vm_name"])
    ssh.close()
Esempio n. 17
0
def vm_duplicate_start(parser):
    """
	check vm can duplicate start 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 FTVM.is_shutoff(parser["vm_name"], parser["PrimaryOS_ip"], ssh):
        raise TA_error.Assert_Error("VM name : %s is shut off in PrimaryOS")
    if FTVM.is_running(parser["vm_name"], parser["PrimaryOS_ip"], ssh):

        out = FTVM.duplicate_ftstart(parser["PrimaryOS_name"],
                                     parser["vm_name"], parser["PrimaryOS_ip"],
                                     ssh)
        expected = HAagent_terminal.Startvm_addVM_failed % (
            HAagent_terminal.Vm_has_exist)
        success = (out == expected)

        if success:
            return True
        raise TA_error.Assert_Error("vm : %s duplicate start fail" %
                                    parser["vm_name"])