• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python test_lib.lib_get_disk_offering_by_name函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中zstackwoodpecker.test_lib.lib_get_disk_offering_by_name函数的典型用法代码示例。如果您正苦于以下问题:Python lib_get_disk_offering_by_name函数的具体用法?Python lib_get_disk_offering_by_name怎么用?Python lib_get_disk_offering_by_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了lib_get_disk_offering_by_name函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test

def test():
    global test_obj_dict
    test_util.test_dsc('Create a VM with 3 additional data volumes with 1 of them using virtio-scsi')
    disk_offering1 = test_lib.lib_get_disk_offering_by_name(os.environ.get('smallDiskOfferingName'))
    disk_offering_uuids = []
    for i in range(0, 8):
        disk_offering_uuids.append(disk_offering1.uuid)
    disk_offering2 = test_lib.lib_get_disk_offering_by_name(os.environ.get('rootDiskOfferingName'))
    for i in range(0, 14):
        disk_offering_uuids.append(disk_offering2.uuid)
    vm = test_stub.create_vlan_vm(system_tags=["virtio::diskOffering::%s::num::14" % (disk_offering2.uuid) ,"virtio::diskOffering::%s::num::14" % (disk_offering1.uuid)], l3_name=os.environ.get('l3VlanNetworkName1'), disk_offering_uuids=disk_offering_uuids)
    test_obj_dict.add_vm(vm)
    vm.check()
    volumes_number = len(test_lib.lib_get_all_volumes(vm.vm))
    if volumes_number != 23:
        test_util.test_fail('Did not find 23 volumes for [vm:] %s. But we assigned 22 data volume when create the vm. We only catch %s volumes' % (vm.vm.uuid, volumes_number))
    else:
        test_util.test_logger('Find 23 volumes for [vm:] %s.' % vm.vm.uuid)

    scsi_cmd = 'ls /dev/sd* | wc -l'
    if test_lib.lib_execute_command_in_vm(vm.get_vm(), scsi_cmd).strip() != '22':
        test_util.test_fail('Only expect 22 disk in virtio scsi mode')

    vm.destroy()
    test_util.test_pass('Create a VM with 22 additional data volumes with 22 of them using virtio-scsi PASS')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:25,代码来源:test_crt_vm_24_virtio_scsi_volumes.py


示例2: share_admin_resource

def share_admin_resource(account_uuid_list):
    instance_offering_uuid = res_ops.get_resource(res_ops.INSTANCE_OFFERING)[0].uuid
    cond = res_ops.gen_query_conditions('mediaType', '!=', 'ISO')
    image_uuid = res_ops.query_resource(res_ops.IMAGE, cond)[0].uuid
    l3net_uuid = res_ops.get_resource(res_ops.L3_NETWORK)[0].uuid
    root_disk_uuid = test_lib.lib_get_disk_offering_by_name(os.environ.get('rootDiskOfferingName')).uuid
    data_disk_uuid = test_lib.lib_get_disk_offering_by_name(os.environ.get('smallDiskOfferingName')).uuid
    acc_ops.share_resources(account_uuid_list, [instance_offering_uuid, image_uuid, l3net_uuid, root_disk_uuid, data_disk_uuid])
开发者ID:KevinDavidMitnick,项目名称:zstack-woodpecker,代码行数:8,代码来源:test_stub.py


示例3: test

def test():
    vm = test_stub.create_vlan_vm()
    test_obj_dict.add_vm(vm)

    disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('rootDiskOfferingName'))
    volume_creation_option = test_util.VolumeOption()
    volume_creation_option.set_disk_offering_uuid(disk_offering.uuid)
    #volume_creation_option.set_system_tags(['ephemeral::shareable', 'capability::virtio-scsi'])
    volume = test_stub.create_volume(volume_creation_option)
    test_obj_dict.add_volume(volume)
    volume.check()
    volume.attach(vm)

    new_vms = vm.clone(vm_names)
    for new_vm in new_vms:
        test_obj_dict.add_vm(new_vm)

    if len(new_vms) != len(vm_names):
        test_util.test_fail('only %s VMs have been cloned, which is less than required: %s' % (len(new_vms), vm_names))

    for new_vm in new_vms:
        new_vm = new_vm.get_vm()
        try:
            vm_names.remove(new_vm.name)
            test_util.test_logger('VM:%s name: %s is found' % (new_vm.uuid, new_vm.name))
        except:
            test_util.test_fail('%s vm name: %s is not in list: %s' % (new_vm.uuid, new_vm.name, vm_names))
    
    if test_lib.lib_get_data_volumes(new_vms[0]) != []:
        test_util.test_fail('The cloned vm is still have data volume, the expected behavior is only clone root volume.')
    

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Clone VM Test Success')
开发者ID:mrwangxc,项目名称:zstack-woodpecker,代码行数:34,代码来源:test_vm_attached_data_volume_clone.py


示例4: test

def test():
    test_util.test_dsc('Create test vm and check')
    vm = test_stub.create_vlan_vm()
    test_obj_dict.add_vm(vm)

    test_util.test_dsc('Create volume and check')
    disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('rootDiskOfferingName'))
    volume_creation_option = test_util.VolumeOption()
    volume_creation_option.set_disk_offering_uuid(disk_offering.uuid)

    volume = test_stub.create_volume(volume_creation_option)
    test_obj_dict.add_volume(volume)
    volume.check()

    test_util.test_dsc('Attach volume and check')
    #mv vm checker later, to save some time.
    vm.check()
    volume.attach(vm)
    volume.check()

    test_util.test_dsc('Detach volume and check')
    volume.detach()
    volume.check()

    test_util.test_dsc('Delete volume and check')
    volume.delete()
    volume.check()
    test_obj_dict.rm_volume(volume)

    vm.destroy()
    vm.check()
    test_util.test_pass('Create Data Volume for VM Test Success')
开发者ID:KevinDavidMitnick,项目名称:zstack-woodpecker,代码行数:32,代码来源:test_add_volume.py


示例5: test

def test():
    global test_obj_dict
    volume_creation_option = test_util.VolumeOption()
    test_util.test_dsc('Create volume and check')
    disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('smallDiskOfferingName'))
    volume_creation_option.set_disk_offering_uuid(disk_offering.uuid)
    volume = test_stub.create_volume(volume_creation_option)
    test_obj_dict.add_volume(volume)
    volume.check()
    volume_uuid = volume.volume.uuid
    vol_size = volume.volume.size
    image_name = os.environ.get('imageName_net')
    l3_name = os.environ.get('l3VlanNetworkName1')
    vm = test_stub.create_vm("test_resize_vm", image_name, l3_name)
    vm.check()
    volume.attach(vm)
    test_obj_dict.add_vm(vm)

    snapshots = test_obj_dict.get_volume_snapshot(volume_uuid)
    snapshots.set_utility_vm(vm)
    snapshots.create_snapshot('create_snapshot1')
    snapshots.check()

    vm.stop()
    vm.check()
    set_size = 1024*1024*1024*5
    vol_ops.resize_data_volume(volume_uuid, set_size)
    vm.update()
    vol_size_after = test_lib.lib_get_data_volumes(vm.get_vm())[0].size
    if set_size != vol_size_after:
        test_util.test_fail('Resize Data Volume failed, size = %s' % vol_size_after)

    test_obj_dict.rm_volume_snapshot(snapshots)
    test_lib.lib_error_cleanup(test_obj_dict)
    test_util.test_pass('Resize Data Volume and Snapshot Test Success')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:35,代码来源:test_snapshot_resize_data_volume.py


示例6: test

def test():
    global test_obj_dict
    global ps_uuid
    global host_uuid
    global vr_uuid
    allow_ps_list = [inventory.CEPH_PRIMARY_STORAGE_TYPE, "SharedBlock"]
    test_lib.skip_test_when_ps_type_not_in_list(allow_ps_list)

    test_util.test_dsc('Create test vm and check')

    bs_cond = res_ops.gen_query_conditions("status", '=', "Connected")
    bss = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE, bs_cond, \
            None)
    if not bss:
        test_util.test_skip("not find available backup storage. Skip test")

    test_lib.lib_set_delete_policy('vm', 'Delay')
    test_lib.lib_set_delete_policy('volume', 'Delay')
    l3_1_name = os.environ.get('l3VlanNetworkName1')
    vm = test_stub.create_vlan_vm(l3_name=l3_1_name)
    l3_1 = test_lib.lib_get_l3_by_name(l3_1_name)
    vr = test_lib.lib_find_vr_by_l3_uuid(l3_1.uuid)[0]
    vr_uuid = vr.uuid
    
    host = test_lib.lib_get_vm_host(vm.get_vm())
    host_uuid = host.uuid
    test_obj_dict.add_vm(vm)
    vm.check()

    disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('rootDiskOfferingName'))
    volume_creation_option = test_util.VolumeOption()
    volume_creation_option.set_disk_offering_uuid(disk_offering.uuid)
    volume_creation_option.set_system_tags(['ephemeral::shareable', 'capability::virtio-scsi'])
    volume = test_stub.create_volume(volume_creation_option)
    test_obj_dict.add_volume(volume)
    volume.check()
    volume.attach(vm)

    #ps = test_lib.lib_get_primary_storage_by_vm(vm.get_vm())
    #ps_uuid = ps.uuid
    #ps_ops.change_primary_storage_state(ps_uuid, 'disable')
    test_stub.disable_all_pss()
    if not test_lib.lib_wait_target_up(vm.get_vm().vmNics[0].ip, '22', 90):
        test_util.test_fail('VM is expected to running when PS change to disable state')

    vm.set_state(vm_header.RUNNING)
    vm.check()
    volume.delete()
    volume.check()
    volume.expunge()
    volume.check()

    #ps_ops.change_primary_storage_state(ps_uuid, 'enable')
    test_stub.enable_all_pss()
    host_ops.reconnect_host(host_uuid)
    vm_ops.reconnect_vr(vr_uuid)
    vm.destroy()
    test_lib.lib_set_delete_policy('vm', 'Direct')
    test_lib.lib_set_delete_policy('volume', 'Direct')
    test_util.test_pass('Delete volume under PS disable mode Test Success')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:60,代码来源:test_disable_ps_expunge_attached_share_vol.py


示例7: test

def test():
    imagestore_backup_storage = test_lib.lib_get_image_store_backup_storage()
    if not imagestore_backup_storage:
        test_util.test_skip('Not find image store type backup storage.')

    img_option = test_util.ImageOption()
    img_option.set_name('iso')
    root_disk_uuid = test_lib.lib_get_disk_offering_by_name(os.environ.get('rootDiskOfferingName')).uuid                       
    bs_uuid = imagestore_backup_storage.uuid          
    img_option.set_backup_storage_uuid_list([bs_uuid])
    command = "command -v genisoimage"
    result = test_lib.lib_execute_ssh_cmd(os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'], 'root', 'password', command)
    if not result:
        command = "yum -y install genisoimage --disablerepo=* --enablerepo=zstack-local"
        test_lib.lib_execute_ssh_cmd(os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'], 'root', 'password', command)
    command = "genisoimage -o %s/apache-tomcat/webapps/zstack/static/zstack-repo/7/x86_64/os/test.iso /tmp/" % os.environ.get('zstackInstallPath')
    test_lib.lib_execute_ssh_cmd(os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'], 'root', 'password', command)
    img_option.set_url('http://%s:8080/zstack/static/zstack-repo/7/x86_64/os/test.iso' % (os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP']))
    image_inv = img_ops.add_iso_template(img_option)
    image = test_image.ZstackTestImage()
    image.set_image(image_inv)
    image.set_creation_option(img_option)

    test_obj_dict.add_image(image)
    image_url = image.export()
    image.delete_exported_image()
    test_lib.lib_robot_cleanup(test_obj_dict)
    if image_url.endswith('.iso'): 
        test_util.test_pass('Export ISO Image Test Success')
    else:
        test_util.test_fail('Export ISO Image Test Fail, exported ISO image ends with %s' % (image_url.split('.')[-1]))
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:31,代码来源:test_export_iso.py


示例8: test

def test():
    global test_obj_dict
    #volume_creation_option = test_util.VolumeOption()
    #test_util.test_dsc('Create volume and check')
    #disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('smallDiskOfferingName'))
    #volume_creation_option.set_disk_offering_uuid(disk_offering.uuid)
    #volume = test_stub.create_volume(volume_creation_option)

    bs_cond = res_ops.gen_query_conditions("status", '=', "Connected")
    bss = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE, bs_cond, \
            None, fields=['uuid'])
    if not bss:
        test_util.test_skip("not find available backup storage. Skip test")

    volume_creation_option = test_util.VolumeOption()
    test_util.test_dsc('Create volume and check')
    disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('smallDiskOfferingName'))
    volume_creation_option.set_disk_offering_uuid(disk_offering.uuid)
    volume1 = test_stub.create_volume(volume_creation_option)
    test_obj_dict.add_volume(volume1)
    volume1.check()
    volume_uuid = volume1.volume.uuid

    test_util.test_dsc('Create vm and check')
    vm = test_stub.create_vr_vm('migrate_volume_vm', 'imageName_net', 'l3VlanNetwork2')
    test_obj_dict.add_vm(vm)
    vm.check()
    vm_uuid = vm.vm.uuid

    volume1.attach(vm)
    volume1.detach(vm_uuid)

    vm.stop()
    image_obj = volume1.create_template([bss[0].uuid])
    vm.start()
    host_uuid = vm.vm.hostUuid
    ps = test_lib.lib_get_primary_storage_by_uuid(vm.get_vm().allVolumes[0].primaryStorageUuid)
    volume2 = image_obj.create_data_volume(ps.uuid, 'volumeName', host_uuid)
    test_obj_dict.add_volume(volume2)
    volume2.check()
    volume_uuid = volume2.volume.uuid

    ps = test_lib.lib_get_primary_storage_by_uuid(vm.get_vm().allVolumes[0].primaryStorageUuid)
    if ps.type != inventory.LOCAL_STORAGE_TYPE:
        test_util.test_skip('Skip test on non-localstorage')

    snapshots = test_obj_dict.get_volume_snapshot(volume_uuid)
    snapshots.set_utility_vm(vm)
    snapshots.create_snapshot('create_snapshot1')
    snapshots.check()
    snapshots.create_snapshot('create_snapshot2')
    snapshots.check()

    target_host = test_lib.lib_find_random_host_by_volume_uuid(volume_uuid)
    target_host_uuid = target_host.uuid

    vol_ops.migrate_volume(volume_uuid, target_host_uuid)

    test_lib.lib_error_cleanup(test_obj_dict)
    test_util.test_pass('Cold migrate Data Volume from Template with Snapshot Test Success')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:60,代码来源:test_cold_migrate_data_volume_from_tmpt_with_sp.py


示例9: test

def test():
    global test_obj_dict
    volumes = []

    ova_image_name = os.environ['vcenterDefaultmplate']
    network_pattern = 'L3-%s'%os.environ['dportgroup']
    if not vct_ops.lib_get_vcenter_l3_by_name(network_pattern):
        network_pattern = 'L3-%s'%os.environ['portgroup0']
    disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('largeDiskOfferingName'))
    #create vm with disk
    vm = test_stub.create_vm_in_vcenter(vm_name = 'vm_2', image_name = ova_image_name, l3_name = network_pattern, disk_offering_uuids = [disk_offering.uuid, disk_offering.uuid] )
    test_obj_dict.add_vm(vm)
    vm.check()

    vcenter = os.environ.get('vcenter')
    SI = vct_ops.connect_vcenter(vcenter)
    content = SI.RetrieveContent()
    vm = vct_ops.get_vm(content, name = 'vm_2')[0]
    
    vct_ops.delete_virtual_disk(vm, 2)
    vct_ops.delete_virtual_disk(vm, 2)
    vcenter_uuid = vct_ops.lib_get_vcenter_by_name(vcenter).uuid
    vct_ops.sync_vcenter(vcenter_uuid)
    time.sleep(5)
    allvolumes = vct_ops.lib_get_vm_by_name('vm_2').allVolumes
    assert len(allvolumes) == 1
    for volume in allvolumes:
        if volume.type == 'Data':
            volumes.append(volume.installPath)
    assert set(volumes) == set([])

    #cleanup
    test_lib.lib_error_cleanup(test_obj_dict)

    test_util.test_pass("sync after detaching disk from vm in vmware test passed.")
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:35,代码来源:test_sync_vcenter_after_detach_disk_in_vmware.py


示例10: test

def test():
    imagestore_backup_storage = test_lib.lib_get_image_store_backup_storage()
    if not imagestore_backup_storage:
        test_util.test_skip('Not find image store type backup storage.')

    img_option = test_util.ImageOption()
    img_option.set_name('iso')
    root_disk_uuid = test_lib.lib_get_disk_offering_by_name(os.environ.get('rootDiskOfferingName')).uuid                       
    bs_uuid = imagestore_backup_storage.uuid          
    img_option.set_backup_storage_uuid_list([bs_uuid])
    os.system("genisoimage -o %s/apache-tomcat/webapps/zstack/static/test.iso /tmp/" % (os.environ.get('zstackInstallPath')))
    img_option.set_url('http://%s:8080/zstack/static/test.iso' % (os.environ.get('node1Ip')))
    image_inv = img_ops.add_iso_template(img_option)
    image = test_image.ZstackTestImage()
    image.set_image(image_inv)
    image.set_creation_option(img_option)

    test_obj_dict.add_image(image)
    image_url = image.export()
    image.delete_exported_image()
    test_lib.lib_robot_cleanup(test_obj_dict)
    if image_url.endswith('.iso'): 
        test_util.test_pass('Export ISO Image Test Success')
    else:
        test_util.test_fail('Export ISO Image Test Fail, exported ISO image ends with %s' % (image_url.split('.')[-1]))
开发者ID:mrwangxc,项目名称:zstack-woodpecker,代码行数:25,代码来源:test_export_iso.py


示例11: test

def test():
    global test_obj_dict
    volume_creation_option = test_util.VolumeOption()
    test_util.test_dsc('Create volume and check')
    disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('smallDiskOfferingName'))
    volume_creation_option.set_disk_offering_uuid(disk_offering.uuid)
    volume = test_stub.create_volume(volume_creation_option)
    test_obj_dict.add_volume(volume)
    volume.check()
    volume_uuid = volume.volume.uuid
    
    test_util.test_dsc('Create vm and check')
    vm = test_stub.create_vr_vm('migrate_volume_vm', 'imageName_s', 'l3VlanNetwork2')
    test_obj_dict.add_vm(vm)
    vm.check()
    vm_uuid = vm.vm.uuid
    
    ps = test_lib.lib_get_primary_storage_by_uuid(vm.get_vm().allVolumes[0].primaryStorageUuid)
    if ps.type != inventory.LOCAL_STORAGE_TYPE:
        test_util.test_skip('Skip test on non-localstorage')
    
    test_util.test_dsc('Attach data volume to vm and check')
    volume.attach(vm)

    target_host = test_lib.lib_find_random_host_by_volume_uuid(volume_uuid)
    target_host_uuid = target_host.uuid

    test_util.test_dsc('Detach data volume from vm and check')
    volume.detach(vm_uuid)

    vol_ops.migrate_volume(volume_uuid, target_host_uuid)

    test_lib.lib_error_cleanup(test_obj_dict)
    test_util.test_pass('Cold migrate Data Volume Test Success')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:34,代码来源:test_cold_migrate_data_volume.py


示例12: test

def test():
    global test_obj_dict
    volume_creation_option = test_util.VolumeOption()
    ps_uuid = res_ops.query_resource(res_ops.PRIMARY_STORAGE, [])[0].uuid
    test_util.test_dsc('Create volume and check')
    disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('smallDiskOfferingName'))
    volume_creation_option.set_disk_offering_uuid(disk_offering.uuid)
    volume_creation_option.set_primary_storage_uuid(ps_uuid)
    if res_ops.query_resource(res_ops.PRIMARY_STORAGE, [])[0].type == "LocalStorage":
        host = test_lib.lib_find_random_host()
        volume_creation_option.set_system_tags(["localStorage::hostUuid::%s" % host.uuid])
    volume = test_stub.create_volume(volume_creation_option)
    test_obj_dict.add_volume(volume)
    volume.check()
    volume_uuid = volume.volume.uuid
    vol_size = volume.volume.size

    set_size = 1024*1024*1024*5
    vol_ops.resize_data_volume(volume_uuid, set_size)
    cond = res_ops.gen_query_conditions('type', '=', "Data")
    cond = res_ops.gen_query_conditions('status', '=', "Ready", cond)
    vol_size_after  = res_ops.query_resource(res_ops.VOLUME, cond)[0].size
    if set_size != vol_size_after:
        test_util.test_fail('Resize Data Volume failed, size = %s' % vol_size_after)
    test_lib.lib_error_cleanup(test_obj_dict)
    test_util.test_pass('Resize Data Volume Test Success')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:26,代码来源:test_resize_unattached_data_volume.py


示例13: create_vm_with_volume

def create_vm_with_volume(vm_creation_option = None, data_volume_uuids = None, \
        session_uuid = None):
    if not data_volume_uuids:
        disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('smallDiskOfferingName'), session_uuid)
        data_volume_uuids = [disk_offering.uuid]
    return create_vm(vm_creation_option, data_volume_uuids, \
            session_uuid = session_uuid)
开发者ID:KevinDavidMitnick,项目名称:zstack-woodpecker,代码行数:7,代码来源:test_stub.py


示例14: test

def test():
    global test_obj_dict

    #enable vmware vmotion
    SI = vct_ops.connect_vcenter(os.environ['vcenter'])
    content = SI.RetrieveContent()
    hosts = vct_ops.get_host(content)
    for host in hosts:
        vct_ops.enable_vmotion(host)

    network_pattern = 'L3-%s'%os.environ['dportgroup']
    if not vct_ops.lib_get_vcenter_l3_by_name(network_pattern):
        network_pattern = 'L3-%s'%os.environ['portgroup0']
    ova_image_name = os.environ['vcenterDefaultmplate']
    disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('largeDiskOfferingName'))

    #create vm 
    vm = test_stub.create_vm_in_vcenter(vm_name = 'migrate_vm', image_name = ova_image_name, l3_name = network_pattern)
    vm.check()
    test_obj_dict.add_vm(vm)
    #check whether vm migration candidate hosts exist
    candidate_hosts = vm_ops.get_vm_migration_candidate_hosts(vm.vm.uuid).inventories
    if candidate_hosts == []:
        test_util.test_logger('Not find vm migration candidate hosts, skip test migrate vm')
    else:
        test_util.test_dsc('Migrate vm to the specified host')
        host_uuid = candidate_hosts[0].uuid
        vm_ops.migrate_vm(vm.vm.uuid, host_uuid)
        vm.update()
        vm.check()
        #check whether the specified host is effective
        assert candidate_hosts[0].name == test_lib.lib_find_host_by_vm(vm.vm).name
        #check the consistency of the migration in zstack and vmware
        assert candidate_hosts[0].name == vct_ops.find_host_by_vm(content, vm.vm.name)
        test_util.test_dsc('vm in suspended state does not allow migration')
        vm.suspend()
        candidate_host = vm_ops.get_vm_migration_candidate_hosts(vm.vm.uuid).inventories
        assert candidate_host == []
        
    #create vm with disk
    vm1 = test_stub.create_vm_in_vcenter(vm_name = 'migrate_vm_with_disk', image_name = ova_image_name, l3_name = network_pattern, disk_offering_uuids = [disk_offering.uuid])
    vm1.check()
    test_obj_dict.add_vm(vm1)
    #check whether vm migration candidate hosts exist
    candidate_hosts = vm_ops.get_vm_migration_candidate_hosts(vm1.vm.uuid).inventories
    if candidate_hosts == []:
        test_util.test_logger('Not find vm migration candidate hosts, skip test migrate vm with disk')
    else:
        test_util.test_dsc('Migrate vm with disk to the specified host')
        host_uuid = candidate_hosts[0].uuid
        vm_ops.migrate_vm(vm1.vm.uuid, host_uuid)
        vm1.update()
        vm1.check()
        assert candidate_hosts[0].name == test_lib.lib_find_host_by_vm(vm1.vm).name
        assert candidate_hosts[0].name == vct_ops.find_host_by_vm(content, vm1.vm.name)
   
    #cleanup 
    test_lib.lib_error_cleanup(test_obj_dict)

    test_util.test_pass("Migrate vm test passed.")
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:60,代码来源:test_migrate_vm_with_shared_storage.py


示例15: test

def test():
    test_util.test_dsc('Create test vm and check')
    vm = test_stub.create_vlan_vm()
    test_obj_dict.add_vm(vm)

    test_util.test_dsc('Create volume and check')
    disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('rootDiskOfferingName'))
    volume_creation_option = test_util.VolumeOption()
    volume_creation_option.set_disk_offering_uuid(disk_offering.uuid)

    volume = test_stub.create_volume(volume_creation_option)
    test_obj_dict.add_volume(volume)
    volume.check()

    test_util.test_dsc('Attach volume and check')
    vm.check()
    volume.attach(vm)
    volume.check()

    test_util.test_dsc('Stop VM')
    vm.stop()

    test_util.test_dsc('Detach volume and check')
    volume.detach()
    volume.check()

    test_util.test_dsc('Attach volume to stopped VM and check')
    volume.attach(vm)
    volume.check()

    test_util.test_dsc('Detach volume from stopped VM again and check')
    volume.detach()
    volume.check()

    volume2 = test_stub.create_volume(volume_creation_option)
    test_obj_dict.add_volume(volume2)
    test_util.test_dsc('Attach new volume2 to stopped VM and check')
    volume2.attach(vm)
    volume2.check()

    test_util.test_dsc('Detach volume2 from stopped VM again and check')
    volume2.detach()
    volume2.check()

    test_util.test_dsc('Attach new volume2 to stopped VM again and start vm')
    volume2.attach(vm)
    vm.start()
    test_util.test_dsc('Detach volume2 from running VM again and check')
    volume2.detach()
    volume2.check()

    test_util.test_dsc('Delete volume and check')
    volume.delete()
    volume.check()
    test_obj_dict.rm_volume(volume)
    volume2.delete()
    test_obj_dict.rm_volume(volume2)

    vm.destroy()
    test_util.test_pass('Do Volumes ops on stopped VM Success')
开发者ID:chancelq,项目名称:zstack-woodpecker,代码行数:60,代码来源:test_volume_ops_on_stopped_vm.py


示例16: create_vm_with_previous_iso

def create_vm_with_previous_iso(vm_creation_option=None, session_uuid=None):
    cond = res_ops.gen_query_conditions('name', '=', 'iso')
    image_uuid = res_ops.query_resource(res_ops.IMAGE, cond)[0].uuid
    root_disk_uuid = test_lib.lib_get_disk_offering_by_name(
        os.environ.get('rootDiskOfferingName')).uuid
    return create_vm(vm_creation_option, None, root_disk_uuid, image_uuid,
                     session_uuid=session_uuid)
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:7,代码来源:test_stub.py


示例17: test

def test():
    global new_offering_uuid
    test_util.test_dsc('Test VM disk bandwidth QoS by 20MB')

    #unit is KB
    volume_bandwidth = 25*1024*1024
    new_offering = test_lib.lib_create_instance_offering(volume_bandwidth = volume_bandwidth)
    new_offering_uuid = new_offering.uuid

    vm = test_stub.create_vm(vm_name = 'vm_volume_qos', \
            instance_offering_uuid = new_offering.uuid)
    test_obj_dict.add_vm(vm)

    vm.check()

    volume_creation_option = test_util.VolumeOption()
    disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('largeDiskOfferingName'))
    volume_creation_option.set_disk_offering_uuid(disk_offering.uuid)
    
    volume_creation_option.set_name('volume-1')
    volume = test_stub.create_volume(volume_creation_option)
    test_obj_dict.add_volume(volume)
    vm_inv = vm.get_vm()
    test_lib.lib_mkfs_for_volume(volume.get_volume().uuid, vm_inv)
    mount_point = '/tmp/zstack/test'
    test_stub.attach_mount_volume(volume, vm, mount_point)

    test_stub.make_ssh_no_password(vm_inv)
    test_stub.install_fio(vm_inv)
    test_stub.test_fio_bandwidth(vm_inv, volume_bandwidth, mount_point)
    vm_ops.delete_instance_offering(new_offering_uuid)
    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM Disk QoS Test Pass')
开发者ID:TinaL3,项目名称:zstack-woodpecker,代码行数:34,代码来源:test_disk_qos2.py


示例18: test

def test():
    global test_obj_dict

    ova_image_name = os.environ['vcenterDefaultmplate']
    network_pattern1 = 'L3-%s'%os.environ['dportgroup']
    if not vct_ops.lib_get_vcenter_l3_by_name(network_pattern1):
        network_pattern1 = 'L3-%s'%os.environ['portgroup0']

    disk_offering1 = test_lib.lib_get_disk_offering_by_name(os.environ.get('largeDiskOfferingName'))

    vm = test_stub.create_vm_in_vcenter(vm_name = 'test_for_sync_volume_size_vm', image_name = ova_image_name, l3_name = network_pattern1)
    test_obj_dict.add_vm(vm)
    vm.check()
    ps_uuid = vm.vm.allVolumes[0].primaryStorageUuid
    volume_creation_option = test_util.VolumeOption()
    volume_creation_option.set_disk_offering_uuid(disk_offering1.uuid)
    volume_creation_option.set_name('test_for_sync_volume_size_volume')
    volume_creation_option.set_primary_storage_uuid(ps_uuid)
    volume = test_stub.create_volume(volume_creation_option)
    test_obj_dict.add_volume(volume)
    volume.check()
    #SyncVolumeSize
    vol_ops.sync_volume_size(volume.get_volume().uuid)
    volume.attach(vm)
    volume.check()
    vol_ops.sync_volume_size(volume.get_volume().uuid)

    #cleanup
    test_lib.lib_error_cleanup(test_obj_dict)

    test_util.test_pass("Test sync volume size in vcenter passed.")
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:31,代码来源:test_sync_volume_size.py


示例19: test

def test():
    test_util.test_dsc('Create test vm and check')
    vm1 = test_stub.create_vm(vm_name="vm1", image_name="ocfs2-host-image")
    test_obj_dict.add_vm(vm1)

    vm2 = test_stub.create_vm(vm_name="vm2", image_name="ocfs2-host-image")
    test_obj_dict.add_vm(vm2)

    vm1.check()
    vm2.check()

    test_util.test_dsc('Create volume and check')
    disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('rootDiskOfferingName'))
    volume_creation_option = test_util.VolumeOption()
    volume_creation_option.set_disk_offering_uuid(disk_offering.uuid)
    normal_volume = test_stub.create_volume(volume_creation_option)
    test_obj_dict.add_volume(normal_volume)
    normal_volume.check()

    volume_creation_option.set_system_tags(['ephemeral::shareable', 'capability::virtio-scsi'])
    sharable_volume = test_stub.create_volume(volume_creation_option)
    test_obj_dict.add_volume(sharable_volume)
    sharable_volume.check()
    normal_volume.check()

    test_util.test_dsc('Attach volume and check')
    #mv vm checker later, to save some time.
    normal_volume.attach(vm2)
    sharable_volume.attach(vm1)
    sharable_volume.attach(vm2)
    sharable_volume.check()
    normal_volume.check()

    config_ocfs2_vms(vm1, vm2)
    check_sharable_volume(vm1, vm2)

    test_util.test_dsc('Detach volume and check')
    sharable_volume.detach(vm1.get_vm().uuid)
    sharable_volume.detach(vm2.get_vm().uuid)
    normal_volume.detach(vm2.get_vm().uuid)
    sharable_volume.check()
    normal_volume.check()

    test_util.test_dsc('Delete volume and check')
    sharable_volume.delete()
    sharable_volume.expunge()
    normal_volume.delete()
    normal_volume.expunge()
    sharable_volume.check()
    normal_volume.check()
    test_obj_dict.rm_volume(sharable_volume)
    test_obj_dict.rm_volume(normal_volume)

    vm1.destroy()
    vm2.destroy()
    vm1.check()
    vm2.check()
    vm1.expunge()
    vm2.expunge()
    test_util.test_pass('Create Data Volume for VM Test Success')
开发者ID:mrwangxc,项目名称:zstack-woodpecker,代码行数:60,代码来源:test_add_sharable_vol_normal_vol.py


示例20: test

def test():
    global vm
    ova_image_name = 'centos-dhcp'
    network_pattern1 = os.environ['vcenterDefaultNetwork']
    cpuNum = 2
    memorySize = 2*1024*1024*1024

    cond = res_ops.gen_query_conditions('type', '!=', 'Vcenter')
    ps = res_ops.query_resource(res_ops.PRIMARY_STORAGE, cond)
    for i in ps:
        if (i.type == 'Ceph') or (i.type == 'Sharedblock'):
            break
    else:
        test_util.test_skip('Skip test on non ceph or sharedblock PS')
    ps_uuid = ps[0].uuid
    cond = res_ops.gen_query_conditions('primaryStorage.uuid', '=', ps_uuid)
    cluster_uuid = res_ops.query_resource(res_ops.CLUSTER, cond)[0].uuid
    cond = res_ops.gen_query_conditions('clusterUuid', '=', cluster_uuid)    
    host = res_ops.query_resource(res_ops.HOST, cond)[0]  

    new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum, memorySize = memorySize)
    vm = test_stub.create_vm_in_vcenter(vm_name = 'v2v-test', image_name = ova_image_name, l3_name = network_pattern1, instance_offering_uuid = new_offering.uuid)
    vm.check()
    disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('smallDiskOfferingName'))
    volume_creation_option = test_util.VolumeOption()
    volume_creation_option.set_disk_offering_uuid(disk_offering.uuid)
    volume_creation_option.set_name('vcenter_volume')
    volume = test_stub.create_volume(volume_creation_option)
    test_obj_dict.add_volume(volume)
    volume.check()
    volume.attach(vm)

    l3_name = os.environ.get('l3VlanNetworkName1')
    l3_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
    v2v_conversion_host = test_stub.add_v2v_conversion_host('v2v_host', host.uuid, '/tmp/zstack', 'VMWARE')
    url = 'vmware://%s' % vm.vm.uuid
    migrate_task = test_stub.convert_vm_from_foreign_hypervisor('test', url, cpuNum, memorySize, ps_uuid, [l3_uuid], cluster_uuid, v2v_conversion_host.uuid)
    cond = res_ops.gen_query_conditions('uuid', '=', migrate_task.uuid)
    long_job = res_ops.query_resource(res_ops.LONGJOB, cond)[0]
    assert long_job.state == 'Running'
    if check_cache(vm.vm.uuid, host.ip) == 1:
        test_util.test_fail('There should be cache in installpath:/tmp/zstack.')

    time.sleep(5)
    longjob_ops.cancel_longjob(long_job.uuid)
    long_job = res_ops.query_resource(res_ops.LONGJOB, cond)[0]        
    assert long_job.state == 'Canceled'

    if check_cache(vm.vm.uuid, host.ip) == 0:
        test_util.test_fail('There are still cache in installpath: /tmp/zstack.')

    cond = res_ops.gen_query_conditions('name', '=', 'test')
    vm = res_ops.query_resource(res_ops.VM_INSTANCE, cond)
    if vm != None:
        test_util.fail('There are still vm after cancel long job.')
    
    #cleanup
    test_lib.lib_error_cleanup(test_obj_dict)
    test_util.test_pass("Cancel v2v long job successfully.")
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:59,代码来源:test_cancel_job.py



注:本文中的zstackwoodpecker.test_lib.lib_get_disk_offering_by_name函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python test_lib.lib_get_ha_enable函数代码示例发布时间:2022-05-26
下一篇:
Python test_lib.lib_get_backup_storage_list_by_vm函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap