def test(): global vms 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('l3PublicNetworkName') l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid cpuNum = 5 #cpuSpeed = 16 #memorySize = 536870912 memorySize = 134217728 name = 'vm-offering-allocator-strategy' new_offering_option = test_util.InstanceOfferingOption() new_offering_option.set_cpuNum(cpuNum) #new_offering_option.set_cpuSpeed(cpuSpeed) new_offering_option.set_memorySize(memorySize) new_offering_option.set_name(name) new_offering = vm_ops.create_instance_offering(new_offering_option) test_obj_dict.add_instance_offering(new_offering) #conditions = res_ops.gen_query_conditions('type', '=', 'UserVm') #instance_offering_inv = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0] #instance_offering_uuid = instance_offering_inv.uuid instance_offering_uuid = new_offering.uuid each_vm_cpu_consume = cpuNum vm_creation_option = test_util.VmOption() 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) #create different cpu usage of hosts scenario prepare_host_with_different_cpu_scenario() #Notice here we are using the same network for both parallel vm and precondition #In this way, we don't need to care about the cpu cost for newly created vr. #If must compute vr we need to check vr existed in l3 network: #vrs = test_lib.lib_find_vr_by_l3_uuid(l3_1.uuid) ps_uuid = res_ops.query_resource(res_ops.PRIMARY_STORAGE)[0].uuid vm_num = compute_total_vm_num_based_on_ps(ps_uuid, each_vm_cpu_consume) #trigger vm create for i in range(vm_num): t = threading.Thread(target=create_vm_wrapper, args=(i, vm_creation_option)) ts.append(t) t.start() for t in ts: t.join() check_threads_exception() #clean the prepare scenario clean_host_with_different_cpu_scenario() clean_parallel_created_vm() test_util.test_pass('Create VM Test Success')
def create_vm_offering(vm_ip, tmp_file): vmoffering_option = test_util.InstanceOfferingOption() vmoffering_option.name = '1-1G' vmoffering_option.cpuNum = '1' vmoffering_option.memorySize = '1073741824' vmoffering_option.type = 'UserVm' vmoffering_inv = scen_ops.create_instance_offering1(vm_ip, vmoffering_option) return vmoffering_inv
def test(): global vms 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('l3PublicNetworkName') l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid cpuNum = 1 cpuSpeed = 8 memorySize = 536870912 name = 'vm-offering-allocator-strategy' new_offering_option = test_util.InstanceOfferingOption() new_offering_option.set_cpuNum(cpuNum) new_offering_option.set_cpuSpeed(cpuSpeed) new_offering_option.set_memorySize(memorySize) new_offering_option.set_name(name) new_offering = vm_ops.create_instance_offering(new_offering_option) test_obj_dict.add_instance_offering(new_offering) #conditions = res_ops.gen_query_conditions('type', '=', 'UserVm') #instance_offering_inv = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0] #instance_offering_uuid = instance_offering_inv.uuid instance_offering_uuid = new_offering.uuid each_vm_mem_consume = memorySize vm_creation_option = test_util.VmOption() 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) #create different mem usage of hosts scenario prepare_host_with_different_mem_scenario() ps_uuid = res_ops.query_resource(res_ops.PRIMARY_STORAGE)[0].uuid vm_num = compute_total_vm_num_based_on_ps(ps_uuid, each_vm_mem_consume) #trigger vm create for i in range(vm_num): t = threading.Thread(target=create_vm_wrapper, args=(i, vm_creation_option)) ts.append(t) t.start() for t in ts: t.join() check_threads_exception() #clean the prepare scenario clean_host_with_different_mem_scenario() clean_parallel_created_vm() test_util.test_pass('Create VM Test Success')
def prepare_host_with_different_cpu_scenario(): """ Prepare vms in hosts """ global pre_vms 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('l3PublicNetworkName') cpuNum = 6 cpuSpeed = 16 memorySize = 134217728 name = 'vm-offering-pre-cond' new_offering_option = test_util.InstanceOfferingOption() new_offering_option.set_cpuNum(cpuNum) new_offering_option.set_cpuSpeed(cpuSpeed) new_offering_option.set_memorySize(memorySize) new_offering_option.set_name(name) new_offering = vm_ops.create_instance_offering(new_offering_option) test_obj_dict.add_instance_offering(new_offering) instance_offering_uuid = new_offering.uuid l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).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) ps_uuid = res_ops.query_resource(res_ops.PRIMARY_STORAGE)[0].uuid hosts = test_lib.lib_find_hosts_by_ps_uuid(ps_uuid) host_id = 0 for host, max_vm_num in zip(hosts,[3,3,3,3]): host_id +=1 for i in range(max_vm_num): print "host_id=%s; i=%s" %(host_id, i) vm_creation_option.set_name('pre-create-vm-%s-%s' %(host_id, i)) vm = test_vm_header.ZstackTestVm() vm_creation_option.set_host_uuid(host.uuid) vm.set_creation_option(vm_creation_option) vm.create() pre_vms.append(vm)
def test(): global image global test_obj_dict allow_bs_list = [ inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE, inventory.CEPH_BACKUP_STORAGE_TYPE, inventory.SFTP_BACKUP_STORAGE_TYPE ] test_lib.skip_test_when_bs_type_not_in_list(allow_bs_list) allow_ps_list = [ inventory.CEPH_PRIMARY_STORAGE_TYPE, inventory.NFS_PRIMARY_STORAGE_TYPE, 'SharedMountPoint' ] test_lib.skip_test_when_ps_type_not_in_list(allow_ps_list) #run condition hosts = res_ops.query_resource(res_ops.HOST) if len(hosts) <= 1: test_util.test_skip( "skip for host_num is not satisfy condition host_num>1") bs_cond = res_ops.gen_query_conditions("status", '=', "Connected") bss = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE, bs_cond, None, fields=['uuid']) #create disk offering data_volume_size = 10737418240 disk_offering_option = test_util.DiskOfferingOption() disk_offering_option.set_name('root-disk-iso') disk_offering_option.set_diskSize(data_volume_size) data_volume_offering = vol_ops.create_volume_offering(disk_offering_option) test_obj_dict.add_disk_offering(data_volume_offering) #create instance offering cpuNum = 2 memorySize = 2147483648 name = 'iso-vm-offering' new_offering_option = test_util.InstanceOfferingOption() new_offering_option.set_cpuNum(cpuNum) new_offering_option.set_memorySize(memorySize) new_offering_option.set_name(name) new_offering = vm_ops.create_instance_offering(new_offering_option) test_obj_dict.add_instance_offering(new_offering) #add iso img_option = test_util.ImageOption() img_option.set_name('iso1') bs_uuid = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE, [], None)[0].uuid img_option.set_backup_storage_uuid_list([bs_uuid]) img_option.set_url( 'http://172.20.1.15:7480/iso/CentOS-x86_64-7.2-Minimal.iso') image_inv = img_ops.add_iso_template(img_option) image_uuid = image_inv.uuid image = test_image.ZstackTestImage() image.set_image(image_inv) image.set_creation_option(img_option) test_obj_dict.add_image(image) #create vm by iso l3_name = os.environ.get('l3VlanNetworkName1') l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid root_disk_uuid = data_volume_offering.uuid vm = test_stub.create_vm_with_iso([l3_net_uuid], image_uuid, 'iso-vm', root_disk_uuid, new_offering.uuid) host_ip = test_lib.lib_find_host_by_vm(vm.get_vm()).managementIp test_obj_dict.add_vm(vm) #check vm vm_inv = vm.get_vm() vm_ip = vm_inv.vmNics[0].ip #cmd ='[ -e /root ]' #ssh_timeout = test_lib.SSH_TIMEOUT #test_lib.SSH_TIMEOUT = 3600 test_lib.lib_set_vm_host_l2_ip(vm_inv) test_lib.lib_wait_target_up(vm.get_vm().vmNics[0].ip, 22, 1800) #if not test_lib.lib_ssh_vm_cmd_by_agent_with_retry(host_ip, vm_ip, 'root', 'password', cmd): # test_lib.SSH_TIMEOUT = ssh_timeout # test_util.test_fail("iso has been failed to installed.") #test_lib.SSH_TIMEOUT = ssh_timeout #clone vm cloned_vm_name = ['cloned_vm_name'] cloned_vm_obj = vm.clone(cloned_vm_name)[0] test_obj_dict.add_vm(cloned_vm_obj) #delete iso image.delete() test_obj_dict.rm_image(image) #vm ops test test_stub.vm_ops_test(cloned_vm_obj, "VM_TEST_ALL") #expunge iso image.expunge() #detach iso img_ops.detach_iso(vm.vm.uuid) #vm ops test test_stub.vm_ops_test(cloned_vm_obj, "VM_TEST_ALL") #create image by vm root volume cloned_vm_img_name = "cloned_vm_image1" img_option2 = test_util.ImageOption() img_option2.set_backup_storage_uuid_list([bs_uuid]) img_option2.set_root_volume_uuid(cloned_vm_obj.vm.rootVolumeUuid) img_option2.set_name(cloned_vm_img_name) image1 = test_image.ZstackTestImage() image1.set_creation_option(img_option2) image1.create() image1.check() test_obj_dict.add_image(image1) #export image image1.export() #create vm vm2 = test_stub.create_vm('image-vm', cloned_vm_img_name, l3_name) #delete image image1.delete() test_obj_dict.rm_image(image1) #vm ops test test_stub.vm_ops_test(vm2, "VM_TEST_ALL") #expunge image image1.expunge() #vm ops test test_stub.vm_ops_test(vm2, "VM_TEST_ALL") vm.destroy() vm2.destroy() cloned_vm_obj.destroy() vol_ops.delete_disk_offering(root_disk_uuid) vm_ops.delete_instance_offering(new_offering.uuid) test_obj_dict.rm_vm(vm) test_obj_dict.rm_disk_offering(data_volume_offering) test_obj_dict.rm_instance_offering(new_offering) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Create VM Image in Image Store Success')
def test(): data_volume_size = 10737418240 disk_offering_option = test_util.DiskOfferingOption() disk_offering_option.set_name('root-disk-iso') disk_offering_option.set_diskSize(data_volume_size) data_volume_offering = vol_ops.create_volume_offering(disk_offering_option) test_obj_dict.add_disk_offering(data_volume_offering) cpuNum = 1 cpuSpeed = 16 memorySize = 536870912 name = 'vm-offering-iso' new_offering_option = test_util.InstanceOfferingOption() new_offering_option.set_cpuNum(cpuNum) new_offering_option.set_cpuSpeed(cpuSpeed) new_offering_option.set_memorySize(memorySize) new_offering_option.set_name(name) new_offering = vm_ops.create_instance_offering(new_offering_option) test_obj_dict.add_instance_offering(new_offering) img_option = test_util.ImageOption() img_option.set_name('image-iso') bs_uuid = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE, [], None)[0].uuid img_option.set_backup_storage_uuid_list([bs_uuid]) img_option.set_url( 'http://172.20.1.15:7480/iso/iso_for_install_vm_test.iso') image_inv = img_ops.add_iso_template(img_option) image_uuid = image_inv.uuid image = test_image.ZstackTestImage() image.set_image(image_inv) image.set_creation_option(img_option) test_obj_dict.add_image(image) l3_name = os.environ.get('l3PublicNetworkName') l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid root_disk_uuid = data_volume_offering.uuid vm = test_stub.create_vm_with_iso([l3_net_uuid], image_uuid, 'vm-iso', root_disk_uuid, new_offering.uuid) test_obj_dict.add_vm(vm) test_util.test_dsc('wait for iso installation') vm_inv = vm.get_vm() vm_ip = vm_inv.vmNics[0].ip test_lib.lib_wait_target_up(vm_ip, '22', 2400) cmd = '[ -e /root ] && echo yes || echo no' ssh_num = 0 ssh_ok = 0 while ssh_num <= 5 and ssh_ok == 0: rsp = test_lib.lib_execute_ssh_cmd(vm_ip, 'root', 'password', cmd, 180) if rsp == False: time.sleep(30) else: ssh_ok = 1 break ssh_num = ssh_num + 1 if ssh_ok == 0: test_util.test_fail('fail to ssh to VM') vm.check() vm.destroy() test_obj_dict.rm_vm(vm) image.delete() test_obj_dict.rm_image(image) vol_ops.delete_disk_offering(root_disk_uuid) test_obj_dict.rm_disk_offering(data_volume_offering) vm_ops.delete_instance_offering(new_offering.uuid) test_obj_dict.rm_instance_offering(new_offering) test_util.test_pass('Create VM with ISO Installation Test Success')
def test(): global image global test_obj_dict #run condition hosts = res_ops.query_resource(res_ops.HOST) if len(hosts) <= 1: test_util.test_skip( "skip for host_num is not satisfy condition host_num>1") bs_cond = res_ops.gen_query_conditions("status", '=', "Connected") bss = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE, bs_cond, None, fields=['uuid']) #create disk offering data_volume_size = 10737418240 disk_offering_option = test_util.DiskOfferingOption() disk_offering_option.set_name('root-disk-iso') disk_offering_option.set_diskSize(data_volume_size) data_volume_offering = vol_ops.create_volume_offering(disk_offering_option) test_obj_dict.add_disk_offering(data_volume_offering) #create instance offering cpuNum = 2 memorySize = 1024 * 1024 * 1024 name = 'iso-vm-offering' new_offering_option = test_util.InstanceOfferingOption() new_offering_option.set_cpuNum(cpuNum) new_offering_option.set_memorySize(memorySize) new_offering_option.set_name(name) new_offering = vm_ops.create_instance_offering(new_offering_option) test_obj_dict.add_instance_offering(new_offering) #add iso img_option = test_util.ImageOption() img_option.set_name('iso1') bs_uuid = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE, [], None)[0].uuid img_option.set_backup_storage_uuid_list([bs_uuid]) img_option.set_url(os.environ.get('isoForVmUrl')) image_inv = img_ops.add_iso_template(img_option) image_uuid = image_inv.uuid image = test_image.ZstackTestImage() image.set_image(image_inv) image.set_creation_option(img_option) test_obj_dict.add_image(image) #create vm by iso l3_name = os.environ.get('l3VlanNetworkName1') l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid root_disk_uuid = data_volume_offering.uuid vm = test_stub.create_vm_with_iso([l3_net_uuid], image_uuid, 'iso-vm', root_disk_uuid, new_offering.uuid) host_ip = test_lib.lib_find_host_by_vm(vm.get_vm()).managementIp test_obj_dict.add_vm(vm) #check vm vm_inv = vm.get_vm() vm_ip = vm_inv.vmNics[0].ip #cmd ='[ -e /root ]' #ssh_timeout = test_lib.SSH_TIMEOUT #test_lib.SSH_TIMEOUT = 3600 test_lib.lib_set_vm_host_l2_ip(vm_inv) test_lib.lib_wait_target_up(vm.get_vm().vmNics[0].ip, 22, 1800) #if not test_lib.lib_ssh_vm_cmd_by_agent_with_retry(host_ip, vm_ip, 'root', 'password', cmd): # test_lib.SSH_TIMEOUT = ssh_timeout # test_util.test_fail("iso has been failed to installed.") #test_lib.SSH_TIMEOUT = ssh_timeout #delete iso image.delete() test_obj_dict.rm_image(image) #expunge iso image.expunge() #detach iso img_ops.detach_iso(vm.vm.uuid) #vm ops test test_stub.vm_ops_test(vm, "VM_TEST_REIMAGE") vm.destroy() vol_ops.delete_disk_offering(root_disk_uuid) vm_ops.delete_instance_offering(new_offering.uuid) test_obj_dict.rm_vm(vm) test_obj_dict.rm_disk_offering(data_volume_offering) test_obj_dict.rm_instance_offering(new_offering) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Create VM Image in Image Store Success')
def test(): # create_instanceoffering_min_cpu with tag_soft instance_offering_option = test_util.InstanceOfferingOption() instance_offering_option.set_cpuNum(1) instance_offering_option.set_memorySize(1 * 1024 * 1024 * 1024) instance_offering_option.set_allocatorStrategy( "MinimumCPUUsageHostAllocatorStrategy") instance_offering_option.set_type("UserVm") instance_offering_option.set_name('cpu') cpu_off = vm_ops.create_instance_offering(instance_offering_option) test_obj_dict.add_instance_offering(cpu_off) cpu_tag = tag_ops.create_system_tag( resourceType="InstanceOfferingVO", resourceUuid=cpu_off.uuid, tag="minimumCPUUsageHostAllocatorStrategyMode::soft") # create_instanceoffering_min_memory with tag_soft instance_offering_option.set_cpuNum(1) instance_offering_option.set_memorySize(1 * 1024 * 1024 * 1024) instance_offering_option.set_allocatorStrategy( "MinimumMemoryUsageHostAllocatorStrategy") instance_offering_option.set_type("UserVm") instance_offering_option.set_name('memory') memory_off = vm_ops.create_instance_offering(instance_offering_option) test_obj_dict.add_instance_offering(cpu_off) memory_tag = tag_ops.create_system_tag( resourceType="InstanceOfferingVO", resourceUuid=memory_off.uuid, tag="minimumMemoryUsageHostAllocatorStrategyMode::soft") # kill prometheus cmd = "kill -9 `netstat -nlp | awk -F'[ /]*' '/9090/{print $(NF-2)}'`" mn_ip = os.environ["ZSTACK_BUILT_IN_HTTP_SERVER_IP"] test_lib.lib_execute_ssh_cmd(mn_ip, "root", "password", cmd) condition = res_ops.gen_query_conditions('name', '=', 'ttylinux') img_name = res_ops.query_resource(res_ops.IMAGE, condition)[0].name l3_name = res_ops.query_resource(res_ops.L3_NETWORK)[0].name try: vm = test_stub.create_vm_with_instance_offering( "cpu_1", img_name, l3_name, cpu_off) test_obj_dict.add_vm(vm) except Exception as e: test_util.test_fail(e) try: vm = test_stub.create_vm_with_instance_offering( "memory_1", img_name, l3_name, memory_off) test_obj_dict.add_vm(vm) except Exception as e: test_util.test_fail(e) tag_ops.update_system_tag( cpu_tag.uuid, tag="minimumCPUUsageHostAllocatorStrategyMode::hard") tag_ops.update_system_tag( memory_tag.uuid, tag="minimumMemoryUsageHostAllocatorStrategyMode::hard") try: vm = test_stub.create_vm_with_instance_offering( "cpu_2", img_name, l3_name, cpu_off) test_obj_dict.add_vm(vm) test_util.test_fail("hard model can not create vm") except Exception as e: test_util.test_logger(e) try: vm = test_stub.create_vm_with_instance_offering( "memory_2", img_name, l3_name, memory_off) test_obj_dict.add_vm(vm) test_util.test_fail("hard model can not create vm") except Exception as e: test_util.test_logger(e) test_lib.lib_execute_ssh_cmd(mn_ip, "root", "password", "zstack-ctl restart_node", timeout=300) test_lib.lib_error_cleanup(test_obj_dict) test_util.test_pass( "test instanceoffering soft->hard and create vm case pass")
def test(): global vms, exec_info, delete_policy1 ps = res_ops.query_resource(res_ops.PRIMARY_STORAGE)[0] if ps.type != inventory.CEPH_PRIMARY_STORAGE_TYPE: test_util.test_skip( 'this test is for moniter expunge vm on ceph, not found ceph, skip test.' ) delete_policy1 = test_lib.lib_set_delete_policy('vm', 'Delay') 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_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid cpuNum = 1 memorySize = 268435456 name = 'vm-offering-allocator-strategy' new_offering_option = test_util.InstanceOfferingOption() new_offering_option.set_cpuNum(cpuNum) new_offering_option.set_memorySize(memorySize) new_offering_option.set_name(name) new_offering = vm_ops.create_instance_offering(new_offering_option) test_obj_dict.add_instance_offering(new_offering) instance_offering_uuid = new_offering.uuid each_vm_cpu_consume = cpuNum vm_creation_option = test_util.VmOption() 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) #trigger vm create exec_info = [] ts = [] for i in range(vm_num): t = threading.Thread(target=create_vm_wrapper, args=(i, vm_creation_option)) ts.append(t) t.start() for t in ts: t.join() check_exception("created") #trigger vm destroy exec_info = [] ts = [] for i, vm in zip(range(vm_num), vms): t = threading.Thread(target=destroy_vm_wrapper, args=(i, vm.vm.uuid)) ts.append(t) t.start() for t in ts: t.join() check_exception("destroyed") #trigger vm expunge exec_info = [] ts = [] for i, vm in zip(range(vm_num), vms): t = threading.Thread(target=expunge_vm_wrapper, args=(i, vm.vm.uuid)) ts.append(t) t.start() for t in ts: t.join() check_exception("expunged") test_lib.lib_set_delete_policy('vm', delete_policy1) test_util.test_pass('Create VM Test Success')
def test(): global ssh_timeout data_volume_size = 10737418240 disk_offering_option = test_util.DiskOfferingOption() disk_offering_option.set_name('root-disk-iso') disk_offering_option.set_diskSize(data_volume_size) data_volume_offering = vol_ops.create_volume_offering(disk_offering_option) test_obj_dict.add_disk_offering(data_volume_offering) cpuNum = 1 memorySize = 536870912 name = 'vm-offering-iso' new_offering_option = test_util.InstanceOfferingOption() new_offering_option.set_cpuNum(cpuNum) new_offering_option.set_memorySize(memorySize) new_offering_option.set_name(name) new_offering = vm_ops.create_instance_offering(new_offering_option) test_obj_dict.add_instance_offering(new_offering) img_option = test_util.ImageOption() img_option.set_name('image-iso') bs_uuid = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE, [], None)[0].uuid img_option.set_backup_storage_uuid_list([bs_uuid]) img_option.set_url('http://172.20.1.15:7480/iso/iso_for_install_vm_test.iso') image_inv = img_ops.add_iso_template(img_option) image_uuid = image_inv.uuid image = test_image.ZstackTestImage() image.set_image(image_inv) image.set_creation_option(img_option) test_obj_dict.add_image(image) l3_name = os.environ.get('l3VlanNetworkName1') l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid root_disk_uuid = data_volume_offering.uuid vm = test_stub.create_vm_with_iso([l3_net_uuid], image_uuid, 'vm-iso', root_disk_uuid, new_offering.uuid) host_ip = test_lib.lib_find_host_by_vm(vm.get_vm()).managementIp test_obj_dict.add_vm(vm) test_util.test_dsc('wait for iso installation') vm_inv = vm.get_vm() vm_ip = vm_inv.vmNics[0].ip #test_lib.lib_wait_target_up(vm_ip, '22', 2400) #vm.check() #cmd ='[ -e /root ] && echo yes || echo no' cmd ='[ -e /root ]' #ssh_num = 0 #ssh_ok = 0 #while ssh_num <= 5 and ssh_ok == 0 : # rsp = test_lib.lib_execute_ssh_cmd(vm_ip, 'root', 'password', cmd, 180) # if rsp == False: # time.sleep(30) # else: # ssh_ok = 1 # break # ssh_num = ssh_num + 1 #if ssh_ok == 0: # test_util.test_fail('fail to ssh to VM') ssh_timeout = test_lib.SSH_TIMEOUT test_lib.SSH_TIMEOUT = 3600 test_lib.lib_set_vm_host_l2_ip(vm_inv) if not test_lib.lib_ssh_vm_cmd_by_agent_with_retry(host_ip, vm_ip, 'root', 'password', cmd): test_lib.SSH_TIMEOUT = ssh_timeout test_util.test_fail("iso has not been failed to installed.") test_lib.SSH_TIMEOUT = ssh_timeout vm.destroy() test_obj_dict.rm_vm(vm) image.delete() test_obj_dict.rm_image(image) vol_ops.delete_disk_offering(root_disk_uuid) test_obj_dict.rm_disk_offering(data_volume_offering) vm_ops.delete_instance_offering(new_offering.uuid) test_obj_dict.rm_instance_offering(new_offering) test_util.test_pass('Create VM with ISO Installation Test Success')