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

Python test_lib.lib_get_image_by_name函数代码示例

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

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



在下文中一共展示了lib_get_image_by_name函数的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():
    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


示例3: test

def test():
    test_util.test_dsc('''Will mainly doing random test for all kinds of snapshot operations. VM, Volume and Image operations will also be tested. If reach 1 hour successful running condition, testing will success and quit.  SG actions, and VIP actions are removed in this robot test.
        VM resources: a special Utility vm is required to do volume attach/detach operation. 
        ''')
    target_running_vm = 4

    public_l3 = test_lib.lib_get_l3_by_name(os.environ.get('l3PublicNetworkName'))

    vm_create_option = test_util.VmOption()
    #image has to use virtual router image, as it needs to do port checking
    vm_create_option.set_image_uuid(test_lib.lib_get_image_by_name(img_name=os.environ.get('imageName_net')).uuid)

    utility_vm_create_option = test_util.VmOption()
    utility_vm_create_option.set_image_uuid(test_lib.lib_get_image_by_name(img_name=os.environ.get('imageName_net')).uuid)
    l3_uuid = test_lib.lib_get_l3_by_name(os.environ.get('l3VlanNetworkName1')).uuid
    utility_vm_create_option.set_l3_uuids([l3_uuid])

    priority_actions = test_state.TestAction.snapshot_actions * 4
    utility_vm = test_lib.lib_create_vm(utility_vm_create_option)
    test_dict.add_utility_vm(utility_vm)
    if os.environ.get('ZSTACK_SIMULATOR') != "yes":
        utility_vm.check()

    test_util.test_dsc('Random Test Begin. Test target: 4 coexisting running VM (not include VR and SG target test VMs.).')
    robot_test_obj = test_util.Robot_Test_Object()
    robot_test_obj.set_test_dict(test_dict)
    robot_test_obj.set_vm_creation_option(vm_create_option)
    priority_action_obj = action_select.ActionPriority()
    priority_action_obj.add_priority_action_list(priority_actions)
    robot_test_obj.set_priority_actions(priority_action_obj)
    robot_test_obj.set_exclusive_actions_list(\
            test_state.TestAction.vip_actions + \
            test_state.TestAction.image_actions + \
            test_state.TestAction.sg_actions + \
            [ test_state.TestAction.create_volume ])
    robot_test_obj.set_public_l3(public_l3)
    robot_test_obj.set_utility_vm(utility_vm)
    robot_test_obj.set_random_type(action_select.fair_strategy)

    rounds = 1
    current_time = time.time()
    timeout_time = current_time + 3600
    while time.time() <= timeout_time:
        test_util.test_dsc('New round %s starts: random operation pickup.' % rounds)
        test_lib.lib_vm_random_operation(robot_test_obj)
        test_util.test_dsc('===============Round %s finished. Begin status checking.================' % rounds)
        rounds += 1
        test_lib.lib_robot_status_check(test_dict)

    test_util.test_dsc('Reach test pass exit criterial: 1 hour.')
    test_lib.lib_robot_cleanup(test_dict)
    test_util.test_pass('Snapshots Robot Test Success')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:52,代码来源:test_scsi_volume_snapshot_robot_1_hour.py


示例4: test

def test():
    test_util.test_dsc('''
        Will doing random test for VIP operations, including VIP create/delete, PF create/attach/detach/remove, EIP create/attach/detach/remove. VM operations will also be tested. If reach max 4 coexisting running vm, testing will success and quit.  SG actions, Volume actions and Image actions are removed in this robot test.
        VM resources: VIP testing needs at least 3 VRs are running. 
        ''')
    target_running_vm = 4

    public_l3 = test_lib.lib_get_l3_by_name(os.environ.get('l3PublicNetworkName'))

    vm_create_option = test_util.VmOption()
    #image has to use virtual router image, as it needs to do port checking
    vm_create_option.set_image_uuid(test_lib.lib_get_image_by_name(img_name=os.environ.get('imageName_net')).uuid)

    priority_actions = test_state.TestAction.snapshot_actions * 4
    utility_vm_create_option = test_util.VmOption()
    utility_vm_create_option.set_image_uuid(test_lib.lib_get_image_by_name(img_name=os.environ.get('imageName_net')).uuid)
    l3_uuid = test_lib.lib_get_l3_by_name(os.environ.get('l3VlanNetworkName1')).uuid
    utility_vm_create_option.set_l3_uuids([l3_uuid])
    utility_vm = test_lib.lib_create_vm(utility_vm_create_option)
    test_dict.add_utility_vm(utility_vm)
    if os.environ.get('ZSTACK_SIMULATOR') != "yes":
        utility_vm.check()

    test_util.test_dsc('Random Test Begin. Test target: 4 coexisting running VM (not include VR and SG target test VMs.).')
    robot_test_obj = test_util.Robot_Test_Object()
    robot_test_obj.set_test_dict(test_dict)
    robot_test_obj.set_vm_creation_option(vm_create_option)
    priority_action_obj = action_select.ActionPriority()
    priority_action_obj.add_priority_action_list(priority_actions)
    robot_test_obj.set_priority_actions(priority_action_obj)
    robot_test_obj.set_exclusive_actions_list(\
            test_state.TestAction.vip_actions + \
            test_state.TestAction.image_actions + \
            test_state.TestAction.sg_actions + \
            [test_state.TestAction.create_volume])
    robot_test_obj.set_public_l3(public_l3)
    robot_test_obj.set_utility_vm(utility_vm)

    rounds = 1
    while len(test_dict.get_vm_list(vm_header.RUNNING)) < target_running_vm:
        test_util.test_dsc('New round %s starts: random operation pickup.' % rounds)
        test_lib.lib_vm_random_operation(robot_test_obj)
        test_util.test_dsc('===============Round %s finished. Begin status checking.================' % rounds)
        rounds += 1
        test_lib.lib_robot_status_check(test_dict)

    test_util.test_dsc('Reach test pass exit criterial.')
    test_lib.lib_robot_cleanup(test_dict)
    test_util.test_pass('Snapshots Robot Test Success')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:49,代码来源:test_scsi_volume_4vm_snapshot_robot.py


示例5: test

def test():
    test_util.test_dsc('Test VM online change instance offering')

    image_name = os.environ.get('imageName_net')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    l3_name = os.environ.get('l3VlanNetworkName1')
    l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
    l3_net_list = [l3_net_uuid]

    vm = test_stub.create_vm(l3_net_list, image_uuid, 'online_chg_offering_vm', system_tags=['instanceOfferingOnlinechange::true'])
    test_obj_dict.add_vm(vm)

    vm.check()
    cpuNum = 2
    memorySize = 666 * 1024 * 1024
    new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\
            memorySize = memorySize)

    test_obj_dict.add_instance_offering(new_offering)
    new_offering_uuid = new_offering.uuid

    new_offering2 = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\
            memorySize = memorySize)
    test_obj_dict.add_instance_offering(new_offering2)
    new_offering_uuid2 = new_offering2.uuid

    vm.change_instance_offering(new_offering_uuid)
    vm.change_instance_offering(new_offering_uuid2)

    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM online change instance offering Test Pass')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:32,代码来源:test_chg_instance_offering_online3.py


示例6: test

def test():
    global vm
    vip_s_vm_cfg_lst = test_stub.get_s_vm_cfg_lst_vip_bind(test_lib.all_scenario_config, test_lib.scenario_file)
    if len(vip_s_vm_cfg_lst) != 1:
        test_util.test_fail('vip has been running on %d host(s)' % len(vip_s_vm_cfg_lst))
    vm_creation_option = test_util.VmOption()
    image_name = os.environ.get('imageName_s')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    l3_name = os.environ.get('l3VlanNetworkName1')

    l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
    vm_creation_option.set_l3_uuids([l3_net_uuid])
    vm_creation_option.set_image_uuid(image_uuid)
    vm_creation_option.set_name('multihost_basic_vm')

    for i in range(1, 10):
        vm_creation_option.set_cpu_num(random.choice(VM_CPU))
        vm_creation_option.set_memory_size(random.choice(VM_MEM))
        vm = test_vm_header.ZstackTestVm()
        vm.set_creation_option(vm_creation_option)
        vm.create()
        vm_uuid = vm.get_vm()['uuid']
        vm.check()
        time.sleep(30)
        prometheus_test(vm_uuid)
        vm.destroy()
        vm.expunge()
        time.sleep(30)
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:28,代码来源:test_prometheus_vm.py


示例7: test

def test():
    test_util.test_dsc('Test VM online change instance offering')

    image_name = os.environ.get('imageName_net')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    l3_name = os.environ.get('l3VlanNetworkName1')
    l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
    l3_net_list = [l3_net_uuid]

    vm = test_stub.create_vm(l3_net_list, image_uuid, 'online_chg_offering_vm', system_tags=['instanceOfferingOnlinechange::true'])
    test_obj_dict.add_vm(vm)
    vm.check()
    cpuNum = 1
    cpuSpeed = 222
    memorySize = 666 * 1024 * 1024
    new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\
            cpuSpeed = cpuSpeed, memorySize = memorySize)
    test_obj_dict.add_instance_offering(new_offering)
    new_offering_uuid = new_offering.uuid
    vm.change_instance_offering(new_offering_uuid)
    vm.check()
    test_lib.lib_execute_command_in_vm(vm.get_vm(), 'ls -d /sys/devices/system/cpu/cpu*')
    test_lib.lib_execute_command_in_vm(vm.get_vm(), 'ls -d /sys/devices/system/memory/memory*')

    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM online change instance offering Test Pass')
开发者ID:mrwangxc,项目名称:zstack-woodpecker,代码行数:27,代码来源:test_chg_instance_offering_online4.py


示例8: create_vm

def create_vm(vm_name = 'vm_for_baremetal', image_name = None, \
             l3_name = None, instance_offering_uuid = None, \
             host_uuid = None, disk_offering_uuid = None, cluster_uuid = None, \
             system_tags = None, password = None, session_uuid = None):
    if not instance_offering_uuid:
        instance_offering_name = os.environ.get('instanceOfferingName_m')
        instance_offering_uuid = test_lib.lib_get_instance_offering_by_name(instance_offering_name).uuid
    if not image_name:
        image_name = os.environ.get('imageName_s')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    if not l3_name:
        l3_name = os.environ.get('scenl3VPCNetworkName1')
    l3_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid

    vm_creation_option = test_util.VmOption()
    vm_creation_option.set_name(vm_name)
    vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
    vm_creation_option.set_image_uuid(image_uuid)
    vm_creation_option.set_l3_uuids([l3_uuid])
    if cluster_uuid:
        vm_creation_option.set_cluster_uuid(cluster_uuid)
    if system_tags: 
        vm_creation_option.set_system_tags(system_tags)
    if disk_offering_uuid:
        vm_creation_option.set_data_disk_uuids(disk_offering_uuid)
    if password:
        vm_creation_option.set_root_password(password)
    if host_uuid:
        vm_creation_option.set_host_uuid(host_uuid)
    if session_uuid:
        vm_creation_option.set_session_uuid(session_uuid)
    vm = zstack_vm_header.ZstackTestVm()
    vm.set_creation_option(vm_creation_option)
    vm.create()
    return vm
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:35,代码来源:test_stub.py


示例9: prepare_host_with_different_cpu_scenario

def prepare_host_with_different_cpu_scenario():
    """
    Prepare vms in hosts
    """
    global pre_vms
    vm_creation_option = test_util.VmOption()
    image_name = os.environ.get('imageName_s')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    l3_name = os.environ.get('l3NoVlanNetworkName1')
    #l3_name = os.environ.get('l3PublicNetworkName')


    l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
    conditions = res_ops.gen_query_conditions('type', '=', 'UserVm')
    instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid
    #instance_offering_uuid = new_offering.uuid
    vm_creation_option.set_l3_uuids([l3_net_uuid])
    vm_creation_option.set_image_uuid(image_uuid)
    vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)

    ps_uuid = res_ops.query_resource(res_ops.PRIMARY_STORAGE)[0].uuid
    hosts = test_lib.lib_find_hosts_by_ps_uuid(ps_uuid)
    host_id = 0
    for host, max_vm_num in zip(hosts,[2,3,1,2]):
        host_id +=1
        for i in range(max_vm_num):
            print "host_id=%s; i=%s" %(host_id, i)
            vm_creation_option.set_name('pre-create-vm-%s-%s' %(host_id, i))
            vm = test_vm_header.ZstackTestVm()
            vm_creation_option.set_host_uuid(host.uuid)
            vm.set_creation_option(vm_creation_option)
            vm.create()
            pre_vms.append(vm)
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:33,代码来源:test_allocator_strategy_crt_vm_cpu.py


示例10: test

def test():
    global vm
    vm_creation_option = test_util.VmOption()
    image_name = os.environ.get('imageName_s')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    l3_name = os.environ.get('l3VlanNetworkName1')

    l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
    vm_creation_option.set_l3_uuids([l3_net_uuid])
    vm_creation_option.set_image_uuid(image_uuid)
    vm_creation_option.set_name('multihost_basic_vm')

    for i in range(1, 10):
        vm_creation_option.set_cpu_num(random.choice(VM_CPU))
        vm_creation_option.set_memory_size(random.choice(VM_MEM))
        vm = test_vm_header.ZstackTestVm()
        vm.set_creation_option(vm_creation_option)
        vm.create()
        vm_uuid = vm.get_vm()['uuid']
        vm.check()
        time.sleep(30)
        prometheus_test(vm_uuid)
        vm.destroy()
        vm.expunge()
        time.sleep(30)
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:25,代码来源:test_prometheus_vm.py


示例11: create_vm

def create_vm(vm_name='virt-vm', \
        image_name = None, \
        l3_name = None, \
        instance_offering_uuid = None, \
        host_uuid = None, \
        disk_offering_uuids=None, system_tags=None, session_uuid = None):

    if not image_name:
        image_name = os.environ.get('imageName_net') 
    if not l3_name:
        l3_name = os.environ.get('l3PublicNetworkName')

    vm_creation_option = test_util.VmOption()
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
    if not instance_offering_uuid:
	instance_offering_name = os.environ.get('instanceOfferingName_s')
        instance_offering_uuid = test_lib.lib_get_instance_offering_by_name(instance_offering_name).uuid

    vm_creation_option.set_l3_uuids([l3_net_uuid])
    vm_creation_option.set_image_uuid(image_uuid)
    vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
    vm_creation_option.set_name(vm_name)
    vm_creation_option.set_system_tags(system_tags)
    vm_creation_option.set_data_disk_uuids(disk_offering_uuids)
    if host_uuid:
        vm_creation_option.set_host_uuid(host_uuid)
    vm = zstack_vm_header.ZstackTestVm()
    vm.set_creation_option(vm_creation_option)
    vm.create()
    return vm 
开发者ID:TinaL3,项目名称:zstack-woodpecker,代码行数:31,代码来源:test_stub.py


示例12: test

def test():
    image_name = os.environ.get('imageName_net')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    l3_name = os.environ.get('l3VlanNetworkName1')

    l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
    l3_uuid_list = [l3_net_uuid]
    vm_creation_option = test_util.VmOption()
    conditions = res_ops.gen_query_conditions('type', '=', 'UserVm')
    instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid
    times = 1
    vm_name = '24hr_vm-'
    vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
    vm_creation_option.set_l3_uuids(l3_uuid_list)
    vm_creation_option.set_image_uuid(image_uuid)
    #vm_creation_option.set_data_disk_uuids(disk_offering_uuids)
    current_time = time.time()
    end_time = current_time + duration
    while current_time < end_time:
        times = times + 1
        vm_creation_option.set_name(vm_name + str(times))
        vm = zstack_vm_header.ZstackTestVm()
        vm.set_creation_option(vm_creation_option)
        vm.create()
        time.sleep(5)
        vm.destroy()
    test_util.test_pass('Keep create/destroy %s VMs in 24 hrs pass' % times)
开发者ID:KevinDavidMitnick,项目名称:zstack-woodpecker,代码行数:27,代码来源:test_poc_24hr_create_destroy.py


示例13: test

def test():
    global session_uuid
    global session_to
    global session_mc
    vm_num = os.environ.get('ZSTACK_TEST_NUM')
    if not vm_num:
        vm_num = 0
    else:
        vm_num = int(vm_num)

    test_util.test_logger('ZSTACK_THREAD_THRESHOLD is %d' % thread_threshold)
    test_util.test_logger('ZSTACK_TEST_NUM is %d' % vm_num)

    org_num = vm_num
    vm_creation_option = test_util.VmOption()
    image_name = os.environ.get('imageName_s')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    l3_name = os.environ.get('l3VlanNetworkName1')
    conditions = res_ops.gen_query_conditions('name', '=', l3_name)
    l3_uuid = res_ops.query_resource_with_num(res_ops.L3_NETWORK, conditions, \
            session_uuid, start = 0, limit = 1)[0].uuid
    vm_creation_option.set_l3_uuids([l3_uuid])
    conditions = res_ops.gen_query_conditions('type', '=', 'UserVm')
    instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid
    vm_creation_option.set_image_uuid(image_uuid)
    vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
    session_uuid = acc_ops.login_as_admin()

    #change account session timeout. 
    session_to = con_ops.change_global_config('identity', 'session.timeout', '720000', session_uuid)
    session_mc = con_ops.change_global_config('identity', 'session.maxConcurrent', '10000', session_uuid)

    vm_creation_option.set_session_uuid(session_uuid)

    vm = test_vm_header.ZstackTestVm()
    random_name = random.random()
    vm_name = 'multihost_basic_vm_%s' % str(random_name)
    vm_creation_option.set_name(vm_name)

    while vm_num > 0:
        check_thread_exception()
        vm.set_creation_option(vm_creation_option)
        vm_num -= 1
        thread = threading.Thread(target=create_vm, args=(vm,))
        while threading.active_count() > thread_threshold:
            time.sleep(1)
        thread.start()

    while threading.active_count() > 1:
        time.sleep(0.01)

    cond = res_ops.gen_query_conditions('name', '=', vm_name)
    vms = res_ops.query_resource_count(res_ops.VM_INSTANCE, cond, session_uuid)
    con_ops.change_global_config('identity', 'session.timeout', session_to, session_uuid)
    con_ops.change_global_config('identity', 'session.maxConcurrent', session_mc, session_uuid)
    acc_ops.logout(session_uuid)
    if vms == org_num:
        test_util.test_pass('Create %d VMs Test Success' % org_num)
    else:
        test_util.test_fail('Create %d VMs Test Failed. Only find %d VMs.' % (org_num, vms))
开发者ID:mrwangxc,项目名称:zstack-woodpecker,代码行数:60,代码来源:test_crt_vm_with_vr_by_max_threads.py


示例14: test

def test():
    global vm, host3_uuid

    if test_lib.lib_get_ha_enable() != 'true':
        test_util.test_skip("vm ha not enabled. Skip test")

    conf_ops.change_global_config('ha', 'allow.slibing.cross.clusters', 'true')

    vm_creation_option = test_util.VmOption()
    image_name = os.environ.get('imageName_s')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    #l3_name = os.environ.get('l3NoVlanNetworkName1')
    #l3_name = os.environ.get('l3VlanNetworkName1')
    l3_name = os.environ.get('l3PublicNetworkName')
    host3_name = os.environ.get('hostName3')
    host4_name = os.environ.get('hostName4')

    conditions1 = res_ops.gen_query_conditions('name', '=', host3_name)
    host3_uuid = res_ops.query_resource(res_ops.HOST, conditions1)[0].uuid
    host3_ip = res_ops.query_resource(res_ops.HOST, conditions1)[0].managementIp

    conditions2 = res_ops.gen_query_conditions('name', '=', host4_name)
    host4_uuid = res_ops.query_resource(res_ops.HOST, conditions2)[0].uuid
    host4_ip = res_ops.query_resource(res_ops.HOST, conditions2)[0].managementIp

    l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
    conditions = res_ops.gen_query_conditions('type', '=', 'UserVm')
    instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid
    vm_creation_option.set_l3_uuids([l3_net_uuid])
    vm_creation_option.set_image_uuid(image_uuid)
    vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
    vm_creation_option.set_name('multihost_basic_vm')
    vm_creation_option.set_host_uuid(host3_uuid)
    vm = test_vm_header.ZstackTestVm()
    vm.set_creation_option(vm_creation_option)
    vm.create()
    time.sleep(30)
    ha_ops.set_vm_instance_ha_level(vm.get_vm().uuid, "NeverStop")
    time.sleep(5)
    vm.check()
    
    ssh_cmd1 = 'ssh  -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % host3_ip    
    cmd = '%s "poweroff" ' % ssh_cmd1
    process_result = test_stub.execute_shell_in_process(cmd, tmp_file)
        
    time.sleep(360)
    host3_status = res_ops.query_resource(res_ops.HOST, conditions1)[0].status    
    if host3_status == "Disconnected":
        conditions3 = res_ops.gen_query_conditions('uuid', '=', vm.vm.uuid)
        vm_status = res_ops.query_resource(res_ops.VM_INSTANCE, conditions3)[0].state
        vm_host_uuid = res_ops.query_resource(res_ops.VM_INSTANCE, conditions3)[0].hostUuid
        if vm_status != "Running" or vm_host_uuid != host4_uuid:         
            test_util.test_fail('Test fail vm status: %s, vm_host_uuid: %s,' %(vm_status, vm_host_uuid))
    vm.destroy()
    conf_ops.change_global_config('ha', 'allow.slibing.cross.clusters', 'false')

    conditions4 = res_ops.gen_query_conditions('vmNics.ip', '=', host3_ip)
    vm3_uuid = sce_ops.query_resource(zstack_management_ip, res_ops.VM_INSTANCE, conditions4).inventories[0].uuid
    sce_ops.start_vm(zstack_management_ip, vm3_uuid)
    test_util.test_pass('VM auto ha across cluster Test Success')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:60,代码来源:test_ha_vm_auto_across_cluster_migration.py


示例15: test

def test():
    img_option = test_util.ImageOption()
    UEFI_image_url = os.environ.get('imageUrl_linux_UEFI')
    image_name = os.environ.get('imageName_linux_UEFI')
    img_option.set_name(image_name)
    bs_uuid = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE, [], None)[0].uuid
    img_option.set_backup_storage_uuid_list([bs_uuid])
    img_option.set_format('qcow2')
    img_option.set_url(UEFI_image_url)
    img_option.set_system_tags("bootMode::UEFI")
    image_inv = img_ops.add_root_volume_template(img_option)
    image = test_image.ZstackTestImage()
    image.set_image(image_inv)
    image.set_creation_option(img_option)
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    test_obj_dict.add_image(image)
    vm = test_stub.create_vm(image_name = os.environ.get('imageName_linux_UEFI'))
    test_obj_dict.add_vm(vm)
    vm.check()
    vm_ip = vm.get_vm().vmNics[0].ip
    retcode = subprocess.call(["ping", "-c","4",vm_ip])
    if retcode != 0:
        test_util.test_fail('Create VM Test linux UEFI failed.')
    else:
        test_util.test_pass('Create VM Test linux UEFI Success.')


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


示例16: test

def test():
    test_util.test_dsc('''
    Test Description:
        Will create 1 VM with 3 l3 networks. 1 l3_network is not using VR; 1 l3_network is using novlan VR; 1 l3_network is using vlan VR. 
    Resource required:
        Need support 3 VMs (1 test VM + 2 VR VMs) existing at the same time. 
        This test required a special image, which was configed with at least 3 enabled NICs (e.g. eth0, eth1, eth2).
    ''')
    image_name = os.environ.get('imageName_net')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    l3_name = os.environ.get('l3VlanNetworkName1')
    l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
    l3_net_list = [l3_net_uuid]
    l3_name = os.environ.get('l3VlanNetworkName3')
    l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
    l3_net_list.append(l3_net_uuid)
    l3_name = os.environ.get('l3VlanNetworkName4')
    l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
    l3_net_list.append(l3_net_uuid)

    vm = test_stub.create_vm(l3_net_list, image_uuid, '3_l3_vm')
    test_obj_dict.add_vm(vm)
    vm.check()

    if len(vm.vm.vmNics) == 3:
        test_util.test_logger("Find 3 expected Nics in new created VM.")
    else:
        test_util.test_fail("New create VM doesn't not have 3 Nics. It only have %s" % len(vm.get_vm().vmNics))

    vm.destroy()
    test_util.test_pass('Create 1 VM with 3 l3_network (1 vlan VR, 1 novlan VR and 1 no VR L3network) successfully.')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:31,代码来源:test_3l3s_vm.py


示例17: test

def test():
    global curr_deploy_conf
    global l2_name2
    curr_deploy_conf = exp_ops.export_zstack_deployment_config(test_lib.deploy_config)

    vm_creation_option = test_util.VmOption()
    image_name = os.environ.get('imageName_s')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    #pick up l3
    l3_1 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name1)[0]
    l3_2 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name2)[0]
    
    l2_2 = res_ops.get_resource(res_ops.L2_NETWORK, \
            uuid = l3_2.l2NetworkUuid)[0]
    l2_name2 = l2_2.name

    conditions = res_ops.gen_query_conditions('type', '=', 'UserVm')
    instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid
    vm_creation_option.set_image_uuid(image_uuid)
    vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
    vm_creation_option.set_name('multizones_basic_vm')
    vm_creation_option.set_l3_uuids([l3_1.uuid, l3_2.uuid])
    cluster1_name = os.environ.get('clusterName2')
    cluster1 = res_ops.get_resource(res_ops.CLUSTER, name = cluster1_name)[0]
    vm_creation_option.set_cluster_uuid(cluster1.uuid)

    vm1 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm1)

    test_util.test_dsc('Delete l2_2')
    net_ops.delete_l2(l2_2.uuid)

    test_obj_dict.mv_vm(vm1, vm_header.RUNNING, vm_header.STOPPED)
    vm1.update()
    vm1.set_state(vm_header.STOPPED)

    vm1.check()

    test_util.test_dsc('start vm again. vm should remove the deleted l2')
    vm1.start()

    net_ops.add_l2_resource(curr_deploy_conf, l2_name = l2_name2)

    #update l3_2, since it is readded.
    l3_2 = res_ops.get_resource(res_ops.L3_NETWORK, name = l3_name2)[0]
    vm_creation_option.set_l3_uuids([l3_1.uuid, l3_2.uuid])

    vm2 = test_lib.lib_create_vm(vm_creation_option)
    test_obj_dict.add_vm(vm2)

    #check vm1 vm2 status.
    vm1.check()

    if not len(vm1.get_vm().vmNics) == 1:
        test_util.test_fail('vm1 vmNics still have L3: %s, even if it is deleted' % l3_2.uuid)

    vm2.check()

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Delete L2 Test Success')
开发者ID:chancelq,项目名称:zstack-woodpecker,代码行数:60,代码来源:test_delete_l2.py


示例18: test

def test():
    global vm

    testHosts = test_lib.lib_get_all_hosts_from_plan()
    for host in testHosts:
        node_ip = host.managementIp_
        print str(node_ip)+" is host.managementIp_"
        break

    host_username = "root"
    host_password = "zstack.mysql.password"

    vm_creation_option = test_util.VmOption()
    image_name = os.environ.get('imageName_s')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    l3_name = os.environ.get('l3VlanNetworkName1')

    l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
    conditions = res_ops.gen_query_conditions('type', '=', 'UserVm')
    instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid
    vm_creation_option.set_l3_uuids([l3_net_uuid])
    vm_creation_option.set_image_uuid(image_uuid)
    vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
    vm_creation_option.set_name('multihost_basic_vm')
    vm = test_vm_header.ZstackTestVm()
    vm.set_creation_option(vm_creation_option)
    vm.create()

    cmd = "zstack-ctl setenv ZSTACK_HOME=/usr/local/zstacktest/apache-tomcat/webapps/zstack/; zstack-ctl dump_mysql --file-name mysql_dump"
    rsp = test_lib.lib_execute_ssh_cmd(node_ip, host_username, host_password, cmd, 180)
    dump_file = rsp.split()[-1]

    cmd = "mysqldump -uroot -pzstack.mysql.password -A -r /tmp/mysql_before_restore.dump"
    rsp = test_lib.lib_execute_ssh_cmd(node_ip, host_username, host_password, cmd, 180)

    vm.check()

    cmd = "zstack-ctl restore_mysql -f %s --mysql-root-password %s"%(dump_file, host_password)
    rsp = test_lib.lib_execute_ssh_cmd(node_ip, host_username, host_password, cmd, 180)

    cmd = '''mysql -uroot -pzstack.mysql.password -D zstack -e "delete from VmInstanceVO where uuid='%s';"''' % (vm.get_vm().uuid)
    rsp = test_lib.lib_execute_ssh_cmd(node_ip, host_username, host_password, cmd, 180)

    cmd = "mysqldump -uroot -pzstack.mysql.password -A -r /tmp/mysql_after_restore.dump"
    rsp = test_lib.lib_execute_ssh_cmd(node_ip, host_username, host_password, cmd, 180)

    cmd = "zstack-ctl start"
    rsp = test_lib.lib_execute_ssh_cmd(node_ip, host_username, host_password, cmd, 180)

    #cmd = "diff /tmp/mysql_before_restore.dump /tmp/mysql_after_restore.dump |wc -l"
    #rsp = test_lib.lib_execute_ssh_cmd(node_ip, host_username, host_password, cmd, 180)

    #diff mysql dump alway has 4 or 8 lines difference because the dump time is different. 
    #and sometime here has 12 lines difference,So we suppose the when the different lines
    # more than 12, Restore mysql db failed.
    #if int(rsp.rstrip()) > 12:
    #    test_util.test_fail('Restore Mysql Failed')

    vm.destroy()
    test_util.test_pass('Restore Mysql Success')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:60,代码来源:test_restore_mysql.py


示例19: test

def test():
    image_name = os.environ.get('imageName_s')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    l3_name = os.environ.get('l3VlanNetworkName1')

    l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
    l3_uuid_list = [l3_net_uuid]
    vm_creation_option = test_util.VmOption()
    conditions = res_ops.gen_query_conditions('type', '=', 'UserVm')
    instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid
    vm_name = '10k_vm-' + str(time.time())
    vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
    vm_creation_option.set_l3_uuids(l3_uuid_list)
    vm_creation_option.set_image_uuid(image_uuid)
    #disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('smallDiskOfferingName'))
    #disk_offering_uuids = [disk_offering.uuid]
    #vm_creation_option.set_data_disk_uuids(disk_offering_uuids)
    vm_creation_option.set_name(vm_name)
    vm = zstack_vm_header.ZstackTestVm()
    vm.set_creation_option(vm_creation_option)
    vm.create()
    test_obj_dict.add_vm(vm)
 
    time.sleep(1)
    vm.destroy()
    test_util.test_pass('Create/Destroy VM successfully')
开发者ID:KevinDavidMitnick,项目名称:zstack-woodpecker,代码行数:26,代码来源:test_poc_1_vm.py


示例20: test

def test():
    image_name = os.environ.get('imageName')
    image_uuid = test_lib.lib_get_image_by_name(image_name).uuid
    l3_name = os.environ.get('l3VlanNetworkName1')

    l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
    l3_uuid_list = [l3_net_uuid]
    vm_creation_option = test_util.VmOption()
    conditions = res_ops.gen_query_conditions('type', '=', 'UserVm')
    instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid
    vm_name = 'parallel_vm-'
    vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
    vm_creation_option.set_l3_uuids(l3_uuid_list)
    vm_creation_option.set_image_uuid(image_uuid)
    #vm_creation_option.set_data_disk_uuids(disk_offering_uuids)
    for i in range(parallel_num):
        i = i + 1
        vm_creation_option.set_name(vm_name + str(i))
        vm = zstack_vm_header.ZstackTestVm()
        vm.set_creation_option(vm_creation_option)
        vm.create()
        test_obj_dict.add_vm(vm)
 
    #vm.destroy()
    test_util.test_pass('Parallelly Create 10 VM successfully')
开发者ID:KevinDavidMitnick,项目名称:zstack-woodpecker,代码行数:25,代码来源:test_poc_10_vm_parallel.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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