本文整理汇总了Python中zstackwoodpecker.test_lib.lib_get_ha_enable函数的典型用法代码示例。如果您正苦于以下问题:Python lib_get_ha_enable函数的具体用法?Python lib_get_ha_enable怎么用?Python lib_get_ha_enable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了lib_get_ha_enable函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test
def test():
global vm, host3_uuid
if test_lib.lib_get_ha_enable() != 'true':
test_util.test_skip("vm ha not enabled. Skip test")
conf_ops.change_global_config('ha', 'allow.slibing.cross.clusters', 'true')
vm_creation_option = test_util.VmOption()
image_name = os.environ.get('imageName_s')
image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
#l3_name = os.environ.get('l3NoVlanNetworkName1')
#l3_name = os.environ.get('l3VlanNetworkName1')
l3_name = os.environ.get('l3PublicNetworkName')
host3_name = os.environ.get('hostName3')
host4_name = os.environ.get('hostName4')
conditions1 = res_ops.gen_query_conditions('name', '=', host3_name)
host3_uuid = res_ops.query_resource(res_ops.HOST, conditions1)[0].uuid
host3_ip = res_ops.query_resource(res_ops.HOST, conditions1)[0].managementIp
conditions2 = res_ops.gen_query_conditions('name', '=', host4_name)
host4_uuid = res_ops.query_resource(res_ops.HOST, conditions2)[0].uuid
host4_ip = res_ops.query_resource(res_ops.HOST, conditions2)[0].managementIp
l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
conditions = res_ops.gen_query_conditions('type', '=', 'UserVm')
instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid
vm_creation_option.set_l3_uuids([l3_net_uuid])
vm_creation_option.set_image_uuid(image_uuid)
vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
vm_creation_option.set_name('multihost_basic_vm')
vm_creation_option.set_host_uuid(host3_uuid)
vm = test_vm_header.ZstackTestVm()
vm.set_creation_option(vm_creation_option)
vm.create()
time.sleep(30)
ha_ops.set_vm_instance_ha_level(vm.get_vm().uuid, "NeverStop")
time.sleep(5)
vm.check()
ssh_cmd1 = 'ssh -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % host3_ip
cmd = '%s "poweroff" ' % ssh_cmd1
process_result = test_stub.execute_shell_in_process(cmd, tmp_file)
time.sleep(360)
host3_status = res_ops.query_resource(res_ops.HOST, conditions1)[0].status
if host3_status == "Disconnected":
conditions3 = res_ops.gen_query_conditions('uuid', '=', vm.vm.uuid)
vm_status = res_ops.query_resource(res_ops.VM_INSTANCE, conditions3)[0].state
vm_host_uuid = res_ops.query_resource(res_ops.VM_INSTANCE, conditions3)[0].hostUuid
if vm_status != "Running" or vm_host_uuid != host4_uuid:
test_util.test_fail('Test fail vm status: %s, vm_host_uuid: %s,' %(vm_status, vm_host_uuid))
vm.destroy()
conf_ops.change_global_config('ha', 'allow.slibing.cross.clusters', 'false')
conditions4 = res_ops.gen_query_conditions('vmNics.ip', '=', host3_ip)
vm3_uuid = sce_ops.query_resource(zstack_management_ip, res_ops.VM_INSTANCE, conditions4).inventories[0].uuid
sce_ops.start_vm(zstack_management_ip, vm3_uuid)
test_util.test_pass('VM auto ha across cluster Test Success')
示例2: test
def test():
global session_uuid
session_uuid = acc_ops.login_as_admin()
l3_1_name = os.environ.get('l3VlanNetworkName1')
l3_1 = test_lib.lib_get_l3_by_name(l3_1_name)
#create VRs.
vrs = test_lib.lib_find_vr_by_l3_uuid(l3_1.uuid)
if not vrs:
vm = test_stub.create_vlan_vm(l3_name=l3_1_name)
vm.destroy()
vr1 = test_lib.lib_find_vr_by_l3_uuid(l3_1.uuid)[0]
else:
vr1 = vrs[0]
vm_ops.stop_vm(vr1.uuid)
if test_lib.lib_get_ha_enable() != 'true' or vr1.applianceVmType != "vrouter":
vm_ops.start_vm(vr1.uuid)
vr1_mgmt_ip = test_lib.lib_find_vr_mgmt_ip(vr1)
if not test_lib.lib_wait_target_up(vr1_mgmt_ip, '7272', 120):
test_util.test_fail('vr: %s is not startup in 120 seconds. Fail to reboot it. ' % vr1.uuid)
timeout = time.time() + 60
while time.time() < timeout:
cond = res_ops.gen_query_conditions('uuid', '=', vr1.uuid)
vms = res_ops.query_resource(res_ops.VM_INSTANCE, cond)
if vms[0].status == 'Connected':
test_util.test_pass('Test Reconnect VR VM start VRs success')
time.sleep(1)
test_util.test_fail('VR VM: %s is not connected within 60 seconds' % vr1.uuid)
示例3: test
def test():
global vm
global host_uuid
global host_ip
global max_attempts
global storagechecker_timeout
allow_ps_list = [inventory.NFS_PRIMARY_STORAGE_TYPE]
test_lib.skip_test_when_ps_type_not_in_list(allow_ps_list)
test_stub.skip_if_not_storage_network_separate(test_lib.all_scenario_config)
if test_lib.lib_get_ha_enable() != 'true':
test_util.test_skip("vm ha not enabled. Skip test")
vm_creation_option = test_util.VmOption()
image_name = os.environ.get('imageName_net')
image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
l3_name = os.environ.get('l3VlanNetworkName1')
l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
test_lib.clean_up_all_vr()
mn_ip = res_ops.query_resource(res_ops.MANAGEMENT_NODE)[0].hostName
conditions = res_ops.gen_query_conditions('type', '=', 'UserVm')
instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid
conditions = res_ops.gen_query_conditions('state', '=', 'Enabled')
conditions = res_ops.gen_query_conditions('status', '=', 'Connected', conditions)
conditions = res_ops.gen_query_conditions('managementIp', '!=', mn_ip, conditions)
host_uuid = res_ops.query_resource(res_ops.HOST, conditions)[0].uuid
vm_creation_option.set_host_uuid(host_uuid)
vm_creation_option.set_l3_uuids([l3_net_uuid])
vm_creation_option.set_image_uuid(image_uuid)
vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
vm_creation_option.set_name('multihost_basic_vm')
vm = test_vm_header.ZstackTestVm()
vm.set_creation_option(vm_creation_option)
vm.create()
vr_hosts = test_stub.get_host_has_vr()
mn_hosts = test_stub.get_host_has_mn()
nfs_hosts = test_stub.get_host_has_nfs()
if not test_stub.ensure_vm_not_on(vm.get_vm().uuid, vm.get_vm().hostUuid, vr_hosts+mn_hosts+nfs_hosts):
test_util.test_fail("Not find out a suitable host")
#vm.check()
host_ip = test_lib.lib_find_host_by_vm(vm.get_vm()).managementIp
test_util.test_logger("host %s is disconnecting" %(host_ip))
ha_ops.set_vm_instance_ha_level(vm.get_vm().uuid, "NeverStop")
#test_stub.down_host_network(host_ip, test_lib.all_scenario_config)
host_username = os.environ.get('hostUsername')
host_password = os.environ.get('hostPassword')
t = test_stub.async_exec_ifconfig_nic_down_up(1200, host_ip, host_username, host_password, "zsn1")
vm.destroy()
test_util.test_pass('Test VM ha change to running within 300s Success')
示例4: test
def test():
global vm
global test_host
global ps_uuid
global host_ip
global max_attempts
global storagechecker_timeout
allow_ps_list = [inventory.LOCAL_STORAGE_TYPE]
test_lib.skip_test_when_ps_type_not_in_list(allow_ps_list)
if test_lib.lib_get_ha_enable() != 'true':
test_util.test_skip("vm ha not enabled. Skip test")
vm_creation_option = test_util.VmOption()
image_name = os.environ.get('imageName_net')
image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
l3_name = os.environ.get('l3VlanNetworkName1')
l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
test_lib.clean_up_all_vr()
conditions = res_ops.gen_query_conditions('type', '=', 'UserVm')
instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid
vm_creation_option.set_l3_uuids([l3_net_uuid])
vm_creation_option.set_image_uuid(image_uuid)
vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
vm_creation_option.set_name('ls_vm_ha_self_start')
vm = test_vm_header.ZstackTestVm()
vm.set_creation_option(vm_creation_option)
vm.create()
ha_ops.set_vm_instance_ha_level(vm.get_vm().uuid, "NeverStop")
ps = test_lib.lib_get_primary_storage_by_vm(vm.get_vm())
ps_uuid = ps.uuid
ps_ops.change_primary_storage_state(ps_uuid, 'maintain')
if not test_lib.lib_wait_target_down(vm.get_vm().vmNics[0].ip, '22', 90):
test_util.test_fail('VM is expected to stop when PS change to maintain state')
vm.set_state(vm_header.STOPPED)
vm.check()
ps_ops.change_primary_storage_state(ps_uuid, 'enable')
for i in range(0, 300):
if res_ops.query_resource(res_ops.VM_INSTANCE, conditions)[0].state == "Running":
break
time.sleep(1)
else:
test_util.test_fail("vm has not been changed to running as expected within 300s.")
vm.destroy()
test_util.test_pass('Test checking VM ha and none status when force stop vm Success.')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:56,代码来源:test_ls_vm_ha_ps_maintain_recover_vm_self_start.py
示例5: test
def test():
global vm
global host_uuid
global host_ip
global max_attempts
global storagechecker_timeout
must_ps_list = ['MiniStorage']
test_lib.skip_test_if_any_ps_not_deployed(must_ps_list)
test_stub.skip_if_not_storage_network_separate(test_lib.all_scenario_config)
if test_lib.lib_get_ha_enable() != 'true':
test_util.test_skip("vm ha not enabled. Skip test")
vm_creation_option = test_util.VmOption()
#image_name = os.environ.get('imageName_net')
image_uuid = test_lib.lib_get_image_by_name("ttylinux").uuid
l3_name = os.environ.get('l3VlanNetworkName1')
l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
test_lib.clean_up_all_vr()
mn_ip = res_ops.query_resource(res_ops.MANAGEMENT_NODE)[0].hostName
conditions = res_ops.gen_query_conditions('type', '=', 'UserVm')
instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid
conditions = res_ops.gen_query_conditions('state', '=', 'Enabled')
conditions = res_ops.gen_query_conditions('status', '=', 'Connected', conditions)
#conditions = res_ops.gen_query_conditions('managementIp', '!=', mn_ip, conditions)
host_uuid = res_ops.query_resource(res_ops.HOST, conditions)[0].uuid
vm_creation_option.set_host_uuid(host_uuid)
vm_creation_option.set_l3_uuids([l3_net_uuid])
vm_creation_option.set_image_uuid(image_uuid)
vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
vm_creation_option.set_name('multihost_basic_vm')
vm = test_vm_header.ZstackTestVm()
vm.set_creation_option(vm_creation_option)
vm.create()
#vm.check()
host_ip = test_lib.lib_find_host_by_vm(vm.get_vm()).managementIp
test_util.test_logger("host %s is disconnecting" %(host_ip))
ha_ops.set_vm_instance_ha_level(vm.get_vm().uuid, "NeverStop")
test_stub.down_host_network(host_ip, test_lib.all_scenario_config, "managment_net")
if test_stub.check_vm_running_on_host(vm.vm.uuid, host_ip):
test_util.test_fail("VM is expected to start running on another host")
vm.set_state(vm_header.RUNNING)
vm.check()
vm.destroy()
test_stub.up_host_network(host_ip, test_lib.all_scenario_config, "managment_net")
test_util.test_pass('Test Success')
示例6: test
def test():
global vm
if test_lib.lib_get_ha_enable() != 'true':
test_util.test_skip("vm ha not enabled. Skip test")
vm = test_stub.create_vm()
vm.check()
ha_ops.set_vm_instance_ha_level(vm.get_vm().uuid, "OnHostFailure")
rsp = test_lib.lib_execute_ssh_cmd(vm.get_vm().vmNics[0].ip, test_lib.lib_get_vm_username(vm.get_vm()), test_lib.lib_get_vm_password(vm.get_vm()), 'init 0')
time.sleep(60)
vm.check()
vm.destroy()
vm.check()
test_util.test_pass('VM shutdown with ha mode OnHostFailure Test Success')
示例7: test
def test():
global vm
if test_lib.lib_get_ha_enable() != 'true':
test_util.test_skip("vm ha not enabled. Skip test")
vm = test_stub.create_vm()
vm.check()
ha_ops.set_vm_instance_ha_level(vm.get_vm().uuid, "OnHostFailure")
vm.stop()
time.sleep(60)
vm.check()
vm.destroy()
vm.check()
test_util.test_pass('VM stop with ha mode OnHostFailure Test Success')
示例8: test
def test():
global vm
if test_lib.lib_get_ha_enable() != 'true':
test_util.test_skip("vm ha not enabled. Skip test")
vm = test_stub.create_vm()
vm.check()
ha_ops.set_vm_instance_ha_level(vm.get_vm().uuid, "NeverStop")
vm.stop()
time.sleep(60)
vm.set_state(vm_header.RUNNING)
vm.check()
vm.destroy()
vm.check()
test_util.test_pass('VM ha never stop Test Success')
示例9: test
def test():
global vm
if test_lib.lib_get_ha_enable() != 'true':
test_util.test_skip("vm ha not enabled. Skip test")
vm = test_stub.create_vm()
vm.check()
ha_ops.set_vm_instance_ha_level(vm.get_vm().uuid, "NeverStop")
rsp = test_lib.lib_execute_ssh_cmd(vm.get_vm().vmNics[0].ip, test_lib.lib_get_vm_username(vm.get_vm()), test_lib.lib_get_vm_password(vm.get_vm()), 'init 0')
time.sleep(60)
vm.set_state(vm_header.RUNNING)
vm.check()
vm.destroy()
vm.check()
test_util.test_pass('VM ha never stop Test Success')
示例10: test
def test():
global vm
if test_lib.lib_get_ha_enable() != 'true':
test_util.test_skip("vm ha not enabled. Skip test")
vm = test_stub.create_vm()
vm.check()
host_uuid = test_lib.lib_find_host_by_vm(vm.get_vm()).uuid
host_ops.change_host_state(host_uuid, "disable")
time.sleep(10)
ha_ops.set_vm_instance_ha_level(vm.get_vm().uuid, "NeverStop")
vm.stop()
time.sleep(60)
vm.check()
vm.destroy()
vm.check()
host_ops.change_host_state(host_uuid, "enable")
test_util.test_pass('VM ha never stop Test Success')
示例11: test
def test():
global vm
if test_lib.lib_get_ha_enable() != 'true':
test_util.test_skip("vm ha not enabled. Skip test")
delete_policy = test_lib.lib_get_delete_policy('vm')
vm = test_stub.create_vm()
vm.set_delete_policy('Delay')
vm.check()
vm.destroy()
ha_ops.set_vm_instance_ha_level(vm.get_vm().uuid, "NeverStop")
vm.recover()
time.sleep(60)
vm.set_state(vm_header.RUNNING)
vm.check()
vm.destroy()
vm.set_delete_policy(delete_policy)
test_util.test_pass('VM ha never stop auto start with recover Test Success')
示例12: test
def test():
test_util.test_dsc('Create test vm1 and check')
if test_lib.lib_get_ha_enable() != 'true':
test_util.test_skip("vm ha not enabled. Skip test")
vm1 = test_stub.create_vlan_vm()
test_obj_dict.add_vm(vm1)
vm1.check()
vrs = test_lib.lib_find_vr_by_vm(vm1.vm)
for vr in vrs:
if vr.applianceVmType != "vrouter":
continue
if ha_ops.get_vm_instance_ha_level(vr.uuid) != "NeverStop":
test_util.test_fail('vr: %s is not set to HA mode NeverStop.' % vr.uuid)
vm1.destroy()
test_util.test_pass('Check VR HA mode Success')
示例13: test
def test():
global vm
global host_uuid
global host_ip
global max_attempts
global storagechecker_timeout
must_ps_list = [inventory.LOCAL_STORAGE_TYPE, 'SharedMountPoint']
test_lib.skip_test_if_any_ps_not_deployed(must_ps_list)
if test_lib.lib_get_ha_enable() != 'true':
test_util.test_skip("vm ha not enabled. Skip test")
vm_creation_option = test_util.VmOption()
image_name = os.environ.get('imageName_net')
image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
l3_name = os.environ.get('l3VlanNetworkName1')
l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
test_lib.clean_up_all_vr()
#vrs = test_lib.lib_find_vr_by_l3_uuid(l3_net_uuid)
#vr_host_ips = []
#for vr in vrs:
# vr_host_ips.append(test_lib.lib_find_host_by_vr(vr).managementIp)
# if test_lib.lib_is_vm_running(vr) != True:
# vm_ops.start_vm(vr.uuid)
#time.sleep(60)
mn_ip = res_ops.query_resource(res_ops.MANAGEMENT_NODE)[0].hostName
conditions = res_ops.gen_query_conditions('type', '=', 'UserVm')
instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid
conditions = res_ops.gen_query_conditions('state', '=', 'Enabled')
conditions = res_ops.gen_query_conditions('status', '=', 'Connected', conditions)
conditions = res_ops.gen_query_conditions('managementIp', '!=', mn_ip, conditions)
#for vr_host_ip in vr_host_ips:
# conditions = res_ops.gen_query_conditions('managementIp', '!=', vr_host_ip, conditions)
host_uuid = res_ops.query_resource(res_ops.HOST, conditions)[0].uuid
vm_creation_option.set_host_uuid(host_uuid)
vm_creation_option.set_l3_uuids([l3_net_uuid])
vm_creation_option.set_image_uuid(image_uuid)
vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
vm_creation_option.set_name('ls_vm_none_status')
vm = test_vm_header.ZstackTestVm()
vm.set_creation_option(vm_creation_option)
vm.create()
vr_hosts = test_stub.get_host_has_vr()
mn_hosts = test_stub.get_host_has_mn()
nfs_hosts = test_stub.get_host_has_nfs()
if not test_stub.ensure_vm_not_on(vm.get_vm().uuid, vm.get_vm().hostUuid, vr_hosts+mn_hosts+nfs_hosts):
test_util.test_fail("Not find out a suitable host")
#vm.check()
host_ip = test_lib.lib_find_host_by_vm(vm.get_vm()).managementIp
test_util.test_logger("host %s is disconnecting" %(host_ip))
test_stub.down_host_network(host_ip, test_lib.all_scenario_config)
cond = res_ops.gen_query_conditions('name', '=', 'ls_vm_none_status')
cond = res_ops.gen_query_conditions('uuid', '=', vm.vm.uuid, cond)
for i in range(0, 300):
vm_stop_time = i
if res_ops.query_resource(res_ops.VM_INSTANCE, cond)[0].state == "Unknown":
test_stub.up_host_network(host_ip, test_lib.all_scenario_config)
time.sleep(1)
test_stub.recover_smp_nfs_server(host_ip)
conditions = res_ops.gen_query_conditions('managementIp', '=', host_ip)
kvm_host_uuid = res_ops.query_resource(res_ops.HOST, conditions)[0].uuid
host_ops.reconnect_host(kvm_host_uuid)
break
time.sleep(1)
if vm_stop_time is None:
vm_stop_time = 300
for i in range(vm_stop_time, 300):
if res_ops.query_resource(res_ops.VM_INSTANCE, cond)[0].state == "Running":
break
time.sleep(1)
else:
test_util.test_fail("vm has not been changed to running as expected within 300s.")
vm.destroy()
test_util.test_pass('Test VM none change to Stopped within 300s Success')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:85,代码来源:test_smp_ls_vm_none_net_discon_connect_vm_status.py
示例14: test
def test():
global vm
global host_uuid
global test_host
global host_ip
global max_attempts
global storagechecker_timeout
allow_ps_list = [inventory.LOCAL_STORAGE_TYPE]
test_lib.skip_test_when_ps_type_not_in_list(allow_ps_list)
if test_lib.lib_get_ha_enable() != 'true':
test_util.test_skip("vm ha not enabled. Skip test")
vm_creation_option = test_util.VmOption()
image_name = os.environ.get('imageName_net')
image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
l3_name = os.environ.get('l3VlanNetworkName1')
l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
test_lib.clean_up_all_vr()
#vrs = test_lib.lib_find_vr_by_l3_uuid(l3_net_uuid)
#vr_host_ips = []
#for vr in vrs:
# vr_host_ips.append(test_lib.lib_find_host_by_vr(vr).managementIp)
# if test_lib.lib_is_vm_running(vr) != True:
# vm_ops.start_vm(vr.uuid)
#time.sleep(60)
mn_ip = res_ops.query_resource(res_ops.MANAGEMENT_NODE)[0].hostName
conditions = res_ops.gen_query_conditions('type', '=', 'UserVm')
instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid
conditions = res_ops.gen_query_conditions('state', '=', 'Enabled')
conditions = res_ops.gen_query_conditions('status', '=', 'Connected', conditions)
conditions = res_ops.gen_query_conditions('managementIp', '!=', mn_ip, conditions)
#for vr_host_ip in vr_host_ips:
# conditions = res_ops.gen_query_conditions('managementIp', '!=', vr_host_ip, conditions)
host_uuid = res_ops.query_resource(res_ops.HOST, conditions)[0].uuid
vm_creation_option.set_host_uuid(host_uuid)
vm_creation_option.set_l3_uuids([l3_net_uuid])
vm_creation_option.set_image_uuid(image_uuid)
vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
vm_creation_option.set_name('ls_vm_none_status')
vm2 = test_vm_header.ZstackTestVm()
vm2.set_creation_option(vm_creation_option)
vm2.create()
test_stub.ensure_host_has_no_vr(host_uuid)
#vm.check()
host_ip = test_lib.lib_find_host_by_vm(vm2.get_vm()).managementIp
test_util.test_logger("host %s is disconnecting" %(host_ip))
host_list = test_stub.get_sce_hosts(test_lib.all_scenario_config, test_lib.scenario_file)
for host in host_list:
if host.ip_ == host_ip:
test_host = host
break
if not test_host:
test_util.test_fail('there is no host with ip %s in scenario file.' %(host_ip))
test_stub.stop_host(test_host, test_lib.all_scenario_config, 'cold')
cond = res_ops.gen_query_conditions('name', '=', 'ls_vm_none_status')
cond = res_ops.gen_query_conditions('uuid', '=', vm2.vm.uuid, cond)
vm_stop_time = None
for i in range(0, 300):
vm_stop_time = i
if res_ops.query_resource(res_ops.VM_INSTANCE, cond)[0].state == "Unknown":
test_stub.start_host(test_host, test_lib.all_scenario_config)
test_stub.recover_host_vlan(test_host, test_lib.all_scenario_config, test_lib.deploy_config)
break
time.sleep(1)
if vm_stop_time is None:
vm_stop_time = 300
for i in range(vm_stop_time, 300):
if res_ops.query_resource(res_ops.VM_INSTANCE, cond)[0].state == "Stopped":
break
time.sleep(1)
else:
test_util.test_fail("vm none is not change to Stopped as expected within 300s.")
test_util.test_pass('Test checking vm none status when host has been force stop Success.')
示例15: test
def test():
global vm
global host_uuid
global host_ip
global max_attempts
global storagechecker_timeout
if test_lib.lib_get_ha_enable() != 'true':
test_util.test_skip("vm ha not enabled. Skip test")
max_attempts = test_lib.lib_get_ha_selffencer_maxattempts()
test_lib.lib_set_ha_selffencer_maxattempts('12')
storagechecker_timeout = test_lib.lib_get_ha_selffencer_storagechecker_timeout()
test_lib.lib_set_ha_selffencer_storagechecker_timeout('15')
vm_creation_option = test_util.VmOption()
image_name = os.environ.get('imageName_s')
image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
#l3_name = os.environ.get('l3NoVlanNetworkName1')
l3_name = os.environ.get('l3VlanNetworkName1')
l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
vrs = test_lib.lib_find_vr_by_l3_uuid(l3_net_uuid)
for vr in vrs:
if test_lib.lib_is_vm_running(vr) == True:
vm_ops.start_vm(vr.uuid)
time.sleep(60)
conditions = res_ops.gen_query_conditions('type', '=', 'UserVm')
instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid
conditions = res_ops.gen_query_conditions('state', '=', 'Enabled')
conditions = res_ops.gen_query_conditions('status', '=', 'Connected', conditions)
conditions = res_ops.gen_query_conditions('managementIp', '!=', os.environ.get('hostIp'), conditions)
host_uuid = res_ops.query_resource(res_ops.HOST, conditions)[0].uuid
vm_creation_option.set_host_uuid(host_uuid)
vm_creation_option.set_l3_uuids([l3_net_uuid])
vm_creation_option.set_image_uuid(image_uuid)
vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
vm_creation_option.set_name('multihost_basic_vm')
vm = test_vm_header.ZstackTestVm()
vm.set_creation_option(vm_creation_option)
vm.create()
#vm.check()
host_ip = test_lib.lib_find_host_by_vm(vm.get_vm()).managementIp
host_uuid = test_lib.lib_find_host_by_vm(vm.get_vm()).uuid
ha_ops.set_vm_instance_ha_level(vm.get_vm().uuid, "OnHostFailure")
l2_network_interface = os.environ.get('l2ManagementNetworkInterface')
cmd = "ifdown %s && sleep 30 && ifup %s" % (l2_network_interface, l2_network_interface)
try:
rsp = test_lib.lib_execute_sh_cmd_by_agent(host_ip, cmd)
test_util.test_logger("host is not expected to shutdown after its network down just for a little while")
except:
test_util.test_fail("host may have been shutdown, while it's not expected to shutdown")
cmd = "date"
try:
rsp = test_lib.lib_execute_sh_cmd_by_agent(host_ip, cmd)
test_util.test_logger("host is still alive")
except:
test_util.test_fail("host is not expected to shutdown after its network down just for a little while")
vm.destroy()
test_lib.lib_set_ha_selffencer_maxattempts(max_attempts)
test_lib.lib_set_ha_selffencer_storagechecker_timeout(storagechecker_timeout)
time.sleep(60)
test_util.test_pass('Test Host Self fence Success')