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(): host = res_ops.query_resource(res_ops.HOST)[0] host_uuid = host.uuid password = "******" host_option = test_util.HostOption() host_option.set_cluster_uuid(host.clusterUuid) host_option.set_username(host.username) host_option.set_password(password) host_option.set_management_ip(host.managementIp) host_option.set_name(host.name) host_option.set_description(host.description) system_tag="pageTableExtensionDisabled" host_option.set_system_tags([system_tag]) host_ops.delete_host(host_uuid) new_added_host = host_ops.add_kvm_host(host_option) time.sleep(60) status = host_ops.get_ept_status(host.managementIp, host.username, password, host.sshPort) if status != "disable": test_util.test_fail('Fail to add host with ept disabled') host_ops.delete_host(new_added_host.uuid) host_option.set_system_tags([]) host_ops.add_kvm_host(host_option) time.sleep(60) status = host_ops.get_ept_status(host.managementIp, host.username, password, host.sshPort) if status != "enable": test_util.test_fail('Fail to add host with ept enabled') test_util.test_pass('Add Host with EPT disabled/enabled 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 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 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(): test_util.test_dsc('SMP ps remove host and check ps is 0') pss = res_ops.get_resource(res_ops.PRIMARY_STORAGE) #if pss[0].type != "SharedMountPoint": # test_util.test_skip("ps is not smp as expected, therefore, skip!") cond = res_ops.gen_query_conditions('state', '=', 'Enabled') cond = res_ops.gen_query_conditions('status', '=', 'Connected', cond) host = res_ops.query_resource_with_num(res_ops.HOST, cond, limit=1) if not host: test_util.test_skip('No Enabled/Connected host was found, skip test.') return True ps = res_ops.query_resource_with_num(res_ops.PRIMARY_STORAGE, cond, limit=1) if not ps: test_util.test_skip( 'No Enabled/Connected primary storage was found, skip test.') return True host = host[0] ps = ps[0] vm = test_stub.create_vm(vm_name='basic-test-vm', host_uuid=host.uuid) vm.check() host_ops.delete_host(host.uuid) ps_capacity = test_lib.lib_get_storage_capacity(ps_uuids=[ps.uuid]) avail_cap = ps_capacity.availableCapacity avail_phy_cap = ps_capacity.availablePhysicalCapacity avail_total_cap = ps_capacity.totalCapacity avail_total_phy_cap = ps_capacity.totalPhysicalCapacity if avail_cap != 0: test_util.test_fail("avail_cap:%d is not 0 as expected" % (avail_cap)) if avail_phy_cap != 0: test_util.test_fail("avail_phy_cap:%d is not 0 as expected" % (avail_phy_cap)) if avail_total_cap != 0: test_util.test_fail("avail_total_cap:%d is not 0 as expected" % (avail_total_cap)) if avail_total_phy_cap != 0: test_util.test_fail("avail_total_phy_cap:%d is not 0 as expected" % (avail_total_phy_cap)) test_util.test_pass( 'SMP remove host check ps capacity equal 0 test success')
def test(): test_util.test_dsc('SMP ps remove host and check ps is 0') pss = res_ops.get_resource(res_ops.PRIMARY_STORAGE) #if pss[0].type != "SharedMountPoint": # test_util.test_skip("ps is not smp as expected, therefore, skip!") cond = res_ops.gen_query_conditions('state', '=', 'Enabled') cond = res_ops.gen_query_conditions('status', '=', 'Connected', cond) host = res_ops.query_resource_with_num(res_ops.HOST, cond, limit = 1) if not host: test_util.test_skip('No Enabled/Connected host was found, skip test.' ) return True ps = res_ops.query_resource_with_num(res_ops.PRIMARY_STORAGE, cond, limit = 1) if not ps: test_util.test_skip('No Enabled/Connected primary storage was found, skip test.' ) return True host = host[0] ps = ps[0] vm = test_stub.create_vm(vm_name = 'basic-test-vm', host_uuid = host.uuid) vm.check() host_ops.delete_host(host.uuid) ps_capacity = test_lib.lib_get_storage_capacity(ps_uuids=[ps.uuid]) avail_cap = ps_capacity.availableCapacity avail_phy_cap = ps_capacity.availablePhysicalCapacity avail_total_cap = ps_capacity.totalCapacity avail_total_phy_cap = ps_capacity.totalPhysicalCapacity if avail_cap != 0: test_util.test_fail("avail_cap:%d is not 0 as expected" %(avail_cap)) if avail_phy_cap != 0: test_util.test_fail("avail_phy_cap:%d is not 0 as expected" %(avail_phy_cap)) if avail_total_cap != 0: test_util.test_fail("avail_total_cap:%d is not 0 as expected" %(avail_total_cap)) if avail_total_phy_cap != 0: test_util.test_fail("avail_total_phy_cap:%d is not 0 as expected" %(avail_total_phy_cap)) test_util.test_pass('SMP remove host check ps capacity equal 0 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 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 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 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 delete(self): host_ops.delete_host(self.host.uuid) super(ZstackTestKvmHost, self).delete()
def operate_host_parall(self, host_uuid): try: host_ops.delete_host(host_uuid,self.session_uuid) except: self.exc_info.append(sys.exc_info())
def test(): host = dict() host['Broadwell'] = [] host['Haswell-noTSX'] = [] _hosts = res_ops.query_resource(res_ops.HOST) if len(_hosts) < 4: test_util.test_fail("this case need at least 4 hosts") for i in _hosts[:2]: test_stub.set_host_cpu_model(i.managementIp, model='Broadwell') host['Broadwell'].append(i) for i in _hosts[2:]: test_stub.set_host_cpu_model(i.managementIp, model='Haswell-noTSX') host['Haswell-noTSX'].append(i) hosts = host['Broadwell'] + host['Haswell-noTSX'] clusters = res_ops.query_resource(res_ops.CLUSTER) for i in clusters: cls_ops.delete_cluster(i.uuid) clusters = [] zone = res_ops.query_resource(res_ops.ZONE)[0] cluster_option = test_util.ClusterOption() cluster_option.set_hypervisor_type('KVM') cluster_option.set_zone_uuid(zone.uuid) cluster_option.set_name('Broadwell_1') cluster1 = cls_ops.create_cluster(cluster_option) tag_ops.create_system_tag('ClusterVO',cluster1.uuid,tag="clusterKVMCpuModel::Broadwell") clusters.append(cluster1) cluster_option.set_name('Broadwell_2') cluster2 = cls_ops.create_cluster(cluster_option) tag_ops.create_system_tag('ClusterVO',cluster2.uuid,tag="clusterKVMCpuModel::Broadwell") clusters.append(cluster2) cluster_option.set_name('Haswell-noTSX_1') cluster3 = cls_ops.create_cluster(cluster_option) tag_ops.create_system_tag('ClusterVO',cluster3.uuid,tag="clusterKVMCpuModel::Haswell-noTSX") clusters.append(cluster3) conditions = res_ops.gen_query_conditions('name', '=', 'vlan-test9') l2 = res_ops.query_resource(res_ops.L2_VLAN_NETWORK, conditions)[0] conditions = res_ops.gen_query_conditions('name', '=', 'l2-public') l2_public = res_ops.query_resource(res_ops.L2_NETWORK, conditions)[0] ps = res_ops.query_resource(res_ops.PRIMARY_STORAGE) _hosts = [] for i in range(len(clusters)): net_ops.attach_l2(l2.uuid, clusters[i].uuid) net_ops.attach_l2(l2_public.uuid, clusters[i].uuid) for j in ps: ps_ops.attach_primary_storage(j.uuid, clusters[i].uuid) host_option = test_util.HostOption() host_option.set_cluster_uuid(clusters[i].uuid) host_option.set_username('root') host_option.set_password('password') host_option.set_name(hosts[i].managementIp) host_option.set_management_ip(hosts[i].managementIp) _hosts.append(host_ops.add_kvm_host(host_option)) # test host_option = test_util.HostOption() host_option.set_cluster_uuid(clusters[0].uuid) host_option.set_username('root') host_option.set_password('password') host_option.set_name(hosts[3].managementIp) host_option.set_management_ip(hosts[3].managementIp) try: _hosts.append(host_ops.add_kvm_host(host_option)) except Exception as e: test_util.test_logger(e) cond = res_ops.gen_query_conditions('name', '=', hosts[3].managementIp) host_uuid = res_ops.query_resource(res_ops.HOST, cond)[0].uuid host_ops.delete_host(host_uuid) host_option.set_cluster_uuid(clusters[2].uuid) try: _hosts.append(host_ops.add_kvm_host(host_option)) except Exception as e: test_util.test_fail("test cluster cpu model faild") # migrate vm conditions = res_ops.gen_query_conditions('name', '=', 'ttylinux') img = res_ops.query_resource(res_ops.IMAGE, conditions)[0] conditions = res_ops.gen_query_conditions('type', '=', 'UserVm') ins = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0] conditions = res_ops.gen_query_conditions('name', '=', 'public network') l3 = res_ops.query_resource(res_ops.L3_NETWORK, conditions)[0] vms = [] for i in [0,2]: vm_option = test_util.VmOption() vm_option.set_name("vm") vm_option.set_image_uuid(img.uuid) vm_option.set_cluster_uuid(clusters[i].uuid) vm_option.set_host_uuid(_hosts[i].uuid) vm_option.set_instance_offering_uuid(ins.uuid) vm_option.set_l3_uuids([l3.uuid]) vm_option.set_default_l3_uuid(l3.uuid) vms.append(vm_ops.create_vm(vm_option)) time.sleep(20) try: vm_ops.migrate_vm(vms[0].uuid, _hosts[1].uuid) except Exception as e: test_util.test_fail(e) try: vm_ops.migrate_vm(vms[1].uuid, _hosts[1].uuid) except Exception as e: test_util.test_logger(e) test_util.test_pass("test cluster cpu model pass")
def operate_host_parall(self, host_uuid): try: host_ops.delete_host(host_uuid, self.session_uuid) except: self.exc_info.append(sys.exc_info())
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')