def test(): global curr_deploy_conf global test_obj_dict global l3_name global l3 curr_deploy_conf = exp_ops.export_zstack_deployment_config( test_lib.deploy_config) delete_policy = test_lib.lib_set_delete_policy('vm', 'Delay') l3_name = os.environ.get('l3VlanNetworkName1') l3 = res_ops.get_resource(res_ops.L3_NETWORK, name=l3_name)[0] vm = test_stub.create_vlan_vm(l3_name) vm.check() test_obj_dict.add_vm(vm) net_ops.delete_l3(l3.uuid) if test_lib.lib_get_l3_by_uuid(l3.uuid): test_util.test_fail( 'l3 should not be found when associated L3 is deleted') #vm_nic_uuid = vm.vm.vmNics[0].uuid #net_ops.detach_l3(vm_nic_uuid) vm.destroy() vm.set_state(vm_header.DESTROYED) vm.check() vm.recover() vm.set_state(vm_header.STOPPED) vm.check() test_lib.lib_set_delete_policy('vm', delete_policy) try: vm.start() except Exception, e: #if "please attach a nic and try again" in str(e): test_util.test_pass('test detach l3 check vm passed.')
def test(): global host_config global ps_inv curr_deploy_conf = exp_ops.export_zstack_deployment_config( test_lib.deploy_config) host1 = res_ops.get_resource(res_ops.HOST, name=host1_name)[0] host_config.set_name(host1_name) host_config.set_cluster_uuid(host1.clusterUuid) host_config.set_management_ip(host1.managementIp) host_config.set_username(os.environ.get('hostUsername')) host_config.set_password(os.environ.get('hostPassword')) test_util.test_dsc('delete host') host_ops.delete_host(host1.uuid) test_util.test_dsc('delete primary storage') ps_name = os.environ.get('nfsPrimaryStorageName1') ps_inv = res_ops.get_resource(res_ops.PRIMARY_STORAGE, name=ps_name)[0] ps_ops.delete_primary_storage(ps_inv.uuid) test_util.test_dsc("Recover Primary Storage") recover_ps() test_util.test_dsc("Recover Host") host_ops.add_kvm_host(host_config) host1 = res_ops.get_resource(res_ops.HOST, name=host1_name)[0] ps1 = res_ops.get_resource(res_ops.PRIMARY_STORAGE, name=ps_name)[0] test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Delete Host and Primary Storage Test Success')
def test(): global host_config global ps_inv curr_deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config) host1 = res_ops.get_resource(res_ops.HOST, name = host1_name)[0] host_config.set_name(host1_name) host_config.set_cluster_uuid(host1.clusterUuid) host_config.set_management_ip(host1.managementIp) host_config.set_username(os.environ.get('hostUsername')) host_config.set_password(os.environ.get('hostPassword')) test_util.test_dsc('delete host') host_ops.delete_host(host1.uuid) test_util.test_dsc('delete primary storage') ps_name = os.environ.get('nfsPrimaryStorageName1') ps_inv = res_ops.get_resource(res_ops.PRIMARY_STORAGE, name = ps_name)[0] ps_ops.delete_primary_storage(ps_inv.uuid) test_util.test_dsc("Recover Primary Storage") recover_ps() test_util.test_dsc("Recover Host") host_ops.add_kvm_host(host_config) host1 = res_ops.get_resource(res_ops.HOST, name = host1_name)[0] ps1 = res_ops.get_resource(res_ops.PRIMARY_STORAGE, name = ps_name)[0] test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Delete Host and Primary Storage Test Success')
def test(): global curr_deploy_conf global l2_name2 curr_deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config) 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 #pick up l3 l3_1 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name1)[0] l3_2 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name2)[0] l2_2 = res_ops.get_resource(res_ops.L2_NETWORK, \ uuid = l3_2.l2NetworkUuid)[0] l2_name2 = l2_2.name 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_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multizones_basic_vm') vm_creation_option.set_l3_uuids([l3_1.uuid, l3_2.uuid]) cluster1_name = os.environ.get('clusterName2') cluster1 = res_ops.get_resource(res_ops.CLUSTER, name = cluster1_name)[0] vm_creation_option.set_cluster_uuid(cluster1.uuid) vm1 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm1) test_util.test_dsc('Delete l2_2') net_ops.delete_l2(l2_2.uuid) test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED) vm1.update() vm1.set_state(vm_header.STOPPED) vm1.check() test_util.test_dsc('start vm again. vm should remove the deleted l2') vm1.start() net_ops.add_l2_resource(curr_deploy_conf, l2_name = l2_name2) #update l3_2, since it is readded. l3_2 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name2)[0] vm_creation_option.set_l3_uuids([l3_1.uuid, l3_2.uuid]) vm2 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm2) #check vm1 vm2 status. vm1.check() if not len(vm1.get_vm().vmNics) == 1: test_util.test_fail('vm1 vmNics still have L3: %s, even if it is deleted' % l3_2.uuid) vm2.check() test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Delete L2 Test Success')
def test(): global curr_deploy_conf #This conf should only be put in test(), since test_lib.deploy_config # should be set by woodpecker. curr_deploy_conf = exp_ops.export_zstack_deployment_config( test_lib.deploy_config) 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 #pick up cluster1 cluster1 = res_ops.get_resource(res_ops.CLUSTER, name=cluster1_name)[0] 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_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multizones_basic_vm') vm_creation_option.set_cluster_uuid(cluster1.uuid) vm1 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm1) vm2 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm2) vm3 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm3) vm4 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm4) test_util.test_dsc('delete cluster') cluster_ops.delete_cluster(cluster1.uuid) test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED) test_obj_dict.mv_vm(vm2, vm_header.RUNNING, vm_header.STOPPED) test_obj_dict.mv_vm(vm3, vm_header.RUNNING, vm_header.STOPPED) test_obj_dict.mv_vm(vm4, vm_header.RUNNING, vm_header.STOPPED) vm1.update() vm2.update() vm3.update() vm4.update() test_lib.lib_robot_status_check(test_obj_dict) cluster_ops.add_cluster_resource(curr_deploy_conf, cluster1_name) cluster1 = res_ops.get_resource(res_ops.CLUSTER, name=cluster1_name)[0] vm_creation_option.set_cluster_uuid(cluster1.uuid) vm_creation_option.set_l3_uuids([]) vm1.start() vm2.start() vm3.start() vm4.start() test_lib.lib_robot_status_check(test_obj_dict) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Delete Cluster Test Success')
def test(): global host_config curr_deploy_conf = exp_ops.export_zstack_deployment_config( test_lib.deploy_config) 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 #pick up host1 host1 = res_ops.get_resource(res_ops.HOST, name=host1_name)[0] 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_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multizones_basic_vm') vm_creation_option.set_host_uuid(host1.uuid) vm1 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm1) vm2 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm2) host_config.set_name(host1_name) host_config.set_cluster_uuid(host1.clusterUuid) host_config.set_management_ip(host1.managementIp) host_config.set_username(os.environ.get('hostUsername')) host_config.set_password(os.environ.get('hostPassword')) test_util.test_dsc('delete host') host_ops.delete_host(host1.uuid) test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED) test_obj_dict.mv_vm(vm2, vm_header.RUNNING, vm_header.STOPPED) vm1.update() vm1.set_state(vm_header.STOPPED) vm2.update() vm2.set_state(vm_header.STOPPED) test_lib.lib_robot_status_check(test_obj_dict) test_util.test_dsc('start vm on other host') vm1.start() vm2.start() test_lib.lib_robot_status_check(test_obj_dict) host_ops.add_kvm_host(host_config) host1 = res_ops.get_resource(res_ops.HOST, name=host1_name)[0] #vm_creation_option.set_host_uuid(host1.uuid) #vm_creation_option.set_l3_uuids([]) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Delete Host Test Success')
def test(): global curr_deploy_conf #This conf should only be put in test(), since test_lib.deploy_config # should be set by woodpecker. curr_deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config) 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 #pick up cluster1 cluster1 = res_ops.get_resource(res_ops.CLUSTER, name = cluster1_name)[0] 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_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multizones_basic_vm') vm_creation_option.set_cluster_uuid(cluster1.uuid) vm1 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm1) vm2 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm2) vm3 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm3) vm4 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm4) test_util.test_dsc('delete cluster') cluster_ops.delete_cluster(cluster1.uuid) test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED) test_obj_dict.mv_vm(vm2, vm_header.RUNNING, vm_header.STOPPED) test_obj_dict.mv_vm(vm3, vm_header.RUNNING, vm_header.STOPPED) test_obj_dict.mv_vm(vm4, vm_header.RUNNING, vm_header.STOPPED) vm1.update() vm2.update() vm3.update() vm4.update() test_lib.lib_robot_status_check(test_obj_dict) cluster_ops.add_cluster_resource(curr_deploy_conf, cluster1_name) cluster1 = res_ops.get_resource(res_ops.CLUSTER, name = cluster1_name)[0] vm_creation_option.set_cluster_uuid(cluster1.uuid) vm_creation_option.set_l3_uuids([]) vm1.start() vm2.start() vm3.start() vm4.start() test_lib.lib_robot_status_check(test_obj_dict) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Delete Cluster Test Success')
def test(): global host_config curr_deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config) 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 #pick up host1 host1 = res_ops.get_resource(res_ops.HOST, name = host1_name)[0] 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_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multizones_basic_vm') vm_creation_option.set_host_uuid(host1.uuid) vm1 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm1) vm2 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm2) host_config.set_name(host1_name) host_config.set_cluster_uuid(host1.clusterUuid) host_config.set_management_ip(host1.managementIp) host_config.set_username(os.environ.get('hostUsername')) host_config.set_password(os.environ.get('hostPassword')) test_util.test_dsc('delete host') host_ops.delete_host(host1.uuid) test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED) test_obj_dict.mv_vm(vm2, vm_header.RUNNING, vm_header.STOPPED) vm1.update() vm1.set_state(vm_header.STOPPED) vm2.update() vm2.set_state(vm_header.STOPPED) test_lib.lib_robot_status_check(test_obj_dict) test_util.test_dsc('start vm on other host') vm1.start() vm2.start() test_lib.lib_robot_status_check(test_obj_dict) host_ops.add_kvm_host(host_config) host1 = res_ops.get_resource(res_ops.HOST, name = host1_name)[0] #vm_creation_option.set_host_uuid(host1.uuid) #vm_creation_option.set_l3_uuids([]) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Delete Host Test Success')
def test(): global image_obj curr_deploy_conf = exp_ops.export_zstack_deployment_config( test_lib.deploy_config) vm_creation_option = test_util.VmOption() image_name = os.environ.get('imageName_net') image_inv = test_lib.lib_get_image_by_name(image_name) image_uuid = image_inv.uuid image_crt_opt = test_util.ImageOption() image_crt_opt.set_name(image_inv.name) image_crt_opt.set_url(image_inv.url) image_crt_opt.set_format(image_inv.format) image_crt_opt.set_system(image_inv.system) image_crt_opt.set_mediaType(image_inv.mediaType) image_crt_opt.set_guest_os_type(image_inv.type) bss = image_inv.backupStorageRefs bss_uuids = [] for bs in bss: bss_uuids.append(bs.backupStorageUuid) image_crt_opt.set_backup_storage_uuid_list(bss_uuids) image_obj.set_creation_option(image_crt_opt) 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_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multizones_basic_vm') vm1 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm1) test_util.test_dsc('delete image') img_ops.delete_image(image_uuid) #in bug, when destroy vm after delete related image, destroy vm will fail test_util.test_dsc('destroy vm') vm1.destroy() test_obj_dict.rm_vm(vm1) test_util.test_dsc('add image back') image_obj.add_root_volume_template() test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Delete Image Test Success')
def test(): global image_obj curr_deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config) vm_creation_option = test_util.VmOption() image_name = os.environ.get('imageName_s') image_inv = test_lib.lib_get_image_by_name(image_name) image_uuid = image_inv.uuid image_crt_opt = test_util.ImageOption() image_crt_opt.set_name(image_inv.name) image_crt_opt.set_url(image_inv.url) image_crt_opt.set_format(image_inv.format) image_crt_opt.set_system(image_inv.system) image_crt_opt.set_mediaType(image_inv.mediaType) image_crt_opt.set_guest_os_type(image_inv.type) bss = image_inv.backupStorageRefs bss_uuids = [] for bs in bss: bss_uuids.append(bs.backupStorageUuid) image_crt_opt.set_backup_storage_uuid_list(bss_uuids) image_obj.set_creation_option(image_crt_opt) 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_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multizones_basic_vm') vm1 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm1) test_util.test_dsc('delete image') img_ops.delete_image(image_uuid) #in bug, when destroy vm after delete related image, destroy vm will fail test_util.test_dsc('destroy vm') vm1.destroy() test_obj_dict.rm_vm(vm1) test_util.test_dsc('add image back') image_obj.add_root_volume_template() test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Delete Image Test Success')
def test(): global curr_deploy_conf global l3_name global l3 curr_deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config) test_util.test_dsc('Create test vm and delete l3.') l3_name = os.environ.get('l3VlanNetworkName1') l3 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name)[0] vm = test_stub.create_vlan_vm(l3_name) test_obj_dict.add_vm(vm) vm.check() net_ops.delete_l3(l3.uuid) if len(test_lib.lib_find_vr_by_l3_uuid(l3.uuid)) != 0: test_util.test_fail('VR VM should be delete when associated L3 is deleted') vm.destroy() net_ops.add_l3_resource(curr_deploy_conf, l3_name) test_util.test_pass('Create VirtualRouter VM delete l3 Test Success')
def test(): global curr_deploy_conf global l3_1 l3_1 = res_ops.get_resource(res_ops.L3_NETWORK, name=l3_name1)[0] curr_deploy_conf = exp_ops.export_zstack_deployment_config( test_lib.deploy_config) 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 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_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multizones_basic_vm') vm_creation_option.set_l3_uuids([l3_1.uuid]) vm1 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm1) vm2 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm2) test_util.test_dsc('Delete l3_1') net_ops.delete_l3(l3_1.uuid) #Since 0.8, delete L3 won't delete VM. It will just detach L3 nic. #test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.DESTROYED) #test_obj_dict.mv_vm(vm2, vm_header.RUNNING, vm_header.DESTROYED) #vm1.set_state(vm_header.DESTROYED) #vm2.set_state(vm_header.DESTROYED) vm1.check() vm2.check() net_ops.add_l3_resource(curr_deploy_conf, l3_name=l3_1.name) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Delete L3 Test 2 Success')
def test(): global deploy_conf global vm_inv global vm test_util.test_dsc('Test Delete VR Offering and Teboot Normal VM') vm = test_stub.create_basic_vm() test_obj_dict.add_vm(vm) vm_inv = vm.get_vm() vm_ip = vm_inv.vmNics[0].ip vm.check() test_util.test_dsc('Record current virtual router offering information') deploy_conf = exp_ops.export_zstack_deployment_config( test_lib.deploy_config) cond = res_ops.gen_query_conditions('zone.vmInstance.uuid', '=', vm_inv.uuid) vr_offering_uuid = res_ops.query_resource(res_ops.VR_OFFERING, cond)[0].uuid test_util.test_dsc('Delete VR-RM and VR-Offering') cond = res_ops.gen_query_conditions('zone.vmInstance.uuid', '=', vm_inv.uuid) vr_vm_uuid = res_ops.query_resource(res_ops.VIRTUALROUTER_VM, cond)[0].uuid vm_ops.destroy_vm(vr_vm_uuid) vm_ops.delete_instance_offering(vr_offering_uuid) test_util.test_dsc( 'Create new VR-Offering, same as the former one, stop and start VM') session_uuid = acc_ops.login_as_admin() dep_ops.add_virtual_router(None, None, deploy_conf, session_uuid) vm.reboot() vm.destroy() test_obj_dict.rm_vm(vm) test_util.test_pass('Delete VR Offering and reboot normal VM: SUCCESS')
def test(): global curr_deploy_conf global l3_1 l3_1 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name1)[0] curr_deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config) 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 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_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multizones_basic_vm') vm_creation_option.set_l3_uuids([l3_1.uuid]) vm1 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm1) vm2 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm2) test_util.test_dsc('Delete l3_1') net_ops.delete_l3(l3_1.uuid) #Since 0.8, delete L3 won't delete VM. It will just detach L3 nic. #test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.DESTROYED) #test_obj_dict.mv_vm(vm2, vm_header.RUNNING, vm_header.DESTROYED) #vm1.set_state(vm_header.DESTROYED) #vm2.set_state(vm_header.DESTROYED) vm1.check() vm2.check() net_ops.add_l3_resource(curr_deploy_conf, l3_name = l3_1.name) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Delete L3 Test 2 Success')
def test(): global host_config global ps_inv curr_deploy_conf = exp_ops.export_zstack_deployment_config( test_lib.deploy_config) host1 = res_ops.get_resource(res_ops.HOST, name=host1_name)[0] host_config.set_name(host1_name) host_config.set_cluster_uuid(host1.clusterUuid) host_config.set_management_ip(host1.managementIp) host_config.set_username(os.environ.get('hostUsername')) host_config.set_password(os.environ.get('hostPassword')) test_util.test_dsc('delete host') host_ops.delete_host(host1.uuid) test_util.test_dsc('delete primary storage') zone_name = os.environ.get('zoneName1') zone_uuid = res_ops.get_resource(res_ops.ZONE, name=zone_name)[0].uuid cond = res_ops.gen_query_conditions('zoneUuid', '=', zone_uuid) ps_inv = res_ops.query_resource(res_ops.PRIMARY_STORAGE, cond)[0] if ps_inv.type == inventory.NFS_PRIMARY_STORAGE_TYPE: ps_name = os.environ.get('nfsPrimaryStorageName1') elif ps_inv.type == inventory.CEPH_PRIMARY_STORAGE_TYPE: ps_name = os.environ.get('cephPrimaryStorageName1') ps_inv = res_ops.get_resource(res_ops.PRIMARY_STORAGE, name=ps_name)[0] ps_ops.delete_primary_storage(ps_inv.uuid) test_util.test_dsc("Recover Primary Storage") test_stub.recover_ps(ps_inv) test_util.test_dsc("Recover Host") host_ops.add_kvm_host(host_config) host1 = res_ops.get_resource(res_ops.HOST, name=host1_name)[0] ps1 = res_ops.get_resource(res_ops.PRIMARY_STORAGE, name=ps_name)[0] test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Delete Host and Primary Storage Test Success')
def test(): global host_config global ps_inv curr_deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config) host1 = res_ops.get_resource(res_ops.HOST, name = host1_name)[0] host_config.set_name(host1_name) host_config.set_cluster_uuid(host1.clusterUuid) host_config.set_management_ip(host1.managementIp) host_config.set_username(os.environ.get('hostUsername')) host_config.set_password(os.environ.get('hostPassword')) test_util.test_dsc('delete host') host_ops.delete_host(host1.uuid) test_util.test_dsc('delete primary storage') zone_name = os.environ.get('zoneName1') zone_uuid = res_ops.get_resource(res_ops.ZONE, name = zone_name)[0].uuid cond = res_ops.gen_query_conditions('zoneUuid', '=', zone_uuid) ps_inv = res_ops.query_resource(res_ops.PRIMARY_STORAGE, cond)[0] if ps_inv.type == inventory.NFS_PRIMARY_STORAGE_TYPE: ps_name = os.environ.get('nfsPrimaryStorageName1') elif ps_inv.type == inventory.CEPH_PRIMARY_STORAGE_TYPE: ps_name = os.environ.get('cephPrimaryStorageName1') ps_inv = res_ops.get_resource(res_ops.PRIMARY_STORAGE, name = ps_name)[0] ps_ops.delete_primary_storage(ps_inv.uuid) test_util.test_dsc("Recover Primary Storage") test_stub.recover_ps(ps_inv) test_util.test_dsc("Recover Host") host_ops.add_kvm_host(host_config) host1 = res_ops.get_resource(res_ops.HOST, name = host1_name)[0] ps1 = res_ops.get_resource(res_ops.PRIMARY_STORAGE, name = ps_name)[0] test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Delete Host and Primary Storage Test Success')
def test(): global deploy_conf global vm_inv global vm test_util.test_dsc('Test Delete VR Offering and Teboot Normal VM') vm = test_stub.create_basic_vm() test_obj_dict.add_vm(vm) vm_inv = vm.get_vm() vm_ip = vm_inv.vmNics[0].ip vm.check() test_util.test_dsc('Record current virtual router offering information') deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config) cond = res_ops.gen_query_conditions('zone.vmInstance.uuid', '=', vm_inv.uuid) vr_offering_uuid = res_ops.query_resource(res_ops.VR_OFFERING, cond)[0].uuid test_util.test_dsc('Delete VR-RM and VR-Offering') cond = res_ops.gen_query_conditions('zone.vmInstance.uuid', '=', vm_inv.uuid) vr_vm_uuid = res_ops.query_resource(res_ops.VIRTUALROUTER_VM, cond)[0].uuid vm_ops.destroy_vm(vr_vm_uuid) vm_ops.delete_instance_offering(vr_offering_uuid) test_util.test_dsc('Create new VR-Offering, same as the former one, stop and start VM') session_uuid = acc_ops.login_as_admin() dep_ops.add_virtual_router(None, None, deploy_conf, session_uuid) vm.reboot() vm.destroy() test_obj_dict.rm_vm(vm) test_util.test_pass('Delete VR Offering and reboot normal VM: SUCCESS')
def test(): #This conf should only be put in test(), since test_lib.deploy_config # should be set by woodpecker. global curr_deploy_conf curr_deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config) 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 #pick up zone1 zone1 = res_ops.get_resource(res_ops.ZONE, name = zone1_name)[0] 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_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multizones_basic_vm') vm_creation_option.set_zone_uuid(zone1.uuid) vm1 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm1) vm2 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm2) vm3 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm3) vm4 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm4) zone_ops.delete_zone(zone1.uuid) test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.DESTROYED) test_obj_dict.mv_vm(vm2, vm_header.RUNNING, vm_header.DESTROYED) test_obj_dict.mv_vm(vm3, vm_header.RUNNING, vm_header.DESTROYED) test_obj_dict.mv_vm(vm4, vm_header.RUNNING, vm_header.DESTROYED) vm1.update() vm2.update() vm3.update() vm4.update() test_lib.lib_robot_status_check(test_obj_dict) zone_ops.add_zone_resource(curr_deploy_conf, zone1_name) zone1 = res_ops.get_resource(res_ops.ZONE, name = zone1_name)[0] vm_creation_option.set_zone_uuid(zone1.uuid) vm_creation_option.set_l3_uuids([]) vm1 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm1) vm2 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm2) vm3 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm3) vm4 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm4) test_lib.lib_robot_status_check(test_obj_dict) #time.sleep(5) #vm.check() #vm.destroy() test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Delete Zone Test Success')
def test(): global curr_deploy_conf global l2_name2 curr_deploy_conf = exp_ops.export_zstack_deployment_config( test_lib.deploy_config) 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 #pick up l3 l3_1 = res_ops.get_resource(res_ops.L3_NETWORK, name=l3_name1)[0] l3_2 = res_ops.get_resource(res_ops.L3_NETWORK, name=l3_name2)[0] l2_2 = res_ops.get_resource(res_ops.L2_NETWORK, \ uuid = l3_2.l2NetworkUuid)[0] l2_name2 = l2_2.name 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_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multizones_basic_vm') vm_creation_option.set_l3_uuids([l3_1.uuid, l3_2.uuid]) cluster1_name = os.environ.get('clusterName2') cluster1 = res_ops.get_resource(res_ops.CLUSTER, name=cluster1_name)[0] vm_creation_option.set_cluster_uuid(cluster1.uuid) vm1 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm1) test_util.test_dsc('Delete l2_2') net_ops.delete_l2(l2_2.uuid) test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED) vm1.update() vm1.set_state(vm_header.STOPPED) vm1.check() test_util.test_dsc('start vm again. vm should remove the deleted l2') vm1.start() net_ops.add_l2_resource(curr_deploy_conf, l2_name=l2_name2) #update l3_2, since it is readded. l3_2 = res_ops.get_resource(res_ops.L3_NETWORK, name=l3_name2)[0] vm_creation_option.set_l3_uuids([l3_1.uuid, l3_2.uuid]) vm2 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm2) #check vm1 vm2 status. vm1.check() if not len(vm1.get_vm().vmNics) == 1: test_util.test_fail( 'vm1 vmNics still have L3: %s, even if it is deleted' % l3_2.uuid) vm2.check() test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Delete L2 Test Success')
def test(): global host_config curr_deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config) 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 #pick up host1 host1_name = os.environ.get('hostName') host1 = res_ops.get_resource(res_ops.HOST, name = host1_name)[0] cond = res_ops.gen_query_conditions('clusterUuid', '=', host1.clusterUuid) cluster_hosts = res_ops.query_resource(res_ops.HOST, cond) if not len(cluster_hosts) > 1: test_util.test_skip('Skip test, since [cluster:] %s did not include more than 1 host' % host1.clusterUuid) for host in cluster_hosts: if host.uuid != host1.uuid: host2 = host 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_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multizones_basic_vm') vm_creation_option.set_host_uuid(host1.uuid) l3_name = os.environ.get('l3VlanNetworkName1') l3 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name)[0] vm_creation_option.set_l3_uuids([l3.uuid]) vm1 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm1) vr_vm_inv = test_lib.lib_find_vr_by_vm(vm1.get_vm())[0] vr_host_uuid = vr_vm_inv.hostUuid host_config.set_cluster_uuid(host1.clusterUuid) host_config.set_username(os.environ.get('hostUsername')) host_config.set_password(os.environ.get('hostPassword')) if vr_host_uuid != host1.uuid: vr_host_inv = res_ops.get_resource(res_ops.HOST, uuid = vr_host_uuid)[0] host_config.set_name(vr_host_inv.name) host_config.set_management_ip(vr_host_inv.managementIp) target_host_uuid = vr_host_inv.uuid else: host_config.set_name(host1_name) host_config.set_management_ip(host1.managementIp) target_host_uuid = host1.uuid test_util.test_dsc("Delete VR VM's host") host_ops.delete_host(target_host_uuid) if vr_host_uuid == host1.uuid: #if the deleted Host is VM1's host, need to restart VM1. test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED) test_util.test_dsc('start vm on other host') vm1.start() vm1.check() #using the same L3 to create VM2 to check if VR is working well. vm_creation_option.set_host_uuid(None) vm2 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm2) vm2.check() vm1.reboot() vm1.check() host_ops.add_kvm_host(host_config) #update host1, since it is re-added again. host1 = res_ops.get_resource(res_ops.HOST, name = host1_name)[0] test_util.test_dsc('Create new VM on new added Host') vm_creation_option.set_host_uuid(host1.uuid) vm3 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm3) vm3.check() #test_util.test_dsc('Delete VR Host again') #vr_new_inv = res_ops.get_resource(res_ops.VM_INSTANCE, \ # uuid = vr_vm_inv.uuid)[0] #vr_new_host_uuid = vr_new_inv.hostUuid #vr_new_host = res_ops.get_resource(res_ops.HOST, uuid = vr_new_host_uuid)[0] #host_config.set_name(vr_new_host.name) #host_config.set_management_ip(vr_new_host.managementIp) #host_ops.delete_host(target_host_uuid) #if vm1.get_vm().hostUuid == vr_new_host_uuid: # test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED) # test_util.test_dsc('start vm on another host') # vm1.start() #vm1.check() test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Test VR migration when deleting Host is Success')
def test(): global ps_inv global ps_uuid global cluster_uuid global tag curr_deploy_conf = exp_ops.export_zstack_deployment_config( test_lib.deploy_config) 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 #pick up primary storage 1 and set system tag for instance offering. zone_name = os.environ.get('zoneName1') zone_uuid = res_ops.get_resource(res_ops.ZONE, name=zone_name)[0].uuid cond = res_ops.gen_query_conditions('zoneUuid', '=', zone_uuid) ps_inv = res_ops.query_resource(res_ops.PRIMARY_STORAGE, cond)[0] if ps_inv.type == inventory.NFS_PRIMARY_STORAGE_TYPE: ps_name1 = os.environ.get('nfsPrimaryStorageName1') elif ps_inv.type == inventory.CEPH_PRIMARY_STORAGE_TYPE: ps_name1 = os.environ.get('cephPrimaryStorageName1') ps_inv = res_ops.get_resource(res_ops.PRIMARY_STORAGE, name=ps_name1)[0] ps_uuid = ps_inv.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_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multizones_vm_ps_ops') tag = tag_ops.create_system_tag('InstanceOfferingVO', \ instance_offering_uuid, \ 'primaryStorage::allocator::uuid::%s' % ps_uuid) l3_name = os.environ.get('l3VlanNetworkName1') l3 = res_ops.get_resource(res_ops.L3_NETWORK, name=l3_name)[0] vm_creation_option.set_l3_uuids([l3.uuid]) vm1 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm1) cluster_uuid = vm1.get_vm().clusterUuid test_util.test_dsc("Detach Primary Storage") ps_ops.detach_primary_storage(ps_uuid, cluster_uuid) test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED) vm1.update() vm1.set_state(vm_header.STOPPED) vm1.check() vm1.start() vm2 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm2) test_util.test_dsc("Delete Primary Storage") tag_ops.delete_tag(tag.uuid) ps_ops.delete_primary_storage(ps_inv.uuid) test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.DESTROYED) vm1.set_state(vm_header.DESTROYED) vm1.check() test_obj_dict.mv_vm(vm2, vm_header.RUNNING, vm_header.DESTROYED) vm2.set_state(vm_header.DESTROYED) vm2.check() try: vm3 = test_lib.lib_create_vm(vm_creation_option) except: test_util.test_logger( 'Catch expected vm creation exception, since primary storage has been deleted. ' ) else: test_util.test_fail( 'Fail: Primary Storage has been deleted. But vm is still created with it.' ) test_stub.recover_ps(ps_inv) test_util.test_dsc("Attach Primary Storage") test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Test primary storage operations Success')
def test(): global ps_uuid global cluster_uuid global tag curr_deploy_conf = exp_ops.export_zstack_deployment_config( test_lib.deploy_config) 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 cluster1_name = os.environ.get('clusterName1') cluster1 = res_ops.get_resource(res_ops.CLUSTER, name=cluster1_name)[0] #pick up primary storage 1 and set system tag for instance offering. ps_name1 = os.environ.get('nfsPrimaryStorageName1') ps_inv = res_ops.get_resource(res_ops.PRIMARY_STORAGE, name=ps_name1)[0] ps_uuid = ps_inv.uuid cluster_uuid = cluster1.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_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multizones_vm_detach_ps') vm_creation_option.set_cluster_uuid(cluster_uuid) tag = tag_ops.create_system_tag('InstanceOfferingVO', \ instance_offering_uuid, \ 'primaryStorage::allocator::uuid::%s' % ps_uuid) l3_name = os.environ.get('l3VlanNetworkName1') l3 = res_ops.get_resource(res_ops.L3_NETWORK, name=l3_name)[0] vm_creation_option.set_l3_uuids([l3.uuid]) vm1 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm1) vm2 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm2) volume1 = test_stub.create_volume() test_obj_dict.add_volume(volume1) volume1.attach(vm1) test_util.test_dsc("Detach Primary Storage") ps_ops.detach_primary_storage(ps_uuid, cluster_uuid) test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED) test_obj_dict.mv_vm(vm2, vm_header.RUNNING, vm_header.STOPPED) vm1.update() vm1.set_state(vm_header.STOPPED) vm2.update() vm2.set_state(vm_header.STOPPED) vm1.check() vm2.check() test_util.test_dsc("Attach Primary Storage") ps_ops.attach_primary_storage(ps_uuid, cluster_uuid) vm1.start() vm2.start() vm3 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm3) vm1.check() volume1.check() vm2.check() vm3.check() test_util.test_dsc("Delete new added tag") tag_ops.delete_tag(tag.uuid) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Test detaching primary storage Success')
def test(): global ps_inv global tag curr_deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config) 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 zone1_name = os.environ.get('zoneName1') zone1 = res_ops.get_resource(res_ops.ZONE, name = zone1_name)[0] #pick up primary storage 1 and set system tag for instance offering. zone_name = os.environ.get('zoneName1') zone_uuid = res_ops.get_resource(res_ops.ZONE, name = zone_name)[0].uuid cond = res_ops.gen_query_conditions('zoneUuid', '=', zone_uuid) ps_inv = res_ops.query_resource(res_ops.PRIMARY_STORAGE, cond)[0] if ps_inv.type == inventory.NFS_PRIMARY_STORAGE_TYPE: ps_name1 = os.environ.get('nfsPrimaryStorageName1') elif ps_inv.type == inventory.CEPH_PRIMARY_STORAGE_TYPE: ps_name1 = os.environ.get('cephPrimaryStorageName1') ps_inv = res_ops.get_resource(res_ops.PRIMARY_STORAGE, name = ps_name1)[0] 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_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multizones_vm_detach_ps') vm_creation_option.set_zone_uuid(zone1.uuid) tag = tag_ops.create_system_tag('InstanceOfferingVO', \ instance_offering_uuid, \ 'primaryStorage::allocator::uuid::%s' % ps_inv.uuid) l3_name = os.environ.get('l3VlanNetworkName1') l3 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name)[0] vm_creation_option.set_l3_uuids([l3.uuid]) vm1 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm1) volume1 = test_stub.create_volume() test_obj_dict.add_volume(volume1) volume1.attach(vm1) test_util.test_dsc("Delete Primary Storage") #need to delete tag as well tag_ops.delete_tag(tag.uuid) ps_ops.delete_primary_storage(ps_inv.uuid) test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.DESTROYED) vm1.update() test_obj_dict.rm_volume(volume1) volume1.update() test_lib.lib_robot_status_check(test_obj_dict) test_util.test_dsc("Recover Primary Storage") test_stub.recover_ps(ps_inv) test_lib.lib_robot_status_check(test_obj_dict) #update tag ps_inv = res_ops.get_resource(res_ops.PRIMARY_STORAGE, name = ps_name1)[0] tag = tag_ops.create_system_tag('InstanceOfferingVO', \ instance_offering_uuid, \ 'primaryStorage::allocator::uuid::%s' % ps_inv.uuid) test_util.test_dsc("Create new VM and Volume") vm2 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm2) volume2 = test_stub.create_volume() test_obj_dict.add_volume(volume2) volume2.attach(vm2) vm2.check() volume2.check() tag_ops.delete_tag(tag.uuid) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Test deleting primary storage Success')
def test(): global ps_uuid global cluster_uuid global tag curr_deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config) 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 cluster1_name = os.environ.get('clusterName1') cluster1 = res_ops.get_resource(res_ops.CLUSTER, name = cluster1_name)[0] #pick up primary storage 1 and set system tag for instance offering. ps_name1 = os.environ.get('nfsPrimaryStorageName1') ps_inv = res_ops.get_resource(res_ops.PRIMARY_STORAGE, name = ps_name1)[0] ps_uuid = ps_inv.uuid cluster_uuid = cluster1.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_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multizones_vm_detach_ps') vm_creation_option.set_cluster_uuid(cluster_uuid) tag = tag_ops.create_system_tag('InstanceOfferingVO', \ instance_offering_uuid, \ 'primaryStorage::allocator::uuid::%s' % ps_uuid) l3_name = os.environ.get('l3VlanNetworkName1') l3 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name)[0] vm_creation_option.set_l3_uuids([l3.uuid]) vm1 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm1) vm2 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm2) volume1 = test_stub.create_volume() test_obj_dict.add_volume(volume1) volume1.attach(vm1) test_util.test_dsc("Detach Primary Storage") ps_ops.detach_primary_storage(ps_uuid, cluster_uuid) test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED) test_obj_dict.mv_vm(vm2, vm_header.RUNNING, vm_header.STOPPED) vm1.update() vm1.set_state(vm_header.STOPPED) vm2.update() vm2.set_state(vm_header.STOPPED) vm1.check() vm2.check() test_util.test_dsc("Attach Primary Storage") ps_ops.attach_primary_storage(ps_uuid, cluster_uuid) vm1.start() vm2.start() vm3 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm3) vm1.check() volume1.check() vm2.check() vm3.check() test_util.test_dsc("Delete new added tag") tag_ops.delete_tag(tag.uuid) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Test detaching primary storage Success')
def test(): global host_config curr_deploy_conf = exp_ops.export_zstack_deployment_config( test_lib.deploy_config) 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 #pick up host1 host1_name = os.environ.get('hostName') host1 = res_ops.get_resource(res_ops.HOST, name=host1_name)[0] cond = res_ops.gen_query_conditions('clusterUuid', '=', host1.clusterUuid) cluster_hosts = res_ops.query_resource(res_ops.HOST, cond) if not len(cluster_hosts) > 1: test_util.test_skip( 'Skip test, since [cluster:] %s did not include more than 1 host' % host1.clusterUuid) for host in cluster_hosts: if host.uuid != host1.uuid: host2 = host 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_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multizones_basic_vm') vm_creation_option.set_host_uuid(host1.uuid) l3_name = os.environ.get('l3VlanNetworkName1') l3 = res_ops.get_resource(res_ops.L3_NETWORK, name=l3_name)[0] vm_creation_option.set_l3_uuids([l3.uuid]) vm1 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm1) vr_vm_inv = test_lib.lib_find_vr_by_vm(vm1.get_vm())[0] vr_host_uuid = vr_vm_inv.hostUuid host_config.set_cluster_uuid(host1.clusterUuid) host_config.set_username(os.environ.get('hostUsername')) host_config.set_password(os.environ.get('hostPassword')) if vr_host_uuid != host1.uuid: vr_host_inv = res_ops.get_resource(res_ops.HOST, uuid=vr_host_uuid)[0] host_config.set_name(vr_host_inv.name) host_config.set_management_ip(vr_host_inv.managementIp) target_host_uuid = vr_host_inv.uuid else: host_config.set_name(host1_name) host_config.set_management_ip(host1.managementIp) target_host_uuid = host1.uuid test_util.test_dsc("Delete VR VM's host") host_ops.delete_host(target_host_uuid) if vr_host_uuid == host1.uuid: #if the deleted Host is VM1's host, need to restart VM1. test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED) test_util.test_dsc('start vm on other host') vm1.start() vm1.check() #using the same L3 to create VM2 to check if VR is working well. vm_creation_option.set_host_uuid(None) vm2 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm2) vm2.check() vm1.reboot() vm1.check() host_ops.add_kvm_host(host_config) #update host1, since it is re-added again. host1 = res_ops.get_resource(res_ops.HOST, name=host1_name)[0] test_util.test_dsc('Create new VM on new added Host') vm_creation_option.set_host_uuid(host1.uuid) vm3 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm3) vm3.check() #test_util.test_dsc('Delete VR Host again') #vr_new_inv = res_ops.get_resource(res_ops.VM_INSTANCE, \ # uuid = vr_vm_inv.uuid)[0] #vr_new_host_uuid = vr_new_inv.hostUuid #vr_new_host = res_ops.get_resource(res_ops.HOST, uuid = vr_new_host_uuid)[0] #host_config.set_name(vr_new_host.name) #host_config.set_management_ip(vr_new_host.managementIp) #host_ops.delete_host(target_host_uuid) #if vm1.get_vm().hostUuid == vr_new_host_uuid: # test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED) # test_util.test_dsc('start vm on another host') # vm1.start() #vm1.check() test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Test VR migration when deleting Host is Success')
def test(): #This conf should only be put in test(), since test_lib.deploy_config # should be set by woodpecker. global curr_deploy_conf curr_deploy_conf = exp_ops.export_zstack_deployment_config( test_lib.deploy_config) 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 #pick up zone1 zone1 = res_ops.get_resource(res_ops.ZONE, name=zone1_name)[0] 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_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multizones_basic_vm') vm_creation_option.set_zone_uuid(zone1.uuid) vm1 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm1) vm2 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm2) vm3 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm3) vm4 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm4) zone_ops.delete_zone(zone1.uuid) test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.DESTROYED) test_obj_dict.mv_vm(vm2, vm_header.RUNNING, vm_header.DESTROYED) test_obj_dict.mv_vm(vm3, vm_header.RUNNING, vm_header.DESTROYED) test_obj_dict.mv_vm(vm4, vm_header.RUNNING, vm_header.DESTROYED) vm1.update() vm2.update() vm3.update() vm4.update() test_lib.lib_robot_status_check(test_obj_dict) zone_ops.add_zone_resource(curr_deploy_conf, zone1_name) zone1 = res_ops.get_resource(res_ops.ZONE, name=zone1_name)[0] vm_creation_option.set_zone_uuid(zone1.uuid) vm_creation_option.set_l3_uuids([]) vm1 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm1) vm2 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm2) vm3 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm3) vm4 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm4) test_lib.lib_robot_status_check(test_obj_dict) #time.sleep(5) #vm.check() #vm.destroy() test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Delete Zone Test Success')
def test(): global curr_deploy_conf global l3_2 l3_2 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name2)[0] curr_deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config) 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 #pick up l3 l3_1 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name1)[0] 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_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multizones_basic_vm') vm_creation_option.set_l3_uuids([l3_1.uuid, l3_2.uuid]) vm1 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm1) vm2 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm2) test_util.test_dsc('Delete l3_2') net_ops.delete_l3(l3_2.uuid) #Since 0.8, delete L3 won't delete VM. It will just detach L3 nic. #test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED) #test_obj_dict.mv_vm(vm2, vm_header.RUNNING, vm_header.STOPPED) vm1.update() #vm1.set_state(vm_header.STOPPED) vm2.update() #vm2.set_state(vm_header.STOPPED) vm1.check() vm2.check() #test_util.test_dsc('start vm again. vm should remove the deleted l3') #vm1.start() #vm2.start() net_ops.add_l3_resource(curr_deploy_conf, l3_name = l3_2.name) #update l3_2, since it is readded. l3_2 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name2)[0] vm_creation_option.set_l3_uuids([l3_1.uuid, l3_2.uuid]) vm3 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm3) #check vm1 vm2 status. vm1.check() vm2.check() if not len(vm1.get_vm().vmNics) == 1: test_util.test_fail('vm1 vmNics still have L3: %s, even if it is deleted' % l3_2.uuid) if not len(vm2.get_vm().vmNics) == 1: test_util.test_fail('vm2 vmNics still have L3: %s, even if it is deleted' % l3_2.uuid) #check vm3 status vm3.check() test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Delete L3 Test Success')
def test(): global host_config curr_deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config) 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 #pick up host1 host1_name = os.environ.get('hostName') host1 = res_ops.get_resource(res_ops.HOST, name = host1_name)[0] host3_name = os.environ.get('hostName3') host3 = res_ops.get_resource(res_ops.HOST, name = host3_name)[0] cond = res_ops.gen_query_conditions('clusterUuid', '=', host1.clusterUuid) cluster_hosts = res_ops.query_resource(res_ops.HOST, cond) if not len(cluster_hosts) > 1: test_util.test_skip('Skip test, since [cluster:] %s did not include more than 1 host' % host1.clusterUuid) for host in cluster_hosts: if host.uuid != host1.uuid: host2 = host 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_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multizones_basic_vm') vm_creation_option.set_host_uuid(host1.uuid) l3_name = os.environ.get('l3VlanNetworkName1') l3 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name)[0] vm_creation_option.set_l3_uuids([l3.uuid]) vm1 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm1) vr_vm_inv = test_lib.lib_find_vr_by_vm(vm1.get_vm())[0] vr_host_uuid = vr_vm_inv.hostUuid #migrate vr to host3. if vr_host_uuid != host3.uuid: vm_ops.migrate_vm(vr_vm_inv.uuid, host3.uuid) host_config.set_cluster_uuid(host3.clusterUuid) host_config.set_username(os.environ.get('hostUsername')) host_config.set_password(os.environ.get('hostPassword')) host_config.set_name(host3_name) host_config.set_management_ip(host3.managementIp) target_host_uuid = host3.uuid test_util.test_dsc("Delete VR VM's host. VR should be migrated to Cluster1") host_ops.delete_host(target_host_uuid) vm1.check() #using the same L3 to create VM2 to check if VR is working well. vm_creation_option.set_host_uuid(None) vm2 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm2) vm2.check() host_ops.add_kvm_host(host_config) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Test VR migration when deleting Host is Success')
def test(): global host_config curr_deploy_conf = exp_ops.export_zstack_deployment_config( test_lib.deploy_config) 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 #pick up host1 host1_name = os.environ.get('hostName') host1 = res_ops.get_resource(res_ops.HOST, name=host1_name)[0] host3_name = os.environ.get('hostName3') host3 = res_ops.get_resource(res_ops.HOST, name=host3_name)[0] cond = res_ops.gen_query_conditions('clusterUuid', '=', host1.clusterUuid) cluster_hosts = res_ops.query_resource(res_ops.HOST, cond) if not len(cluster_hosts) > 1: test_util.test_skip( 'Skip test, since [cluster:] %s did not include more than 1 host' % host1.clusterUuid) for host in cluster_hosts: if host.uuid != host1.uuid: host2 = host 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_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multizones_basic_vm') vm_creation_option.set_host_uuid(host1.uuid) l3_name = os.environ.get('l3VlanNetworkName1') l3 = res_ops.get_resource(res_ops.L3_NETWORK, name=l3_name)[0] vm_creation_option.set_l3_uuids([l3.uuid]) vm1 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm1) vr_vm_inv = test_lib.lib_find_vr_by_vm(vm1.get_vm())[0] vr_host_uuid = vr_vm_inv.hostUuid #migrate vr to host3. if vr_host_uuid != host3.uuid: vm_ops.migrate_vm(vr_vm_inv.uuid, host3.uuid) host_config.set_cluster_uuid(host3.clusterUuid) host_config.set_username(os.environ.get('hostUsername')) host_config.set_password(os.environ.get('hostPassword')) host_config.set_name(host3_name) host_config.set_management_ip(host3.managementIp) target_host_uuid = host3.uuid test_util.test_dsc( "Delete VR VM's host. VR should be migrated to Cluster1") host_ops.delete_host(target_host_uuid) vm1.check() #using the same L3 to create VM2 to check if VR is working well. vm_creation_option.set_host_uuid(None) vm2 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm2) vm2.check() host_ops.add_kvm_host(host_config) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Test VR migration when deleting Host is Success')
def test(): global curr_deploy_conf global l3_2 l3_2 = res_ops.get_resource(res_ops.L3_NETWORK, name=l3_name2)[0] curr_deploy_conf = exp_ops.export_zstack_deployment_config( test_lib.deploy_config) 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 #pick up l3 l3_1 = res_ops.get_resource(res_ops.L3_NETWORK, name=l3_name1)[0] 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_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multizones_basic_vm') vm_creation_option.set_l3_uuids([l3_1.uuid, l3_2.uuid]) vm1 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm1) vm2 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm2) test_util.test_dsc('Delete l3_2') net_ops.delete_l3(l3_2.uuid) #Since 0.8, delete L3 won't delete VM. It will just detach L3 nic. #test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED) #test_obj_dict.mv_vm(vm2, vm_header.RUNNING, vm_header.STOPPED) vm1.update() #vm1.set_state(vm_header.STOPPED) vm2.update() #vm2.set_state(vm_header.STOPPED) vm1.check() vm2.check() #test_util.test_dsc('start vm again. vm should remove the deleted l3') #vm1.start() #vm2.start() net_ops.add_l3_resource(curr_deploy_conf, l3_name=l3_2.name) #update l3_2, since it is readded. l3_2 = res_ops.get_resource(res_ops.L3_NETWORK, name=l3_name2)[0] vm_creation_option.set_l3_uuids([l3_1.uuid, l3_2.uuid]) vm3 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm3) #check vm1 vm2 status. vm1.check() vm2.check() if not len(vm1.get_vm().vmNics) == 1: test_util.test_fail( 'vm1 vmNics still have L3: %s, even if it is deleted' % l3_2.uuid) if not len(vm2.get_vm().vmNics) == 1: test_util.test_fail( 'vm2 vmNics still have L3: %s, even if it is deleted' % l3_2.uuid) #check vm3 status vm3.check() test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Delete L3 Test Success')
def test(): global ps_inv global ps_uuid global cluster_uuid global tag curr_deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config) 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 #pick up primary storage 1 and set system tag for instance offering. zone_name = os.environ.get('zoneName1') zone_uuid = res_ops.get_resource(res_ops.ZONE, name = zone_name)[0].uuid cond = res_ops.gen_query_conditions('zoneUuid', '=', zone_uuid) ps_inv = res_ops.query_resource(res_ops.PRIMARY_STORAGE, cond)[0] if ps_inv.type == inventory.NFS_PRIMARY_STORAGE_TYPE: ps_name1 = os.environ.get('nfsPrimaryStorageName1') elif ps_inv.type == inventory.CEPH_PRIMARY_STORAGE_TYPE: ps_name1 = os.environ.get('cephPrimaryStorageName1') ps_inv = res_ops.get_resource(res_ops.PRIMARY_STORAGE, name = ps_name1)[0] ps_uuid = ps_inv.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_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multizones_vm_ps_ops') tag = tag_ops.create_system_tag('InstanceOfferingVO', \ instance_offering_uuid, \ 'primaryStorage::allocator::uuid::%s' % ps_uuid) l3_name = os.environ.get('l3VlanNetworkName1') l3 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name)[0] vm_creation_option.set_l3_uuids([l3.uuid]) vm1 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm1) cluster_uuid = vm1.get_vm().clusterUuid test_util.test_dsc("Detach Primary Storage") ps_ops.detach_primary_storage(ps_uuid, cluster_uuid) test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED) vm1.update() vm1.set_state(vm_header.STOPPED) vm1.check() vm1.start() vm2 = test_lib.lib_create_vm(vm_creation_option) test_obj_dict.add_vm(vm2) test_util.test_dsc("Delete Primary Storage") tag_ops.delete_tag(tag.uuid) ps_ops.delete_primary_storage(ps_inv.uuid) test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.DESTROYED) vm1.set_state(vm_header.DESTROYED) vm1.check() test_obj_dict.mv_vm(vm2, vm_header.RUNNING, vm_header.DESTROYED) vm2.set_state(vm_header.DESTROYED) vm2.check() try: vm3 = test_lib.lib_create_vm(vm_creation_option) except: test_util.test_logger('Catch expected vm creation exception, since primary storage has been deleted. ') else: test_util.test_fail('Fail: Primary Storage has been deleted. But vm is still created with it.') test_stub.recover_ps(ps_inv) test_util.test_dsc("Attach Primary Storage") test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Test primary storage operations Success')