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

Python test_lib.lib_create_instance_offering函数代码示例

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

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



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

示例1: test

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

    cpuNum = 1
    memorySize = 555 * 1024 * 1024
    new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\
            memorySize = memorySize)

    vm = test_stub.create_vm(vm_name = 'ckvmoffering-c7-64', image_name = "imageName_i_c7", instance_offering_uuid=new_offering.uuid)
    vm.check()
    test_obj_dict.add_vm(vm)
    test_obj_dict.add_instance_offering(new_offering)
    cpuNum = 1
    memorySize = 667 * 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
    vm.change_instance_offering(new_offering_uuid)
    vm.check()

    test_lib.lib_robot_cleanup(test_obj_dict)

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


示例2: test

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

    #unit is KB
    net_bandwidth1 = 1024
    new_offering1 = test_lib.lib_create_instance_offering(net_bandwidth = net_bandwidth1)

    test_obj_dict.add_instance_offering(new_offering1)
    new_offering_uuid = new_offering1.uuid

    vm = test_stub.create_vm(vm_name = 'vm_net_qos', \
            instance_offering_uuid = new_offering1.uuid)
    test_obj_dict.add_vm(vm)

    vm.stop()

    net_bandwidth2 = 512
    new_offering2 = test_lib.lib_create_instance_offering(net_bandwidth = net_bandwidth2)

    test_obj_dict.add_instance_offering(new_offering2)
    new_offering_uuid = new_offering2.uuid
    vm_inv = vm.get_vm()
    vm.change_instance_offering(new_offering_uuid)
    vm.start()
    vm.check()
    import time
    time.sleep(1)
    test_stub.make_ssh_no_password(vm_inv)
    test_stub.create_test_file(vm_inv, net_bandwidth2)
    test_stub.test_scp_speed(vm_inv, net_bandwidth2)
    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM Network QoS change instance offering Test Pass')
开发者ID:KevinDavidMitnick,项目名称:zstack-woodpecker,代码行数:34,代码来源:test_net_change_qos.py


示例3: test

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

    vm = test_stub.create_vlan_vm()
    test_obj_dict.add_vm(vm)

    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

    vm.change_instance_offering(new_offering_uuid)
    vm.check()
    vm.reboot()
    vm.check()
    cpuNum = 1
    memorySize = 555 * 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
    vm.change_instance_offering(new_offering_uuid)
    vm.check()

    test_lib.lib_robot_cleanup(test_obj_dict)

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


示例4: 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


示例5: test

def test():
    global new_offering_uuid
    test_util.test_dsc('Test memory status after change VM offering')

    cond = res_ops.gen_query_conditions('state', '=', 'Enabled')
    cond = res_ops.gen_query_conditions('status', '=', 'Connected', cond)
    host = res_ops.query_resource_with_num(res_ops.HOST, cond, limit = 1)
    if not host:
        test_util.test_skip('No Enabled/Connected host was found, skip test.' )
        return True

    host_uuid = host[0].uuid
    zone_uuid = host[0].zoneUuid
    host_avail_mem1 = test_lib.lib_get_cpu_memory_capacity(host_uuids = [host_uuid]).availableMemory
    zone_avail_mem1 = test_lib.lib_get_cpu_memory_capacity(zone_uuids = [zone_uuid]).availableMemory
    #unit is KB
    new_offering1 = test_lib.lib_create_instance_offering(cpuNum = 1, \
            memorySize = 536870912, name = 'new_instance1')

    test_obj_dict.add_instance_offering(new_offering1)
    new_offering_uuid = new_offering1.uuid

    vm = test_stub.create_vm(vm_name = 'test_avail_memory', \
            host_uuid = host_uuid, \
            instance_offering_uuid = new_offering1.uuid)
    test_obj_dict.add_vm(vm)

    vm.stop()

    new_offering2 = test_lib.lib_create_instance_offering(cpuNum = 1, \
            memorySize = 1073741824, name = 'new_instance2')

    test_obj_dict.add_instance_offering(new_offering2)
    new_offering_uuid = new_offering2.uuid
    vm_inv = vm.get_vm()
    vm.change_instance_offering(new_offering_uuid)
    vm.start()
    host_avail_mem2 = test_lib.lib_get_cpu_memory_capacity(host_uuids = [host_uuid]).availableMemory
    host_mem_diff = host_avail_mem1 - host_avail_mem2
    if host_avail_mem2 >= host_avail_mem1 :
        test_util.test_fail('Host available memory is not correct after change vm template. Previous value: %s , Current value: %s' % (host_avail_mem1, host_avail_mem2))
    else:
        test_util.test_logger('Host available memory before change template: %s , after change template: %s , the difference: %s' % (host_avail_mem1, host_avail_mem2, host_mem_diff))

    zone_avail_mem2 = test_lib.lib_get_cpu_memory_capacity(zone_uuids = [zone_uuid]).availableMemory
    zone_mem_diff = zone_avail_mem1 - zone_avail_mem2
    if zone_avail_mem2 >= zone_avail_mem1 :
        test_util.test_fail('Zone available memory is not correct after change vm template. Previous value: %s , Current value: %s' % (zone_avail_mem1, zone_avail_mem2))
    else:
        test_util.test_logger('Zone available memory before change template: %s , after change template: %s , the difference: %s' % (zone_avail_mem1, zone_avail_mem2, zone_mem_diff))

    if zone_mem_diff != host_mem_diff:
        test_util.test_fail('available memory change is not correct after change vm template. zone changed value: %s , host changed value: %s' % ((zone_avail_mem1 - zone_avail_mem2), (host_avail_mem1 - host_avail_mem2)))

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Test available memory when changing instance offering Pass')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:56,代码来源:test_change_offering.py


示例6: 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


示例7: test

def test():
    flavor = case_flavor[os.environ.get('CASE_FLAVOR')]
    test_util.test_dsc("STEP1: Ceate vm instance offering")
    vm_instance_offering = test_lib.lib_create_instance_offering(cpuNum=1, memorySize=1024*1024*1024)
    test_obj_dict.add_instance_offering(vm_instance_offering)

    test_util.test_dsc("STEP2: Ceate vm and wait until it up for testing image_name : {}".format(flavor['image']))
    vm = test_stub.create_vm(vm_name='test_vm', image_name=flavor['image'],
                             instance_offering_uuid=vm_instance_offering.uuid)
    test_obj_dict.add_vm(vm)
    vm.check()

    cpu_change = random.randint(1, 5) if flavor['add_cpu'] else 0
    mem_change = random.randint(1, 500)*1024*1024 if flavor['add_memory'] else 0

    test_util.test_dsc("STEP3: Hot Plugin CPU: {} and Memory: {} and check capacity".format(cpu_change, mem_change))

    with test_stub.CapacityCheckerContext(vm, cpu_change, mem_change):
        vm_ops.update_vm(vm.get_vm().uuid, vm_instance_offering.cpuNum+cpu_change,
                         vm_instance_offering.memorySize+mem_change)
        vm.update()
        if flavor['need_online']:
            test_stub.online_hotplug_cpu_memory(vm)
        time.sleep(10)

    test_util.test_dsc("STEP4: Destroy test object")
    test_lib.lib_error_cleanup(test_obj_dict)
    test_util.test_pass('VM online change instance offering Test Pass')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:28,代码来源:test_vm_offering.py


示例8: testmethod

    def testmethod():
        test_util.test_dsc("STEP1: Ceate vm instance offering")
        vm_instance_offering = test_lib.lib_create_instance_offering(cpuNum=1, memorySize=1024*1024*1024)
        tbj.add_instance_offering(vm_instance_offering)

        test_util.test_dsc("STEP2: Ceate vm and wait until it up for testing")
        vm = create_vm(vm_name='test_vm', image_name = test_image_name,
                       instance_offering_uuid=vm_instance_offering.uuid)
        tbj.add_vm(vm)
        vm.check()

        cpu_change = random.randint(1, 5) if add_cpu else 0
        mem_change = random.randint(1, 500)*1024*1024 if add_memory else 0

        test_util.test_dsc("STEP3: Hot Plugin CPU: {} and Memory: {} and check capacity".format(cpu_change, mem_change))

        with CapacityCheckerContext(vm, cpu_change, mem_change):
            vm_ops.update_vm(vm.get_vm().uuid, vm_instance_offering.cpuNum+cpu_change,
                             vm_instance_offering.memorySize+mem_change)
            vm.update()
            if need_online:
                online_hotplug_cpu_memory(vm)
            time.sleep(10)

        test_util.test_dsc("STEP4: Destroy test object")
        test_lib.lib_error_cleanup(tbj)
        test_util.test_pass('VM online change instance offering Test Pass')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:27,代码来源:test_stub.py


示例9: test

def test():
    test_util.test_dsc("STEP1: Ceate vm instance offering")
    vm_instanc_offering = test_lib.lib_create_instance_offering(cpuNum = 2,
                                                                memorySize = 2 * 1024 * 1024 * 1024)
    test_obj_dict.add_instance_offering(vm_instanc_offering)

    test_util.test_dsc("STEP2: Ceate vm and wait until it up for testing")
    vm = test_stub.create_vm(vm_name = 'window-telnet', image_name = "imageName_windows",
                             instance_offering_uuid=vm_instanc_offering.uuid)
    test_obj_dict.add_vm(vm)
    time.sleep(10)

    test_util.test_dsc("STEP3: Hot Plugin CPU and Memory and check capacity")
    cpu_change = random.randint(1,5)
    mem_change = random.randint(1,500) * 1024 * 1024

    with test_stub.CapacityCheckerContext(vm, cpu_change, mem_change, window=True):
        # wait for 90s to ensure all the windows services up
        time.sleep(90)
        vm_ops.update_vm(vm.get_vm().uuid, vm_instanc_offering.cpuNum+cpu_change,
                         vm_instanc_offering.memorySize+mem_change)
        vm.update()
        time.sleep(10)

    test_util.test_dsc("STEP4: Destroy test object")
    test_lib.lib_error_cleanup(test_obj_dict)
    test_util.test_pass('VM online change instance offering Test Pass')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:27,代码来源:test_hotplugin_cpu_memory_windows.py


示例10: test

def test():
    test_util.test_dsc('Test update instance offering')

    cond = res_ops.gen_query_conditions('state', '=', 'Enabled')
    cond = res_ops.gen_query_conditions('status', '=', 'Connected', cond)
    host = res_ops.query_resource_with_num(res_ops.HOST, cond, limit = 1)
    if not host:
        test_util.test_skip('No Enabled/Connected host was found, skip test.' )
        return True

    host_uuid = host[0].uuid
    new_offering = test_lib.lib_create_instance_offering(cpuNum = 1, \
            cpuSpeed = 16, memorySize = 536870912, name = 'orgin_instance_name')

    test_obj_dict.add_instance_offering(new_offering)

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

    vm.stop()

    #These parameters are need to be populated.
    updated_offering = test_lib.lib_update_instance_offering(new_offering.uuid, cpuNum = 2, cpuSpeed = 16, \
        memorySize = 1073741824, name = 'updated_instance_name', \
        volume_iops = None, volume_bandwidth = None, \
        net_outbound_bandwidth = None, net_inbound_bandwidth = None)

    vm.start()
    vm.check()

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Test updated instance offering Pass')
开发者ID:mrwangxc,项目名称:zstack-woodpecker,代码行数:34,代码来源:test_update_offering.py


示例11: test

def test():
    global new_offering_uuid
    test_util.test_dsc('Test VM network outbound & inbound bandwidth QoS by 1MB')

    #unit is KB
    net_bandwidth = 1*1024
    new_offering = test_lib.lib_create_instance_offering(net_outbound_bandwidth = net_bandwidth*8*1024, \
            net_inbound_bandwidth = net_bandwidth*8*1024)

    new_offering_uuid = new_offering.uuid

    vm = test_stub.create_vm(vm_name = 'vm_net_inbound_outbound_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.create_test_file(vm_inv, net_bandwidth)
    test_stub.test_scp_vm_outbound_speed(vm_inv, net_bandwidth)
    test_stub.test_scp_vm_inbound_speed(vm_inv, net_bandwidth)
    vm_ops.delete_instance_offering(new_offering_uuid)
    test_lib.lib_robot_cleanup(test_obj_dict)

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


示例12: test

def test():

    for bandwidth, net_out, net_in in itertools.product((None, BANDWIDTH), (None, NET_OUT), (None, NET_IN)):
        instance_offering = test_lib.lib_create_instance_offering(name='test_offering',
                                                                  volume_bandwidth=bandwidth,
                                                                  net_outbound_bandwidth=net_out,
                                                                  net_inbound_bandwidth=net_in)
        test_obj_dict.add_instance_offering(instance_offering)
        volume_list = test_stub.create_multi_volumes(ps=random.choice(res_ops.get_resource(res_ops.PRIMARY_STORAGE)))
        for volume in volume_list:
            test_obj_dict.add_volume(volume)
        test_vm = test_stub.create_vm_with_random_offering(vm_name='test_vm', instance_offering_uuid=instance_offering.uuid,
                                                           l3_name='l3VlanNetwork2', image_name='imageName_net')
        test_obj_dict.add_vm(test_vm)
        for volume in volume_list:
            volume.attach(test_vm)
            volume.check()
        test_vm.check()

        for volume in volume_list:
            volume.detach()
            volume.check()
        test_vm.check()

        test_vm_with_datavol = test_stub.create_vm_with_random_offering(vm_name='test_vm_datavol', instance_offering_uuid=instance_offering.uuid,
                                                              disk_offering_uuids=[random.choice(res_ops.get_resource(res_ops.DISK_OFFERING)).uuid],
                                                              l3_name='l3VlanNetwork2', image_name='imageName_net')
        test_obj_dict.add_vm(test_vm_with_datavol)

    test_util.test_pass('Volume attach on QOS vm TEST PASS')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:30,代码来源:test_volume_attach_qos_vm.py


示例13: 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


示例14: 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


示例15: test

def test():
    global test_stub,test_obj_dict
    vm = test_stub.create_arm_vm()
    test_obj_dict.add_vm(vm)

    vm.check()
    vm.suspend()
    vm.check()
    vm.resume()
    vm.check()
    vm.reboot()
    vm.check()
    l3_name=os.environ.get('l3PublicNetworkName')
    l3_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
    vm.add_nic(l3_uuid)
    # 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)

    vm.stop()
    vm.change_instance_offering(new_offering.uuid)
    vm.check()
    vm.start()
    vm.stop()
    vm.check()
    vm.reinit()
    vm.check()
    #time.sleep(5)
    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Create VM Test Success')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:33,代码来源:test_arm_vm.py


示例16: test

def test():

    test_util.test_dsc("STEP1: Ceate vm instance offering")
    vm_instance_offering = test_lib.lib_create_instance_offering(cpuNum = 1,
                                                                memorySize = 1024 * 1024 * 1024)
    test_obj_dict.add_instance_offering(vm_instance_offering)

    test_util.test_dsc("STEP2: Ceate vm and wait until it up for testing")
    vm = test_stub.create_vm(vm_name = 'ckvmoffering-c6-64', image_name = "imageName_i_c6",
                             instance_offering_uuid=vm_instance_offering.uuid)
    test_obj_dict.add_vm(vm)
    vm.check()

    test_util.test_dsc("STEP3: Continuously Hot Plugin CPU and Memory and check capacity")
    last_cpu = vm_instance_offering.cpuNum
    last_mem = vm_instance_offering.memorySize
    cpu_change = 0
    mem_change_list = [random.randint(0, 500)*1024*1024 for _ in xrange(8)]

    for mem_change in mem_change_list:
        with test_stub.CapacityCheckerContext(vm, cpu_change, mem_change) as cc:
            vm_ops.update_vm(vm.get_vm().uuid, last_cpu + cpu_change, last_mem + mem_change)
            last_cpu += cpu_change
            last_mem += cc.mem_aligned_change
            vm.update()
            test_stub.online_hotplug_cpu_memory(vm)
            time.sleep(5)

    test_util.test_dsc("STEP4: Destroy test object")
    test_lib.lib_error_cleanup(test_obj_dict)
    test_util.test_pass('VM online change instance offering Test Pass')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:31,代码来源:test_hotplugin_mem_alignment.py


示例17: test

def test():
    global new_offering_uuid
    test_util.test_dsc('Test VM network outbound bandwidth QoS by 1MB')

    #unit is KB
    net_bandwidth = 1*1024
    new_offering = test_lib.lib_create_instance_offering(net_outbound_bandwidth = net_bandwidth*8*1024)

    new_offering_uuid = new_offering.uuid

    vm = test_stub.create_vm(vm_name = 'vm_net_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.create_test_file(vm_inv, net_bandwidth)
    test_stub.test_scp_vm_outbound_speed(vm_inv, net_bandwidth)
    if test_stub.test_scp_vm_inbound_speed(vm_inv, net_bandwidth, raise_exception=False):
        test_util.test_fail('VM network inbound is not expected to be limited when only outbound qos is set')

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

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


示例18: 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


示例19: 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


示例20: test

def test():
    test_util.test_dsc('''
    Test Description:
        This case is test for detach a NIC from a stop or a running windows VM 
        Will create 1 test windows VM with 1 NIC firstly. 
        Then attach a new NIC to Stopped VM with different L3 Network.
        Then Stop the VM.
        Then detach the new NIC
        Then start the VM and check the network.
        Then attach a new NIC again
        Then detach the NIC
    ''')
    image_name = os.environ.get('imageName_windows')
    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_name2 = os.environ.get('l3VlanNetworkName5')
    l3_net_uuid2 = test_lib.lib_get_l3_by_name(l3_name2).uuid
    vm_instance_offering = test_lib.lib_create_instance_offering(cpuNum = 2,
                                                                memorySize = 2048 * 1024 * 1024)
    test_obj_dict.add_instance_offering(vm_instance_offering)

    vm = test_stub.create_vm(l3_net_list, image_uuid, 'windows2012_vm', \
            default_l3_uuid = l3_net_uuid, instance_offering_uuid = vm_instance_offering.uuid)
    test_obj_dict.add_vm(vm)

    vm.add_nic(l3_net_uuid2)
    attached_nic = test_lib.lib_get_vm_last_nic(vm.get_vm())
    if l3_net_uuid2 != attached_nic.l3NetworkUuid:
        test_util.test_fail("After attach a nic, VM:%s last nic is not belong l3: %s" % (vm.get_vm().uuid, l3_net_uuid2))

    vm.stop()
    time.sleep(5)
    
    vm.remove_nic(attached_nic.uuid)
    time.sleep(5)

    vm.start()
    time.sleep(50)

    vm.add_nic(l3_net_uuid2)
    attached_nic = test_lib.lib_get_vm_last_nic(vm.get_vm())
    if l3_net_uuid2 != attached_nic.l3NetworkUuid:
        test_util.test_fail("After attach a nic again, VM:%s last nic is not belong l3: %s" % (vm.get_vm().uuid, l3_net_uuid2))
    
    time.sleep(5)
    vm.remove_nic(attached_nic.uuid)
    time.sleep(5)

    vm.destroy()
    test_util.test_pass('Test Attach Nic with VM reboot action successfully.')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:52,代码来源:test_windows_detach_nic_stop_run_vm.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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