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

Python test_lib.lib_get_root_volume函数代码示例

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

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



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

示例1: test

def test():
   test_util.test_dsc('Test Change VM Image In Multihosts Env')
   global vm
   image = test_lib.lib_get_image_by_name("centos")
   vm = test_stub.create_vm(image_uuid=image.uuid)
   last_l3network_uuid = test_lib.lib_get_l3s_uuid_by_vm(vm.get_vm())
   last_primarystorage_uuid = test_lib.lib_get_root_volume(vm.get_vm()).primaryStorageUuid
   last_host_uuid = test_lib.lib_get_vm_last_host(vm.get_vm()).uuid
   image_uuid = test_lib.lib_get_image_by_name("image_for_sg_test").uuid
   vm_uuid = vm.get_vm().uuid
   host_ops.change_host_state(host_uuid = last_host_uuid, state = 'disable')
   vm_ops.stop_vm(vm_uuid)
   ps = test_lib.lib_get_primary_storage_by_vm(vm.get_vm())
   #Disable vm's host.If ps is shared storage,the vm will be started on another host that meets the conditions and the operation of changing vm image will success.
   if ps.type != 'LocalStorage':
      vm_ops.change_vm_image(vm_uuid,image_uuid)
      vm_ops.start_vm(vm_uuid)
      #check whether the network config has changed
      l3network_uuid_after = test_lib.lib_get_l3s_uuid_by_vm(vm.get_vm())
      if l3network_uuid_after != last_l3network_uuid:
         test_util.test_fail('Change VM Image Failed.The Network config has changed.')
      #check whether primarystorage has changed
      primarystorage_uuid_after = test_lib.lib_get_root_volume(vm.get_vm()).primaryStorageUuid
      if primarystorage_uuid_after != last_primarystorage_uuid:
         test_util.test_fail('Change VM Image Failed.Primarystorage has changed.')
      vm.destroy()
      test_util.test_pass('Change Vm Image Test Success In Multihosts Env Success')
   #Disable vm's host.If ps is local storage,the operation of changing vm image will fail.  
   else:
      try:
         vm_ops.change_vm_image(vm_uuid, image_uuid)
      except:
         test_util.test_pass('Change Vm Image Test Success In Multihosts Env Success')
   test_util.test_fail('Test Change VM Image In Multihosts Env Success Failed')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:34,代码来源:test_change_vm_image_in_multihosts_env.py


示例2: test

def test():
    global vm
    create_vm_option = test_util.VmOption()
    create_vm_option.set_rootVolume_systemTags(["volumeProvisioningStrategy::ThinProvisioning"])
    create_vm_option.set_name('test_resize_vm_root_volume')
    vm = test_lib.lib_create_vm(create_vm_option)
    vm.check()
    vm.stop() 
    vm.check()

    vol_size = test_lib.lib_get_root_volume(vm.get_vm()).size
    volume_uuid = test_lib.lib_get_root_volume(vm.get_vm()).uuid
    set_size = 1024*1024*1024*5
    vol_ops.resize_volume(volume_uuid, set_size)
    vm.update()
    vol_size_after = test_lib.lib_get_root_volume(vm.get_vm()).size
    if set_size != vol_size_after:
        test_util.test_fail('Resize Root Volume failed, size = %s' % vol_size_after)

    vm.start()
    set_size = 1024*1024*1024*6
    vol_ops.resize_volume(volume_uuid, set_size)
    vm.update()
    vol_size_after = test_lib.lib_get_root_volume(vm.get_vm()).size
    if set_size != vol_size_after:
        test_util.test_fail('Resize Root Volume failed, size = %s' % vol_size_after)

    vm.destroy()
    test_util.test_pass('Resize VM Test Success')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:29,代码来源:test_resize_vm_root_volumethin_provision.py


示例3: test

def test():
    global vm
    vm_creation_option = test_util.VmOption()
    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)
    test_obj_dict.add_vm(vm)
    vm.check()
    vm.stop() 
    vm.check()

    vol_size = test_lib.lib_get_root_volume(vm.get_vm()).size
    volume_uuid = test_lib.lib_get_root_volume(vm.get_vm()).uuid
    set_size = 1024*1024*1024*5

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

    vol_ops.resize_volume(volume_uuid, set_size)
    vm.update()
    vol_size_after = test_lib.lib_get_root_volume(vm.get_vm()).size
    if set_size != vol_size_after:
        test_util.test_fail('Resize Root Volume failed, size = %s' % vol_size_after)

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


示例4: test

def test():
    global vm
    vm_creation_option = test_util.VmOption()
    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)
    test_obj_dict.add_vm(vm)
    vm.check()

    vol_size = test_lib.lib_get_root_volume(vm.get_vm()).size
    volume_uuid = test_lib.lib_get_root_volume(vm.get_vm()).uuid
    set_size = 1024*1024*1024*5
    vol_ops.resize_volume(volume_uuid, set_size)
    vm.update()
    vol_size_after = test_lib.lib_get_root_volume(vm.get_vm()).size
    if set_size != vol_size_after:
        test_util.test_fail('Resize Root Volume failed, size = %s' % vol_size_after)

    bs_list = test_lib.lib_get_backup_storage_list_by_vm(vm.vm)
    image_option = test_util.ImageOption()
    image_option.set_root_volume_uuid(volume_uuid)
    image_option.set_name('image_resize_template')
    image_option.set_backup_storage_uuid_list([bs_list[0].uuid])
    image = img_ops.create_root_volume_template(image_option)

    new_vm = test_stub.create_vm("test_vm_after_resize", 'image_resize_template', l3_name)
    test_obj_dict.add_vm(new_vm)
    new_vm.check()
    new_volume_uuid = test_lib.lib_get_root_volume_uuid(new_vm.get_vm())
    vol_size_after = test_lib.lib_get_root_volume(new_vm.get_vm()).size
    if set_size != vol_size_after:
        test_util.test_fail('Resize Root Volume failed, size = %s' % vol_size_after) 
    test_lib.lib_error_cleanup(test_obj_dict)
    test_util.test_pass('Create Template for Resize VM Test Success')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:34,代码来源:test_online_resize_vm_create_template.py


示例5: test

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

    #unit is KB
    volume_bandwidth = 5*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()
    vm_inv = vm.get_vm()
    test_stub.make_ssh_no_password(vm_inv)
    test_stub.install_fio(vm_inv)
    test_stub.test_fio_bandwidth(vm_inv, volume_bandwidth)
    if vm_ops.get_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid).volumeBandwidth != volume_bandwidth:
        test_util.test_fail('Retrieved disk qos not match')
    vm_ops.set_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid, volume_bandwidth/2)
    test_stub.test_fio_bandwidth(vm_inv, volume_bandwidth/2)
    vm_ops.del_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid)
    if test_stub.test_fio_bandwidth(vm_inv, volume_bandwidth/2, raise_exception=False):
        test_util.test_fail('disk qos is not expected to have limit after qos setting is deleted')
    vm_ops.delete_instance_offering(new_offering_uuid)
    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM Network QoS Test Pass')
开发者ID:mrwangxc,项目名称:zstack-woodpecker,代码行数:30,代码来源:test_del_disk_qos.py


示例6: test

def test():
    global vm
    vm_creation_option = test_util.VmOption()
    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()
    vm.stop() 
    vm.check()

    vol_size = test_lib.lib_get_root_volume(vm.get_vm()).size
    volume_uuid = test_lib.lib_get_root_volume(vm.get_vm()).uuid
    set_size = 1024*1024*1024*5
    vol_ops.resize_volume(volume_uuid, set_size)
    vm.update()
    vol_size_after = test_lib.lib_get_root_volume(vm.get_vm()).size
    if set_size != vol_size_after:
        test_util.test_fail('Resize Root Volume failed, size = %s' % vol_size_after)

    vm.start()
    set_size = 1024*1024*1024*6   
    vol_ops.resize_volume(volume_uuid, set_size)
    vm.update()
    vol_size_after = test_lib.lib_get_root_volume(vm.get_vm()).size
    if set_size != vol_size_after:
        test_util.test_fail('Resize Root Volume failed, size = %s' % vol_size_after)    

    vm.destroy()
    test_util.test_pass('Resize VM Test Success')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:29,代码来源:test_resize_vm.py


示例7: test

def test():
    if res_ops.query_resource(res_ops.SFTP_BACKUP_STORAGE):
        test_util.test_skip("sftp backupstorage doesn't support for clone test. Skip test")
    global vm
    vm_creation_option = test_util.VmOption()
    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)
    test_obj_dict.add_vm(vm)
    vm.check()

    vol_size = test_lib.lib_get_root_volume(vm.get_vm()).size
    volume_uuid = test_lib.lib_get_root_volume(vm.get_vm()).uuid
    set_size = 1024*1024*1024*5
    vol_ops.resize_volume(volume_uuid, set_size)
    vm.update()
    vol_size_after = test_lib.lib_get_root_volume(vm.get_vm()).size
    if set_size != vol_size_after:
        test_util.test_fail('Resize Root Volume failed, size = %s' % vol_size_after)

    new_vm = vm.clone(['vm_clone'])[0]
    test_obj_dict.add_vm(new_vm)
    new_volume_uuid = test_lib.lib_get_root_volume_uuid(new_vm.get_vm())
    vol_size_after = test_lib.lib_get_root_volume(new_vm.get_vm()).size
    if set_size != vol_size_after:
        test_util.test_fail('Resize Root Volume failed, size = %s' % vol_size_after) 
    test_lib.lib_error_cleanup(test_obj_dict)
    test_util.test_pass('Resize VM Snapshot Test Success')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:28,代码来源:test_online_resize_vm_clone.py


示例8: resize_rvol

def resize_rvol(vm_obj):
    vol_size = test_lib.lib_get_root_volume(vm_obj.get_vm()).size
    volume_uuid = test_lib.lib_get_root_volume(vm_obj.get_vm()).uuid
    set_size = 1024 * 1024 * 1024 + int(vol_size)
    vol_ops.resize_volume(volume_uuid, set_size)
    vm_obj.update()
    vol_size_after = test_lib.lib_get_root_volume(vm_obj.get_vm()).size
    # if set_size != vol_size_after:
    #     test_util.test_fail('Resize Root Volume failed, size = %s' % vol_size_after)
    # vm_obj.check()
    test_lib.lib_wait_target_up(vm_obj.get_vm().vmNics[0].ip, 22, 300)
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:11,代码来源:test_del_backup_full.py


示例9: test

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

    #unit is KB
    write_bandwidth = 5*1024*1024
    read_bandwidth = 10*1024*1024
    new_offering = test_lib.lib_create_instance_offering(read_bandwidth=read_bandwidth, write_bandwidth=write_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()
    vm_inv = vm.get_vm()
    test_stub.make_ssh_no_password(vm_inv)
    test_stub.install_fio(vm_inv)
#     test_stub.test_fio_bandwidth(vm_inv, read_bandwidth)
    vm_ops.set_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid, read_bandwidth*2)
    if vm_ops.get_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid).volumeBandwidth != read_bandwidth*2:
        test_util.test_fail('Retrieved disk qos not match')
    if vm_ops.get_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid).volumeBandwidthRead == read_bandwidth:
        test_util.test_fail('read qos must be cleared after set total qos')
    if vm_ops.get_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid).volumeBandwidthWrite == write_bandwidth:
        test_util.test_fail('write qos must be cleared after set total qos')

    vm_ops.set_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid, read_bandwidth*2, 'read')
    if vm_ops.get_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid).volumeBandwidthRead != read_bandwidth*2:
        test_util.test_fail('Retrieved disk qos not match')

    test_stub.test_fio_bandwidth(vm_inv, read_bandwidth*2, '/dev/vda')
    vm_ops.del_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid, mode='all')

    if test_stub.test_fio_bandwidth(vm_inv, read_bandwidth, '/dev/vda', raise_exception=False):
        test_util.test_fail('disk qos is not expected to have limit after qos setting is deleted')

    vm_ops.set_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid, write_bandwidth*2, 'write')
    if vm_ops.get_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid).volumeBandwidthWrite != write_bandwidth*2:
        test_util.test_fail('Retrieved disk qos not match')

    test_stub.test_fio_bandwidth(vm_inv, write_bandwidth*2)
    vm_ops.del_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid, mode='all')

    if test_stub.test_fio_bandwidth(vm_inv, write_bandwidth, raise_exception=False):
        test_util.test_fail('disk qos is not expected to have limit after qos setting is deleted')


    vm_ops.delete_instance_offering(new_offering_uuid)
    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM Network QoS Test Pass')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:53,代码来源:test_del_disk_rw_qos.py


示例10: test

def test():
    ps_inv = res_ops.query_resource(res_ops.PRIMARY_STORAGE)
    ceph_ps = [ps for ps in ps_inv if ps.type == 'Ceph']
    if not ceph_ps:
        test_util.test_skip('Skip test as there is not Ceph primary storage')
    
    flavor = case_flavor[os.getenv('CASE_FLAVOR')]
    
    if flavor['shared_vm']:
        multi_ps.create_vm(image_name="ttylinux", ps_type="SharedBlock")
    else:
        multi_ps.create_vm(image_name="ttylinux", ps_type="Ceph")
    multi_ps.create_data_volume(vms=multi_ps.vm, ps_type='SharedBlock')
    multi_ps.create_data_volume(vms= multi_ps.vm, ps_type='Ceph')

    vm = multi_ps.vm[0]
    last_data_volumes_uuids = []
    last_data_volumes = test_lib.lib_get_data_volumes(vm.get_vm())
    for data_volume in last_data_volumes:
        last_data_volumes_uuids.append(data_volume.uuid)
    last_l3network_uuid = test_lib.lib_get_l3s_uuid_by_vm(vm.get_vm())
    last_primarystorage_uuid = test_lib.lib_get_root_volume(vm.get_vm()).primaryStorageUuid
    vm.stop()

    if flavor['imagestore_bs']:
        image_uuid = test_lib.lib_get_image_by_name("image_for_sg_test", bs_type="ImageStoreBackupStorage").uuid
    else:
        image_uuid = test_lib.lib_get_image_by_name("image_for_sg_test", bs_type="Ceph").uuid
    vm_ops.change_vm_image(vm.get_vm().uuid, image_uuid)
    vm.start()
    vm.update()

    #check whether the vm is running successfully
    if not test_lib.lib_wait_target_up(vm.get_vm().vmNics[0].ip, 22, 1200):
        test_util.test_fail('VM:%s is not startup in 1200 seconds.' % vm.get_vm().uuid)
    #check whether data volumes attached to the vm has changed
    now_data_volumes_uuids = []
    now_data_volumes = test_lib.lib_get_data_volumes(vm.get_vm())
    for data_volume in now_data_volumes:
        now_data_volumes_uuids.append(data_volume.uuid)
    if set(last_data_volumes_uuids) != set(now_data_volumes_uuids):
        test_util.test_fail('Change Vm Image Failed.Data volumes changed.')
    #check whether the network config has changed
    now_l3network_uuid = test_lib.lib_get_l3s_uuid_by_vm(vm.get_vm())
    if now_l3network_uuid != last_l3network_uuid:
        test_util.test_fail('Change VM Image Failed.The Network config has changed.')
    #check whether primarystorage has changed
    now_primarystorage_uuid = test_lib.lib_get_root_volume(vm.get_vm()).primaryStorageUuid
    if now_primarystorage_uuid != last_primarystorage_uuid:
        test_util.test_fail('Change VM Image Failed.Primarystorage has changed.')

    test_util.test_pass('Change Vm Image Test Success')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:52,代码来源:test_change_vm_image.py


示例11: compare

def compare(ps, vm, backup):
    test_util.test_logger("-----------------compare----------------")
    # find vm_host
    host = test_lib.lib_find_host_by_vm(vm.vm)
    bs = res_ops.query_resource(res_ops.BACKUP_STORAGE)[0]

    root_volume = test_lib.lib_get_root_volume(vm.get_vm())
    vm_path = root_volume.installPath
    if ps.type == "SharedBlock":
        vm_path = "/dev/" + root_volume.installPath.split("/")[2] + "/" + root_volume.installPath.split("/")[3]
    test_util.test_logger(vm_path)

    name = backup.backupStorageRefs[0].installPath.split("/")[2]
    id = backup.backupStorageRefs[0].installPath.split("/")[3]
    # compare vm_root_volume & image
    cmd = "mkdir /root/%s;" \
          "/usr/local/zstack/imagestore/bin/zstcli " \
          "-rootca=/var/lib/zstack/imagestorebackupstorage/package/certs/ca.pem " \
          "-url=%s:8000 " \
          "pull -installpath /root/%s/old.qcow2 %s:%s;" \
          "qemu-img compare %s /root/%s/old.qcow2;" % (id, bs.hostname, id, name, id, vm_path, id)
    # clean image
    result = test_lib.lib_execute_ssh_cmd(host.managementIp, "root", "password", cmd, timeout=300)
    if result != "Images are identical.\n":
        test_util.test_fail("compare vm_root_volume & image created by backup")
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:25,代码来源:test_backup_vm.py


示例12: test

def test():
    ps_env = test_stub.PSEnvChecker()

    ps, another = ps_env.get_two_ps()
    disk_offering_uuids = [random.choice(res_ops.get_resource(res_ops.DISK_OFFERING)).uuid]

    vm = test_stub.create_iso_vm_with_random_offering(vm_name='iso_vm', l3_name='l3VlanNetworkName1')
    test_obj_dict.add_vm(vm)

    for root_volume_ps_uuid in [None, ps.uuid]:
        for data_vol_ps_uuid in [None, another.uuid]:
            if ps_env.is_local_shared_env or ps_env.is_sb_ceph_env:
                if type(root_volume_ps_uuid) != type(data_vol_ps_uuid):
                    continue
            vm = test_stub.create_iso_vm_with_random_offering(vm_name='test_iso_vm',
                                                              disk_offering_uuids=disk_offering_uuids if data_vol_ps_uuid else None,
                                                              ps_uuid=root_volume_ps_uuid,
                                                              l3_name='l3VlanNetworkName1',
                                                              system_tags=['primaryStorageUuidForDataVolume::{}'.format(data_vol_ps_uuid)] if data_vol_ps_uuid else None)
            if root_volume_ps_uuid:
                root_vol = test_lib.lib_get_root_volume(vm.get_vm())
                assert root_vol.primaryStorageUuid == ps.uuid

            if data_vol_ps_uuid:
                data_vol_list = [vol for vol in vm.get_vm().allVolumes if vol.type != 'Root']
                for data_vol in data_vol_list:
                    assert data_vol.primaryStorageUuid == another.uuid

            test_obj_dict.add_vm(vm)

    test_util.test_pass('Multi PrimaryStorage Test Pass')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:31,代码来源:test_create_iso_vm_multi_ps.py


示例13: test

def test():
    vm = test_stub.create_vm(vm_name = vn_prefix)
    test_obj_dict.add_vm(vm)
    backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm.vm)
    for bs in backup_storage_list:
        if bs.type in [inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE, inventory.CEPH_BACKUP_STORAGE_TYPE]:
            break
    else:
        vm.destroy()
        test_util.test_skip('Not find image store or ceph type backup storage.')

    vm1 = test_stub.create_vm(vm_name = vn_prefix)
    test_obj_dict.add_vm(vm1)
    vm_root_volume_inv = test_lib.lib_get_root_volume(vm.get_vm())
    test_util.test_dsc('create snapshot and check')
    snapshots = test_obj_dict.get_volume_snapshot(vm_root_volume_inv.uuid)
    snapshots.set_utility_vm(vm1)
    snapshots.create_snapshot('create_root_snapshot1')
    snapshot1 = snapshots.get_current_snapshot()
    snapshots.create_snapshot('create_root_snapshot2')

    snapshots.delete_snapshot(snapshot1)
    vm.reboot()
    new_vm1 = vm.clone(vm_name1)[0]
    test_obj_dict.add_vm(new_vm1)
    vm.destroy()

    new_vm1.check()

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Clone VM Test with snapshot operations Success')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:31,代码来源:test_clone_vm_sp_ops.py


示例14: test

def test():
    global vm
    loop = 20
    count = 0
    vm_creation_option = test_util.VmOption()
    image_name = os.environ.get('imageName_net')
    l3_name = os.environ.get('l3VlanNetworkName1')
    vm = test_stub.create_vm("test_libvirt_snapshot_vm", image_name, l3_name)
    test_obj_dict.add_vm(vm)
    vm.check()

    volume_uuid = test_lib.lib_get_root_volume(vm.get_vm()).uuid
     
    snapshots = test_obj_dict.get_volume_snapshot(volume_uuid)
    snapshots.set_utility_vm(vm)
    while count <= loop:
        sp_name = "create_snapshot" + str(count)
        snapshots.create_snapshot(sp_name)
        snapshots.check()
        count += 1

    host = test_lib.lib_find_host_by_vm(vm.get_vm())
    result = test_lib.lib_execute_ssh_cmd(host.managementIp, 'root', 'password', 'service libvirtd restart')

    time.sleep(600)

    vm.check()
    snapshots.check()

    snapshots.delete()
    test_obj_dict.rm_volume_snapshot(snapshots)
    test_lib.lib_error_cleanup(test_obj_dict)
    test_util.test_pass('Libvirt restart with snapshot passed')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:33,代码来源:test_vm_snapshot_libvirt_restart.py


示例15: test

def test():
    global session_to
    global session_mc

    session_to = con_ops.change_global_config('identity', 'session.timeout', '720000')
    session_mc = con_ops.change_global_config('identity', 'session.maxConcurrent', '10000')
    test_util.test_dsc('Create test vm as utility vm')
    vm = test_stub.create_vlan_vm()
    test_obj_dict.add_vm(vm)
    #use root volume to skip add_checking_point
    test_util.test_dsc('Use root volume for snapshot testing')
    root_volume_inv = test_lib.lib_get_root_volume(vm.get_vm())
    root_volume = zstack_volume_header.ZstackTestVolume()
    root_volume.set_volume(root_volume_inv)
    root_volume.set_state(volume_header.ATTACHED)
    root_volume.set_target_vm(vm)
    test_obj_dict.add_volume(root_volume)
    vm.check()

    snapshots = test_obj_dict.get_volume_snapshot(root_volume.get_volume().uuid)
    snapshots.set_utility_vm(vm)

    ori_num = 100
    index = 1
    while index < 101:
        thread = threading.Thread(target=create_snapshot, args=(snapshots, index,))
        thread.start()
        index += 1

    while threading.activeCount() > 1:
        time.sleep(0.1)

    #snapshot.check() doesn't work for root volume
    #snapshots.check()
    #check if snapshot exists in install_path
    ps = test_lib.lib_get_primary_storage_by_vm(vm.get_vm())
    if ps.type == inventory.NFS_PRIMARY_STORAGE_TYPE or ps.type == inventory.LOCAL_STORAGE_TYPE:
        host = test_lib.lib_get_vm_host(vm.get_vm())
        for snapshot in snapshots.get_snapshot_list():
            snapshot_inv = snapshot.get_snapshot()
            sp_ps_install_path = snapshot_inv.primaryStorageInstallPath
            if test_lib.lib_check_file_exist(host, sp_ps_install_path):
                test_util.test_logger('Check result: snapshot %s is found in host %s in path %s' % (snapshot_inv.name, host.managementIp, sp_ps_install_path))
            else:
                test_lib.lib_robot_cleanup(test_obj_dict)
                test_util.test_fail('Check result: snapshot %s is not found in host %s in path %s' % (snapshot_inv.name, host.managementIp, sp_ps_install_path))
    else:
        test_util.test_logger('Skip check file install path for %s primary storage' % (ps.type))

    cond = res_ops.gen_query_conditions('volumeUuid', '=', root_volume.get_volume().uuid)
    sps_num = res_ops.query_resource_count(res_ops.VOLUME_SNAPSHOT, cond)

    if sps_num != ori_num:
        test_util.test_fail('Create %d snapshots, but only %d snapshots were successfully created' % (ori_num, sps_num))

    try:
        test_lib.lib_robot_cleanup(test_obj_dict)
    except:
        test_lib.test_logger('Delete VM may timeout')
    test_util.test_pass('Test create 100 snapshots simultaneously success')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:60,代码来源:test_crt_sp_simultaneously.py


示例16: test

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

    vm.stop()
    r_volume = zstack_volume_header.ZstackTestVolume()
    r_volume.set_volume(test_lib.lib_get_root_volume(vm.get_vm()))
    r_volume.set_state(volume_header.ATTACHED)

    test_util.test_dsc('Create volume template and check')
    bs_list = test_lib.lib_get_backup_storage_list_by_vm(vm.get_vm())
    vol_tmpt = r_volume.create_template([bs_list[0].uuid], 'new_data_template')
    test_obj_dict.add_image(vol_tmpt)

    test_util.test_dsc('Try to use data vol_tempt to Create VM. ')
    vm_option = vm.get_creation_option()
    vm_option.set_image_uuid(vol_tmpt.get_image().uuid)
    vm2 = zstack_vm_header.ZstackTestVm()
    vm2.set_creation_option(vm_option)
    try:
        vm2.create()
    except:
        test_util.test_logger('Expected exception, when creating VM by using Data Volume Template as root image')
    else:
        test_util.test_fail('VM can use data volume template to create VM')

    vol_tmpt.delete()
    test_obj_dict.rm_image(vol_tmpt)
    vm.destroy()
    test_util.test_pass('Create VM from Data Volume Template Test Success')
开发者ID:KevinDavidMitnick,项目名称:zstack-woodpecker,代码行数:31,代码来源:test_crt_vm_from_dvt.py


示例17: back_up

def back_up(vm_obj):
     global backup
     bs = res_ops.query_resource(res_ops.BACKUP_STORAGE)[0]
     backup_option = test_util.BackupOption()
     backup_option.set_name("test_compare")
     backup_option.set_volume_uuid(test_lib.lib_get_root_volume(vm_obj.get_vm()).uuid)
     backup_option.set_backupStorage_uuid(bs.uuid)
     backup = vol_ops.create_backup(backup_option)
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:8,代码来源:test_backup_replay_vm.py


示例18: delete_snapshot

def delete_snapshot(vm_obj):
    vol_obj = zstack_volume_header.ZstackTestVolume()
    vol_obj.set_volume(test_lib.lib_get_root_volume(vm_obj.get_vm()))
    snapshots_root = zstack_sp_header.ZstackVolumeSnapshot()
    snapshots_root.set_utility_vm(vm_obj)
    snapshots_root.set_target_volume(vol_obj)
    sp_list = snapshots_root.get_snapshot_list()
    if sp_list:
        snapshots_root.delete_snapshot(random.choice(sp_list))
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:9,代码来源:test_del_backup_full.py


示例19: create_snapshot

def create_snapshot(vm_obj):
    vol_obj = zstack_volume_header.ZstackTestVolume()
    vol_obj.set_volume(test_lib.lib_get_root_volume(vm_obj.get_vm()))
    snapshots_root = zstack_sp_header.ZstackVolumeSnapshot()
    snapshots_root.set_utility_vm(vm_obj)
    snapshots_root.set_target_volume(vol_obj)
    snapshots_root.create_snapshot('create_data_snapshot1')
    snapshots_root.check()
    sp1 = snapshots_root.get_current_snapshot()
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:9,代码来源:test_del_backup_full.py


示例20: test

def test():
    ps_env = test_stub.PSEnvChecker()

    local_nfs_env = ps_env.is_local_nfs_env
    local_smp_env = ps_env.is_local_smp_env

    local_ps, another_ps = ps_env.get_two_ps()

    vm = test_stub.create_multi_vms(name_prefix='test-', count=1)[0]
    test_obj_dict.add_vm(vm)

    volume_in_local = []
    if not local_nfs_env:
        volume_in_local = test_stub.create_multi_volumes(count=VOLUME_NUMBER, ps=local_ps,
                                                         host_uuid=test_lib.lib_get_vm_host(vm.get_vm()).uuid)

    volume_in_another = test_stub.create_multi_volumes(count=VOLUME_NUMBER, ps=another_ps,
                                                       host_uuid=None if local_nfs_env else test_lib.lib_get_vm_host(vm.get_vm()).uuid)

    for volume in volume_in_local + volume_in_another:
        test_obj_dict.add_volume(volume)

    for volume in volume_in_local + volume_in_another:
        volume.attach(vm)
        volume.check()
    vm.check()

    for volume in volume_in_local + volume_in_another:
        volume.detach()
        volume.check()
    vm.check()

    target_host = test_lib.lib_find_random_host(vm.get_vm())

    vm.stop()
    vm.check()
    vol_ops.migrate_volume(test_lib.lib_get_root_volume(vm.get_vm()).uuid, target_host.uuid)

    for volume in volume_in_local:
        vol_ops.migrate_volume(volume.get_volume().uuid, target_host.uuid)

    if not (local_nfs_env or local_smp_env):
        for volume in volume_in_another:
            vol_ops.migrate_volume(volume.get_volume().uuid, target_host.uuid)

    for volume in volume_in_local + volume_in_another:
        volume.attach(vm)
        volume.check()

    vm.start()
    vm.check()

    for volume in volume_in_local + volume_in_another:
        assert volume.get_volume().vmInstanceUuid == vm.get_vm().uuid

    test_util.test_pass('Multi PrimaryStorage Test Pass')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:56,代码来源:test_cold_migrate_multi_ps.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python test_lib.lib_get_test_stub函数代码示例发布时间:2022-05-26
下一篇:
Python test_lib.lib_get_l3_by_name函数代码示例发布时间: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