コード例 #1
0
def test():
    global volume_offering_uuid
    test_util.test_dsc('Test VM data volume bandwidth QoS by 20MB')

    #unit is KB
    volume_bandwidth = 5*1024*1024
    new_volume_offering = test_lib.lib_create_disk_offering(volume_bandwidth = volume_bandwidth)
    volume_offering_uuid = new_volume_offering.uuid
    vm = test_stub.create_vm(vm_name = 'vm_volume_qos', disk_offering_uuids = [volume_offering_uuid])
    vm.check()
    test_obj_dict.add_vm(vm)
    vm_inv = vm.get_vm()
    cond = res_ops.gen_query_conditions("vmInstanceUuid", '=', vm_inv.uuid) 
    cond = res_ops.gen_query_conditions("type", '=', 'Data', cond)
    volume_uuid = res_ops.query_resource(res_ops.VOLUME, cond)[0].uuid
    test_lib.lib_mkfs_for_volume(volume_uuid, vm_inv)
    path = '/mnt'
    user_name = 'root'
    user_password = '******'
    os.system("sshpass -p '%s' ssh %s@%s 'mount /dev/vdb1 %s'"%(user_password, user_name, vm_inv.vmNics[0].ip, path))
    vm.check()
    test_stub.make_ssh_no_password(vm_inv)
    test_stub.install_fio(vm_inv)
    test_stub.test_fio_bandwidth(vm_inv, volume_bandwidth, path)
    vol_ops.delete_disk_offering(volume_offering_uuid)
    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM data volume QoS Test Pass')
コード例 #2
0
def test():
    global volume_offering_uuid
    test_util.test_dsc('Test VM data volume bandwidth QoS by 20MB')

    #unit is KB
    write_bandwidth = 5*1024*1024
    new_volume_offering = test_lib.lib_create_disk_offering(write_bandwidth = write_bandwidth)
    volume_offering_uuid = new_volume_offering.uuid
    vm = test_stub.create_vm(vm_name='vm_volume_qos', disk_offering_uuids = [volume_offering_uuid])
    vm.check()
    test_obj_dict.add_vm(vm)
    vm_inv = vm.get_vm()
    cond = res_ops.gen_query_conditions("vmInstanceUuid", '=', vm_inv.uuid) 
    cond = res_ops.gen_query_conditions("type", '=', 'Data', cond)
    volume_uuid = res_ops.query_resource(res_ops.VOLUME, cond)[0].uuid
    test_lib.lib_mkfs_for_volume(volume_uuid, vm_inv)
    path = '/mnt'
    user_name = 'root'
    user_password = '******'
    os.system("sshpass -p '%s' ssh %s@%s 'mount /dev/vdb1 %s'"%(user_password, user_name, vm_inv.vmNics[0].ip, path))
    vm.check()
    test_stub.make_ssh_no_password(vm_inv)
    test_stub.install_fio(vm_inv)

    if vm_ops.get_vm_disk_qos(test_lib.lib_get_data_volumes(vm_inv)[0].uuid).volumeBandwidthRead != -1 and \
    vm_ops.get_vm_disk_qos(test_lib.lib_get_data_volumes(vm_inv)[0].uuid).volumeBandwidthWrite != write_bandwidth:
        test_util.test_fail('Retrieved disk qos not match')
    test_stub.test_fio_bandwidth(vm_inv, write_bandwidth, path)

    if test_stub.test_fio_bandwidth(vm_inv, write_bandwidth/2, '/dev/vdb', raise_exception=False):
        test_util.test_fail('disk read qos is not expected to have limit as only write qos was set')
    vol_ops.delete_disk_offering(volume_offering_uuid)
    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM data volume write QoS Test Pass')
コード例 #3
0
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')
    test_obj_dict.add_vm(vm)

    vm.check()

    volume_creation_option = test_util.VolumeOption()
    disk_offering = test_lib.lib_create_disk_offering(diskSize=1073741824,name="1G")
    volume_creation_option.set_disk_offering_uuid(disk_offering.uuid)
    tag_ops.create_system_tag('DiskOfferingVO', disk_offering.uuid, "volumeTotalBandwidth::26214400")
    
    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)
    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM Disk QoS Test Pass')
コード例 #4
0
def test():
    global volume_offering_uuid
    test_util.test_dsc('Test VM data volume bandwidth QoS by 20MB')

    #unit is KB
    volume_bandwidth = 5 * 1024 * 1024
    new_volume_offering = test_lib.lib_create_disk_offering(
        volume_bandwidth=volume_bandwidth)
    volume_offering_uuid = new_volume_offering.uuid
    vm = test_stub.create_vm(vm_name='vm_volume_qos',
                             disk_offering_uuids=[volume_offering_uuid])
    test_obj_dict.add_vm(vm)
    vm_inv = vm.get_vm()
    cond = res_ops.gen_query_conditions("vmInstanceUuid", '=', vm_inv.uuid)
    cond = res_ops.gen_query_conditions("type", '=', 'Data', cond)
    volume_uuid = res_ops.query_resource(res_ops.VOLUME, cond)[0].uuid
    test_lib.lib_mkfs_for_volume(volume_uuid, vm_inv)
    path = '/mnt'
    user_name = 'root'
    user_password = '******'
    os.system("sshpass -p '%s' ssh %s@%s 'mount /dev/vdb1 %s'" %
              (user_password, user_name, vm_inv.vmNics[0].ip, path))
    vm.check()
    test_stub.make_ssh_no_password(vm_inv)
    test_stub.install_fio(vm_inv)
    test_stub.test_fio_bandwidth(vm_inv, volume_bandwidth, path)
    vol_ops.delete_disk_offering(volume_offering_uuid)
    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM data volume QoS Test Pass')
コード例 #5
0
def test():
    global volume_offering_uuid
    test_util.test_dsc('Test VM disk bandwidth QoS by 20MB')

    #unit is KB
    volume_bandwidth = 5 * 1024 * 1024
    new_volume_offering = test_lib.lib_create_disk_offering(
        volume_bandwidth=volume_bandwidth)

    volume_offering_uuid = new_volume_offering.uuid

    vm = test_stub.create_vm(vm_name='vm_volume_qos',
                             disk_offering_uuids=[volume_offering_uuid])
    test_obj_dict.add_vm(vm)
    vm_inv = vm.get_vm()
    cond = res_ops.gen_query_conditions("vmInstanceUuid", '=', vm_inv.uuid)
    cond = res_ops.gen_query_conditions("type", '=', 'Data', cond)
    volume_uuid = res_ops.query_resource(res_ops.VOLUME, cond)[0].uuid
    test_lib.lib_mkfs_for_volume(volume_uuid, vm_inv)
    path = '/mnt'
    user_name = 'root'
    user_password = '******'
    os.system("sshpass -p '%s' ssh %s@%s 'mount /dev/vdb1 %s'" %
              (user_password, user_name, vm_inv.vmNics[0].ip, path))
    test_stub.make_ssh_no_password(vm_inv)
    test_stub.install_fio(vm_inv)
    test_stub.test_fio_bandwidth(vm_inv, volume_bandwidth, path)
    if vm_ops.get_vm_disk_qos(test_lib.lib_get_data_volumes(vm_inv)
                              [0].uuid).volumeBandwidth != volume_bandwidth:
        test_util.test_fail('Retrieved disk qos not match')
    vm_ops.set_vm_disk_qos(
        test_lib.lib_get_data_volumes(vm_inv)[0].uuid, volume_bandwidth / 2)
    test_stub.test_fio_bandwidth(vm_inv, volume_bandwidth / 2, path)
    vm_ops.del_vm_disk_qos(test_lib.lib_get_data_volumes(vm_inv)[0].uuid)
    if test_stub.test_fio_bandwidth(vm_inv,
                                    volume_bandwidth / 2,
                                    path,
                                    raise_exception=False):
        test_util.test_fail(
            'disk qos is not expected to have limit after qos setting is deleted'
        )
    vol_ops.delete_disk_offering(volume_offering_uuid)
    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM data volume QoS Test Pass')
コード例 #6
0
def test():
    global volume_offering_uuid,new_offering_uuid
    test_util.test_dsc('Test VM data volume bandwidth QoS by 20MB')

    # Only imagestore supports full clone
    bs = res_ops.query_resource(res_ops.BACKUP_STORAGE)
    for i in bs:
        if i.type == inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE:
            break
    else:
        test_util.test_skip('Skip test on non-imagestore')

    # SharedBlock and AliyunNAS not support full clone
    ps = res_ops.query_resource(res_ops.PRIMARY_STORAGE)
    for i in ps:
        if i.type in ['SharedBlock', 'AliyunNAS']:
            test_util.test_skip('Skip test on SharedBlock and AliyunNAS PS')

    #unit is KB
    write_bandwidth = 10*1024*1024
    new_offering = test_lib.lib_create_instance_offering(write_bandwidth = write_bandwidth)
    new_offering_uuid = new_offering.uuid
    new_volume_offering = test_lib.lib_create_disk_offering(write_bandwidth = write_bandwidth)
    volume_offering_uuid = new_volume_offering.uuid
    vm = test_stub.create_vm(vm_name='vm_volume_qos', instance_offering_uuid = new_offering_uuid,
                             disk_offering_uuids = [volume_offering_uuid])
    test_obj_dict.add_vm(vm)
    vm.check()
    vm_inv = vm.get_vm()
    cond = res_ops.gen_query_conditions("vmInstanceUuid", '=', vm_inv.uuid) 
    cond = res_ops.gen_query_conditions("type", '=', 'Data', cond)
    volume_uuid = res_ops.query_resource(res_ops.VOLUME, cond)[0].uuid
    test_lib.lib_mkfs_for_volume(volume_uuid, vm_inv)
    path = '/mnt'
    user_name = 'root'
    user_password = '******'
    os.system("sshpass -p '%s' ssh %s@%s 'mount /dev/vdb1 %s'"%(user_password, user_name, vm_inv.vmNics[0].ip, path))
    vm.check()
    test_stub.make_ssh_no_password(vm_inv)
#     test_stub.install_fio(vm_inv)

    vm_ops.set_vm_disk_qos(test_lib.lib_get_data_volumes(vm_inv)[0].uuid, write_bandwidth*2, 'write')
    vm_ops.set_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid, write_bandwidth*2, 'write')

    new_vm = vm.clone(['full_cloned_vm'], full=True)[0]
    new_vm.check()
    test_obj_dict.add_vm(new_vm)

    volumes_number = len(test_lib.lib_get_all_volumes(new_vm.vm))
    if volumes_number != 2:
        test_util.test_fail('Did not find 2 volumes for [vm:] %s. But we assigned 2 data volume when create the vm. We only catch %s volumes' % (new_vm.vm.uuid, volumes_number))
    else:
        test_util.test_logger('Find 2 volumes for [vm:] %s.' % new_vm.vm.uuid)

    new_vm_inv = new_vm.get_vm()
    test_stub.install_fio(new_vm_inv)

    if vm_ops.get_vm_disk_qos(test_lib.lib_get_data_volumes(new_vm_inv)[0].uuid).volumeBandwidthWrite != write_bandwidth*2:
        test_util.test_fail('Retrieved disk qos not match')

    test_stub.test_fio_bandwidth(new_vm_inv, write_bandwidth*2)
    test_stub.test_fio_bandwidth(new_vm_inv, write_bandwidth*2, path)

    if test_stub.test_fio_bandwidth(vm_inv, write_bandwidth, '/dev/vda', raise_exception=False):
        test_util.test_fail('disk read qos is not expected to have limit as only read qos was set')

    if test_stub.test_fio_bandwidth(vm_inv, write_bandwidth, '/dev/vdb', raise_exception=False):
        test_util.test_fail('disk read qos is not expected to have limit as only read qos was set')

    vm_ops.delete_instance_offering(new_offering_uuid)
    vol_ops.delete_disk_offering(volume_offering_uuid)
    test_lib.lib_robot_cleanup(test_obj_dict)

    test_util.test_pass('VM data volume read QoS Test Pass')
コード例 #7
0
def test():
    global vm, session_uuid
    global all_volume_offering_uuid, rw_volume_offering_uuid, instance_offering_uuid
    global test_account_uuid
    
    test_util.test_dsc('Test normal account change the qos network and volume ')

    #create normal account
    test_util.test_dsc('create normal account')
    account_name = 'a'
    account_pass = hashlib.sha512(account_name).hexdigest()
    test_account = acc_ops.create_normal_account(account_name, account_pass)
    test_account_uuid = test_account.uuid
    test_account_session = acc_ops.login_by_account(account_name, account_pass)

    #create disk offering
    test_util.test_dsc('create disk offering')
    name_all = 'all_disk_offering'	
    volume_bandwidth = 30*1024*1024
    all_volume_offering = test_lib.lib_create_disk_offering(name = name_all, volume_bandwidth = volume_bandwidth)
    all_volume_offering_uuid = all_volume_offering.uuid

    name_rw = 'rw_disk_offering'	
    volume_read_bandwidth = 90*1024*1024
    volume_write_bandwidth = 100*1024*1024
    rw_volume_offering = test_lib.lib_create_disk_offering(name = name_rw, read_bandwidth = volume_read_bandwidth, write_bandwidth = volume_write_bandwidth)
    rw_volume_offering_uuid = rw_volume_offering.uuid

    #create instance offering 
    test_util.test_dsc('create instance offering')
    read_bandwidth = 50*1024*1024
    write_bandwidth = 60*1024*1024
    net_outbound_bandwidth = 70*1024*1024
    net_inbound_bandwidth = 80*1024*1024
    new_instance_offering = test_lib.lib_create_instance_offering(read_bandwidth = read_bandwidth, write_bandwidth=write_bandwidth, net_outbound_bandwidth = net_outbound_bandwidth, net_inbound_bandwidth = net_inbound_bandwidth)
    instance_offering_uuid = new_instance_offering.uuid
    
    #share admin resoure to normal account
    test_util.test_dsc('share admin resoure to normal account')
    test_stub.share_admin_resource([test_account_uuid])
    acc_ops.share_resources([test_account_uuid], [all_volume_offering_uuid, rw_volume_offering_uuid])

    #create vm with 2 data volumes
    test_util.test_dsc('create vm with volumes qos by normal account a')
    l3net_uuid = res_ops.get_resource(res_ops.L3_NETWORK, session_uuid = test_account_session)[0].uuid
    cond = res_ops.gen_query_conditions('platform', '=', 'Linux')
    image_uuid = res_ops.query_resource(res_ops.IMAGE, cond, session_uuid = test_account_session)[0].uuid
    vm_creation_option = test_util.VmOption()
    vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
    vm_creation_option.set_image_uuid(image_uuid)
    vm_creation_option.set_l3_uuids([l3net_uuid])

    vm = test_stub.create_vm_with_volume(vm_creation_option = vm_creation_option,  data_volume_uuids = [all_volume_offering_uuid, rw_volume_offering_uuid], session_uuid = test_account_session)
    vm_inv = vm.get_vm()

    # get  the nic uuid
    test_util.test_dsc('get the vm_nic')
    l3_uuid = vm_inv.vmNics[0].l3NetworkUuid
    vm_nic = test_lib.lib_get_vm_nic_by_l3(vm_inv, l3_uuid)

    # get the volume uuid
    test_util.test_dsc('get the vm data volumes')
    cond1 = res_ops.gen_query_conditions("diskOfferingUuid", '=', all_volume_offering_uuid)
    cond2 = res_ops.gen_query_conditions("diskOfferingUuid", '=', rw_volume_offering_uuid)
    all_volume_uuid = res_ops.query_resource(res_ops.VOLUME, cond1)[0].uuid
    rw_volume_uuid = res_ops.query_resource(res_ops.VOLUME, cond2)[0].uuid
    #set root disk qos
    test_util.test_dsc('set read*2, read/2, write*2, write/2 and del the root disk read and write qos')    
    try:
    	vm_ops.set_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid, volumeBandwidth = read_bandwidth*2, mode = 'read', session_uuid = test_account_session)
    except:
	print "Test results were in line with expectations"
	pass

    test_util.test_dsc('del the root disk read qos')    
    try:
    	vm_ops.del_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid, mode = 'read', session_uuid = test_account_session)
    except:
	print "Test results were in line with expectations"
	pass
    vm_ops.set_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid, volumeBandwidth = read_bandwidth/2, mode = 'read', session_uuid = test_account_session)

    test_util.test_dsc('set 2 times the root disk write qos')    
    try:
    	vm_ops.set_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid, volumeBandwidth = write_bandwidth*2, mode = 'write', session_uuid = test_account_session)
    except:
	print "Test results were in line with expectations"
	pass

    test_util.test_dsc('del the root disk write qos')    
    try:
    	vm_ops.del_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid, mode = 'write', session_uuid = test_account_session)
    except:
	print "Test results were in line with expectations"
	pass

    test_util.test_dsc('set below the root disk write qos')    
    vm_ops.set_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid, volumeBandwidth = write_bandwidth/2, mode = 'write', session_uuid = test_account_session)

    #set data disk all_volume_uuid qos
    test_util.test_dsc('set read*2, read/2, write*2, write/2 and del the volume1 disk read and write qos')    
    try:
    	vm_ops.set_vm_disk_qos(all_volume_uuid, volumeBandwidth = volume_bandwidth*2, session_uuid = test_account_session)
    except:
	print "Test results were in line with expectations"
	pass

    test_util.test_dsc('del the data volume qos')    
    try:
    	vm_ops.del_vm_disk_qos(all_volume_uuid, session_uuid = test_account_session)
    except:
	print "Test results were in line with expectations"
	pass

    vm_ops.set_vm_disk_qos(all_volume_uuid, volumeBandwidth = volume_bandwidth/2, session_uuid = test_account_session)

    #set data disk rw_volume_uuid write qos
    test_util.test_dsc('set 2 times the data rw_volume_uuid write qos')    
    try:
    	vm_ops.set_vm_disk_qos(rw_volume_uuid, volumeBandwidth = volume_write_bandwidth*2, mode = 'write', session_uuid = test_account_session)
    except:
	print "Test results were in line with expectations"
	pass

    test_util.test_dsc('del the data rw_volume_uuid  write qos')
    try:
    	vm_ops.del_vm_disk_qos(rw_volume_uuid, mode = 'write', session_uuid = test_account_session)
    except:
	print "Test results were in line with expectations"
	pass

    vm_ops.set_vm_disk_qos(rw_volume_uuid, volumeBandwidth = volume_write_bandwidth/2, mode = 'write', session_uuid = test_account_session)

    #set data disk rw_volume_uuid read qos
    test_util.test_dsc('set 2 times the data rw_volume_uuid read qos')    
    try:
    	vm_ops.set_vm_disk_qos(rw_volume_uuid, volumeBandwidth = volume_read_bandwidth*2, mode = 'read', session_uuid = test_account_session)
    except:
	print "Test results were in line with expectations"
	pass
    test_util.test_dsc('del the data rw_volume_uuid read qos')
    try:
    	vm_ops.del_vm_disk_qos(rw_volume_uuid, mode = 'read', session_uuid = test_account_session)
    except:
	print "Test results were in line with expectations"
	pass
    vm_ops.set_vm_disk_qos(rw_volume_uuid, volumeBandwidth = volume_read_bandwidth/2, mode = 'read', session_uuid = test_account_session)

   # set the vm nic qos
    test_util.test_dsc('set higher than net out and in ')    
    try:
	vm_ops.set_vm_nic_qos(vm_nic.uuid, outboundBandwidth = net_outbound_bandwidth*2, inboundBandwidth = net_inbound_bandwidth*2, session_uuid = test_account_session)
    except:
	print "Test results were in line with expectations"
	pass

    test_util.test_dsc('set higher than net out and equal in ')    
    try:
	vm_ops.set_vm_nic_qos(vm_nic.uuid, outboundBandwidth = net_outbound_bandwidth*2, inboundBandwidth = net_inbound_bandwidth, session_uuid = test_account_session)
    except:
	print "Test results were in line with expectations"
	pass

    test_util.test_dsc('del net  in ')    
    try:
	vm_ops.del_vm_nic_qos(vm_nic.uuid, direction = 'in', session_uuid = test_account_session)
    except:
	print "Test results were in line with expectations"
	pass

    test_util.test_dsc('del net out ')    
    try:
	vm_ops.del_vm_nic_qos(vm_nic.uuid, direction = 'out', session_uuid = test_account_session)
    except:
	print "Test results were in line with expectations"
	pass

    test_util.test_dsc('set equal net out and  in ')    
    try:
	vm_ops.set_vm_nic_qos(vm_nic.uuid, outboundBandwidth = net_outbound_bandwidth, inboundBandwidth = net_inbound_bandwidth, session_uuid = test_account_session)
    #except:
    except Exception as e:	
	test_util.test_logger(e)

    test_util.test_dsc('set below net out and  in ')    
    vm_ops.set_vm_nic_qos(vm_nic.uuid, outboundBandwidth = net_outbound_bandwidth/2, inboundBandwidth = net_inbound_bandwidth/2, session_uuid = test_account_session)

    vm.check()
    vm.destroy(test_account_session)
    vm.check()
    vol_ops.delete_disk_offering(all_volume_offering_uuid)
    vol_ops.delete_disk_offering(rw_volume_offering_uuid)
    vol_ops.delete_volume(all_volume_uuid, test_account_session)
    vol_ops.delete_volume(rw_volume_uuid, test_account_session)
    acc_ops.delete_account(test_account_uuid)    
    vm_ops.delete_instance_offering(instance_offering_uuid)
    test_util.test_pass('Create VM Test Success')
コード例 #8
0
def test():
   test_util.test_dsc('Test Change VM Image Function')
   global vm
   #set overProvisioning.primaryStorage's value as 10
   con_ops.change_global_config('mevoco','overProvisioning.primaryStorage',10)
   test_lib.lib_create_disk_offering(diskSize=1099511627776,name="1T")
   l3_uuid = test_lib.lib_get_l3_by_name("l3VlanNetwork1").uuid
   image_uuid = test_lib.lib_get_image_by_name("ttylinux").uuid
   disk_offering_uuids = [test_lib.lib_get_disk_offering_by_name("smallDiskOffering").uuid,test_lib.lib_get_disk_offering_by_name("root-disk").uuid,test_lib.lib_get_disk_offering_by_name("1T").uuid]
   vm = test_stub.create_vm(l3_uuid_list = [l3_uuid],image_uuid = image_uuid,vm_name="test-vm",disk_offering_uuids = disk_offering_uuids)
   test_obj_dict.add_vm(vm)
   vm.check()

   vm_uuid = vm.get_vm().uuid
   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_ops.stop_vm(vm_uuid)
   vr = test_lib.lib_find_vr_by_vm(vm.get_vm())[0]
   vr_mgmt_ip = test_lib.lib_find_vr_mgmt_ip(vr)
   #stop vm's vr
   vm_ops.stop_vm(vr.uuid)
   #change vm image
   image_uuid = test_lib.lib_get_image_by_name("windows").uuid
   vm_ops.change_vm_image(vm_uuid,image_uuid)
   #check whether vr's status is running
   if vr.applianceVmType == 'vrouter':
      if not test_lib.lib_wait_target_up(vr_mgmt_ip,'7272',240):
         test_util.test_fail('vm:%s is not startup in 240 seconds.Fail to reboot it.' % vr.uuid)
      time.sleep(20)
   else:
      vm_ops.start_vm(vr.uuid)
      vm_ops.reconnect_vr(vr.uuid)
   vm_ops.start_vm(vm_uuid)
   vm.update()
   #check whether the windows vm is running successfully
   vm_ip = vm.get_vm().vmNics[0].ip
   if not test_lib.lib_wait_target_up(vm_ip,'23',1200):
      test_util.test_fail('vm:%s is not startup in 1200 seconds.Fail to reboot it.' % vm_uuid)
   #check whether data volumes attached to the vm has changed
   data_volumes_after_uuids = []
   data_volumes_after = test_lib.lib_get_data_volumes(vm.get_vm())
   for data_volume in data_volumes_after:
      data_volumes_after_uuids.append(data_volume.uuid)
   if set(last_data_volumes_uuids) != set(data_volumes_after_uuids):
      test_util.test_fail('Change Vm Image Failed.Data volumes changed.')
   #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.')

   #check whether the linux vm is running successfully
   vm_ops.stop_vm(vm_uuid)
   #stop vm's vr
   vm_ops.stop_vm(vr.uuid)
   image_uuid = test_lib.lib_get_image_by_name("image_for_sg_test").uuid
   vm_ops.change_vm_image(vm_uuid,image_uuid)
   #check whether vr's status is running
   if vr.applianceVmType == 'vrouter':
      if not test_lib.lib_wait_target_up(vr_mgmt_ip,'7272',240):
         test_util.test_fail('vm:%s is not startup in 240 seconds.Fail to reboot it.' % vr.uuid)
      time.sleep(20)
   else:
      vm_ops.start_vm(vr.uuid)
      vm_ops.reconnect_vr(vr.uuid)
   vm_ops.start_vm(vm_uuid)

   if not test_lib.lib_wait_target_up(vm_ip,'22',120):
      test_util.test_fail('vm:%s is not startup in 120 seconds.Fail to reboot it.' % vm_uuid)
   #check whether data volumes attached to the vm has changed
   data_volumes_after_uuids_linux = []
   data_volumes_after_linux = test_lib.lib_get_data_volumes(vm.get_vm())
   for data_volume in data_volumes_after_linux:
      data_volumes_after_uuids_linux.append(data_volume.uuid)
   if set(data_volumes_after_uuids) != set(data_volumes_after_uuids_linux):
      test_util.test_fail('Change Vm Image Failed.Data volumes changed.')
   #check whether the network config has changed
   l3network_uuid_after_linux = test_lib.lib_get_l3s_uuid_by_vm(vm.get_vm())
   if l3network_uuid_after != l3network_uuid_after_linux:
      test_util.test_fail('Change VM Image Failed.The Network config has changed.')
   #check whether primarystorage has changed
   primarystorage_uuid_after_linux = test_lib.lib_get_root_volume(vm.get_vm()).primaryStorageUuid
   if primarystorage_uuid_after_linux != primarystorage_uuid_after:
      test_util.test_fail('Change VM Image Failed.Primarystorage has changed.')

   test_lib.lib_destroy_vm_and_data_volumes(vm.get_vm())
   test_util.test_pass('Change Vm Image Test Success')
コード例 #9
0
def test():
   test_util.test_dsc('Test Change VM Image Function')
   #set overProvisioning.primaryStorage's value as 10
   con_ops.change_global_config('mevoco','overProvisioning.primaryStorage',10)
   global vm
   bs_cond = res_ops.gen_query_conditions("status","=","Connected")
   bss = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE, bs_cond, None, fields=['uuid'])
   if not bss:
      test_util.test_skip("not find available backup storage.Skip test")
   test_lib.lib_create_disk_offering(diskSize=1099511627776,name="1T")
   disk_offering_uuids = [test_lib.lib_get_disk_offering_by_name("smallDiskOffering").uuid,test_lib.lib_get_disk_offering_by_name("root-disk").uuid,test_lib.lib_get_disk_offering_by_name("1T").uuid]
   #create vm with 3 data volumes
   vm = test_stub.create_vm(image_name = "ttylinux",vm_name="test-vm",disk_offering_uuids = disk_offering_uuids)
   test_obj_dict.add_vm(vm)
   vm.check()

   vm_uuid = vm.get_vm().uuid
   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_ops.stop_vm(vm_uuid)
   image_option = test_util.ImageOption()
   image_option.set_name('windows_for_test')
   image_option.set_format('qcow2')
   image_option.set_mediaType('RootVolumeTemplate')
   image_option.set_platform('windows')
   #image_option.set_url('http://172.20.1.16:7480/diskimages/windows-telnet.qcow2')
   image_option.set_url(os.environ.get('windowsImageUrl'))
   image_option.set_backup_storage_uuid_list([bss[0].uuid])
   image_option.set_timeout(1800*1000)
   new_image = zstack_image_header.ZstackTestImage()
   new_image.set_creation_option(image_option)
   new_image.add_root_volume_template()

   image_windows_uuid = test_lib.lib_get_image_by_name("windows_for_test").uuid
   vm_ops.change_vm_image(vm_uuid,image_windows_uuid)
   vm_ops.start_vm(vm_uuid)
   vm.update()
   vm_ip = vm.get_vm().vmNics[0].ip
   #check whether the windows vm is running successfully
   if not test_lib.lib_wait_target_up(vm_ip,'23',1200):
      test_util.test_fail('vm:%s is not startup in 1200 seconds.Fail to reboot it.' % vm_uuid)
   #check whether data volumes attached to the vm has changed
   data_volumes_after_uuids = []
   data_volumes_after = test_lib.lib_get_data_volumes(vm.get_vm())
   for data_volume in data_volumes_after:
      data_volumes_after_uuids.append(data_volume.uuid)
   if set(last_data_volumes_uuids) != set(data_volumes_after_uuids):
      test_util.test_fail('Change Vm Image Failed.Data volumes changed.')
   #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.')
   #check whether the linux vm is running successfully
   image_linux_uuid = test_lib.lib_get_image_by_name("image_for_sg_test").uuid
   vm_ops.stop_vm(vm_uuid)
   vm_ops.change_vm_image(vm_uuid,image_linux_uuid)
   vm_ops.start_vm(vm_uuid)
   if not test_lib.lib_wait_target_up(vm_ip,'22',180):
      test_util.test_fail('vm:%s is not startup in 180 seconds.Fail to reboot it.' % vm_uuid)
   #check whether data volumes attached to the vm has changed
   data_volumes_after_uuids_linux = []
   data_volumes_after_linux = test_lib.lib_get_data_volumes(vm.get_vm())
   for data_volume in data_volumes_after_linux:
      data_volumes_after_uuids_linux.append(data_volume.uuid)
   if set(data_volumes_after_uuids) != set(data_volumes_after_uuids_linux):
      test_util.test_fail('Change Vm Image Failed.Data volumes changed.')
   #check whether the network config has changed
   l3network_uuid_after_linux = test_lib.lib_get_l3s_uuid_by_vm(vm.get_vm())
   if l3network_uuid_after != l3network_uuid_after_linux:
      test_util.test_fail('Change VM Image Failed.The Network config has changed.')
   #check whether primarystorage has changed
   primarystorage_uuid_after_linux = test_lib.lib_get_root_volume(vm.get_vm()).primaryStorageUuid
   if primarystorage_uuid_after != primarystorage_uuid_after_linux:
      test_util.test_fail('Change VM Image Failed.Primarystorage has changed.')


   test_lib.lib_destroy_vm_and_data_volumes(vm.get_vm())
   vm.expunge()
   img_ops.delete_image(image_windows_uuid)
   img_ops.expunge_image(image_windows_uuid)
   test_util.test_pass('Change Vm Image Test Success')
コード例 #10
0
def test():
   test_util.test_dsc('Test Change VM Image Function')
   #set overProvisioning.primaryStorage's value as 10
   primary_storage_list = res_ops.query_resource(res_ops.PRIMARY_STORAGE)
   for ps in primary_storage_list:
       if ps.type == "SharedBlock":
           test_util.test_skip('SharedBlock primary storage does not support overProvision')
   con_ops.change_global_config('mevoco','overProvisioning.primaryStorage',10)
   global vm
   test_lib.lib_create_disk_offering(diskSize=1099511627776,name="1T")
   l3_uuid = test_lib.lib_get_l3_by_name("l3VlanNetwork3").uuid
   image_uuid = test_lib.lib_get_image_by_name("ttylinux").uuid
   disk_offering_uuids = [test_lib.lib_get_disk_offering_by_name("smallDiskOffering").uuid,test_lib.lib_get_disk_offering_by_name("root-disk").uuid,test_lib.lib_get_disk_offering_by_name("1T").uuid]
   vm = test_stub.create_vm(l3_uuid_list = [l3_uuid],image_uuid = image_uuid,vm_name="test-nxs",disk_offering_uuids = disk_offering_uuids)
   test_obj_dict.add_vm(vm)
   vm.check()

   vm_uuid = vm.get_vm().uuid
   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

   ps = test_lib.lib_get_primary_storage_by_uuid(last_primarystorage_uuid)
   avail_cap = ps.availableCapacity
   total_cap = ps.totalCapacity

   vm_ops.stop_vm(vm_uuid)
   vr = test_lib.lib_find_vr_by_vm(vm.get_vm())[0]
   vr_mgmt_ip = test_lib.lib_find_vr_mgmt_ip(vr)
   #stop vm's vr
   vm_ops.stop_vm(vr.uuid)
   image_uuid = test_lib.lib_get_image_by_name("image_for_sg_test").uuid
   vm_ops.change_vm_image(vm_uuid,image_uuid)
   #check whether vr's status is running
   if vr.applianceVmType == 'vrouter':
      if not test_lib.lib_wait_target_up(vr_mgmt_ip,'7272',240):
         test_util.test_fail('vm:%s is not startup in 240 seconds.Fail to reboot it.' % vr.uuid)
      time.sleep(20)
   #if vr.state == 'Stopped':
   else:
      vm_ops.start_vm(vr.uuid)
      vm_ops.reconnect_vr(vr.uuid)
   vm_ops.start_vm(vm_uuid)
   vm.update()
   #check whether the vm is running successfully
   if not test_lib.lib_wait_target_up(vm.get_vm().vmNics[0].ip,'22',120):
      test_util.test_fail('vm:%s is not startup in 120 seconds.Fail to reboot it.' % vm_uuid)
   #check whether data volumes attached to the vm has changed
   data_volumes_after_uuids = []
   data_volumes_after = test_lib.lib_get_data_volumes(vm.get_vm())
   for data_volume in data_volumes_after:
      data_volumes_after_uuids.append(data_volume.uuid)
   if set(last_data_volumes_uuids) != set(data_volumes_after_uuids):
      test_util.test_fail('Change Vm Image Failed.Data volumes changed.')
   #check whether the network config has changed
   l3network_uuid_after = test_lib.lib_get_l3s_uuid_by_vm(vm.get_vm())
   if set(l3network_uuid_after) != set(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.')

   ps = test_lib.lib_get_primary_storage_by_uuid(primarystorage_uuid_after)
   avail_cap1 = ps.availableCapacity
   total_cap1 = ps.totalCapacity

   if total_cap != total_cap1:
      test_util.test_fail('Primary Storage total capacity is not same,after changing vm image:%s.The previous value:%s, the current value:%s' % (image_uuid,total_cap,total_cap1))
   if avail_cap <= avail_cap1:
      test_util.test_fail('Primary Storage available capacity is not correct,after changing larger image:%s.The previous value:%s, the current value:%s' % (image_uuid,avail_cap,avail_cap1))

   vm_ops.stop_vm(vm_uuid)
   #stop vm's vr
   vm_ops.stop_vm(vr.uuid)
   image_tiny_uuid = test_lib.lib_get_image_by_name("ttylinux").uuid
   vm_ops.change_vm_image(vm_uuid,image_tiny_uuid)
   #check whether vr's status is running
   if vr.applianceVmType == 'vrouter':
      if not test_lib.lib_wait_target_up(vr_mgmt_ip,'7272',240):
         test_util.test_fail('vm:%s is not startup in 240 seconds.Fail to reboot it.' % vr.uuid)
      time.sleep(20)
   #if vr.state == 'Stopped':
   else:
      vm_ops.start_vm(vr.uuid)
      vm_ops.reconnect_vr(vr.uuid)
   vm_ops.start_vm(vm_uuid)
   vm.update()
   #check whether the vm is running successfully
   if not test_lib.lib_wait_target_up(vm.get_vm().vmNics[0].ip,'22',120):
      test_util.test_fail('vm:%s is not startup in 120 seconds.Fail to reboot it.' % vm_uuid)
   #check whether data volumes attached to the vm has changed
   data_volumes_after_uuids_tiny = []
   data_volumes_after_tiny = test_lib.lib_get_data_volumes(vm.get_vm())
   for data_volume in data_volumes_after_tiny:
      data_volumes_after_uuids_tiny.append(data_volume.uuid)
   if set(data_volumes_after_uuids_tiny) != set(data_volumes_after_uuids):
      test_util.test_fail('Change Vm Image Failed.Data volumes changed.')
   #check whether the network config has changed
   l3network_uuid_after_tiny = test_lib.lib_get_l3s_uuid_by_vm(vm.get_vm())
   if set(l3network_uuid_after_tiny) != set(l3network_uuid_after_tiny):
      test_util.test_fail('Change VM Image Failed.The Network config has changed.')
   #check whether primarystorage has changed
   primarystorage_uuid_after_tiny = test_lib.lib_get_root_volume(vm.get_vm()).primaryStorageUuid
   if primarystorage_uuid_after != primarystorage_uuid_after_tiny:
      test_util.test_fail('Change VM Image Failed.Primarystorage has changed.')

   ps = test_lib.lib_get_primary_storage_by_uuid(primarystorage_uuid_after_tiny)
   avail_cap2 = ps.availableCapacity
   total_cap2 = ps.totalCapacity

   if total_cap2 != total_cap1:
      test_util.test_fail('Primary Storage total capacity is not same,after changing vm image:%s.The previous value:%s, the current value:%s' % (image_uuid,total_cap1,total_cap2))
   if avail_cap2 <= avail_cap1:
      test_util.test_fail('Primary Storage available capacity is not correct,after changing smaller image:%s.The previous value:%s, the current value:%s' % (image_uuid,avail_cap1,avail_cap2))


   test_lib.lib_destroy_vm_and_data_volumes(vm.get_vm())
   test_util.test_pass('Change Vm Image Test Success')
コード例 #11
0
def test():
   test_util.test_dsc('Test Change VM Image Function')
   primary_storage_list = res_ops.query_resource(res_ops.PRIMARY_STORAGE)
   for ps in primary_storage_list:
       if ps.type == "SharedBlock":
           test_util.test_skip('SharedBlock primary storage does not support overProvision')
   global vm
   #set overProvisioning.primaryStorage's value as 10
   con_ops.change_global_config('mevoco','overProvisioning.primaryStorage',10)
   test_lib.lib_create_disk_offering(diskSize=1099511627776,name="1T")
   l3_uuid = test_lib.lib_get_l3_by_name("l3VlanNetwork1").uuid
   image_uuid = test_lib.lib_get_image_by_name("ttylinux").uuid
   disk_offering_uuids = [test_lib.lib_get_disk_offering_by_name("smallDiskOffering").uuid,test_lib.lib_get_disk_offering_by_name("root-disk").uuid,test_lib.lib_get_disk_offering_by_name("1T").uuid]
   #choose the ps which availableCapacity >= 105G
   cond = res_ops.gen_query_conditions('availableCapacity', '>=', '112742891520')
   ps_uuid = res_ops.query_resource(res_ops.PRIMARY_STORAGE, cond)[0].uuid
   system_tag = "primaryStorageUuidForDataVolume::%s" % ps_uuid
   vm = test_stub.create_vm(l3_uuid_list = [l3_uuid],image_uuid = image_uuid,vm_name="test-vm",disk_offering_uuids = disk_offering_uuids,system_tags=[system_tag])
   test_obj_dict.add_vm(vm)
   vm.check()

   vm_uuid = vm.get_vm().uuid
   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_ops.stop_vm(vm_uuid)
   vr = test_lib.lib_find_vr_by_vm(vm.get_vm())[0]
   vr_mgmt_ip = test_lib.lib_find_vr_mgmt_ip(vr)
   #stop vm's vr
   vm_ops.stop_vm(vr.uuid)
   #change vm image
   image_uuid = test_lib.lib_get_image_by_name("windows").uuid
   vm_ops.change_vm_image(vm_uuid,image_uuid)
   #check whether vr's status is running
   if vr.applianceVmType == 'vrouter':
      if not test_lib.lib_wait_target_up(vr_mgmt_ip,'7272',240):
         test_util.test_fail('vm:%s is not startup in 240 seconds.Fail to reboot it.' % vr.uuid)
      time.sleep(20)
   else:
      vm_ops.start_vm(vr.uuid)
      vm_ops.reconnect_vr(vr.uuid)
   vm_ops.start_vm(vm_uuid)
   vm.update()
   #check whether the windows vm is running successfully
   vm_ip = vm.get_vm().vmNics[0].ip
   if not test_lib.lib_wait_target_up(vm_ip,'23',1200):
      test_util.test_fail('vm:%s is not startup in 1200 seconds.Fail to reboot it.' % vm_uuid)
   #check whether data volumes attached to the vm has changed
   data_volumes_after_uuids = []
   data_volumes_after = test_lib.lib_get_data_volumes(vm.get_vm())
   for data_volume in data_volumes_after:
      data_volumes_after_uuids.append(data_volume.uuid)
   if set(last_data_volumes_uuids) != set(data_volumes_after_uuids):
      test_util.test_fail('Change Vm Image Failed.Data volumes changed.')
   #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.')

   #check whether the linux vm is running successfully
   vm_ops.stop_vm(vm_uuid)
   #stop vm's vr
   vm_ops.stop_vm(vr.uuid)
   image_uuid = test_lib.lib_get_image_by_name("image_for_sg_test").uuid
   vm_ops.change_vm_image(vm_uuid,image_uuid)
   #check whether vr's status is running
   if vr.applianceVmType == 'vrouter':
      if not test_lib.lib_wait_target_up(vr_mgmt_ip,'7272',240):
         test_util.test_fail('vm:%s is not startup in 240 seconds.Fail to reboot it.' % vr.uuid)
      time.sleep(20)
   else:
      vm_ops.start_vm(vr.uuid)
      vm_ops.reconnect_vr(vr.uuid)
   vm_ops.start_vm(vm_uuid)

   if not test_lib.lib_wait_target_up(vm_ip,'22',180):
      test_util.test_fail('vm:%s is not startup in 180 seconds.Fail to reboot it.' % vm_uuid)
   #check whether data volumes attached to the vm has changed
   data_volumes_after_uuids_linux = []
   data_volumes_after_linux = test_lib.lib_get_data_volumes(vm.get_vm())
   for data_volume in data_volumes_after_linux:
      data_volumes_after_uuids_linux.append(data_volume.uuid)
   if set(data_volumes_after_uuids) != set(data_volumes_after_uuids_linux):
      test_util.test_fail('Change Vm Image Failed.Data volumes changed.')
   #check whether the network config has changed
   l3network_uuid_after_linux = test_lib.lib_get_l3s_uuid_by_vm(vm.get_vm())
   if l3network_uuid_after != l3network_uuid_after_linux:
      test_util.test_fail('Change VM Image Failed.The Network config has changed.')
   #check whether primarystorage has changed
   primarystorage_uuid_after_linux = test_lib.lib_get_root_volume(vm.get_vm()).primaryStorageUuid
   if primarystorage_uuid_after_linux != primarystorage_uuid_after:
      test_util.test_fail('Change VM Image Failed.Primarystorage has changed.')

   test_lib.lib_destroy_vm_and_data_volumes(vm.get_vm())
   test_util.test_pass('Change Vm Image Test Success')
def test():
    global vm, all_volume_offering_uuid, rw_volume_offering_uuid, all_volume_uuid, rw_volume_uuid, volume_offering_3, volume_offering_4, volume_offering_5, volume_offering_6 
    global instance_offering_uuid, volume_uuid_3, volume_uuid_4, volume_uuid_5, volume_uuid_6
    
    #create disk offering
    test_util.test_dsc('create disk offering')
    name_all = 'all_disk_offering'	
    volume_bandwidth = 30*1024*1024
    all_volume_offering = test_lib.lib_create_disk_offering(name = name_all, volume_bandwidth = volume_bandwidth)
    all_volume_offering_uuid = all_volume_offering.uuid

    name_rw = 'rw_disk_offering'	
    volume_read_bandwidth = 90*1024*1024
    volume_write_bandwidth = 100*1024*1024
    rw_volume_offering = test_lib.lib_create_disk_offering(name = name_rw, read_bandwidth = volume_read_bandwidth, write_bandwidth = volume_write_bandwidth)
    rw_volume_offering_uuid = rw_volume_offering.uuid
    
    volume_offering_3 = test_lib.lib_create_disk_offering(name = "volume_offering_3")
    volume_offering_4 = test_lib.lib_create_disk_offering(name = "volume_offering_4")
    volume_offering_5 = test_lib.lib_create_disk_offering(name = "volume_offering_5")
    volume_offering_6 = test_lib.lib_create_disk_offering(name = "volume_offering_6")

    #create instance offering 
    test_util.test_dsc('create instance offering')
    read_bandwidth = 50*1024*1024
    write_bandwidth = 60*1024*1024
    net_outbound_bandwidth = 70*1024*1024
    net_inbound_bandwidth = 80*1024*1024
    new_instance_offering = test_lib.lib_create_instance_offering(read_bandwidth = read_bandwidth, write_bandwidth=write_bandwidth, net_outbound_bandwidth = net_outbound_bandwidth, net_inbound_bandwidth = net_inbound_bandwidth)
    instance_offering_uuid = new_instance_offering.uuid

    #create vm with 2 data volumes
    test_util.test_dsc('create vm with volumes qos by normal account a')
    l3net_uuid = res_ops.get_resource(res_ops.L3_NETWORK)[0].uuid
    cond = res_ops.gen_query_conditions('name', '=', 'ttylinux')
    image_uuid = res_ops.query_resource(res_ops.IMAGE, cond)[0].uuid
    vm_creation_option = test_util.VmOption()
    vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
    vm_creation_option.set_image_uuid(image_uuid)
    vm_creation_option.set_l3_uuids([l3net_uuid])

    vm = test_stub.create_vm_with_volume(vm_creation_option = vm_creation_option, data_volume_uuids = [all_volume_offering_uuid, rw_volume_offering_uuid, volume_offering_3.uuid, volume_offering_4.uuid, volume_offering_5.uuid, volume_offering_6.uuid])
    vm_inv = vm.get_vm()


    # get the volume uuid
    test_util.test_dsc('get the vm data volumes')
    cond1 = res_ops.gen_query_conditions("diskOfferingUuid", '=', all_volume_offering_uuid)
    cond2 = res_ops.gen_query_conditions("diskOfferingUuid", '=', rw_volume_offering_uuid)
    cond3 = res_ops.gen_query_conditions("diskOfferingUuid", '=', volume_offering_3.uuid)
    cond4 = res_ops.gen_query_conditions("diskOfferingUuid", '=', volume_offering_4.uuid)
    cond5 = res_ops.gen_query_conditions("diskOfferingUuid", '=', volume_offering_5.uuid)
    cond6 = res_ops.gen_query_conditions("diskOfferingUuid", '=', volume_offering_6.uuid)
    all_volume_uuid = res_ops.query_resource(res_ops.VOLUME, cond1)[0].uuid
    rw_volume_uuid = res_ops.query_resource(res_ops.VOLUME, cond2)[0].uuid
    volume_uuid_3 = res_ops.query_resource(res_ops.VOLUME, cond3)[0].uuid
    volume_uuid_4 = res_ops.query_resource(res_ops.VOLUME, cond4)[0].uuid
    volume_uuid_5 = res_ops.query_resource(res_ops.VOLUME, cond5)[0].uuid
    volume_uuid_6 = res_ops.query_resource(res_ops.VOLUME, cond6)[0].uuid

    tag_ops.create_system_tag('VolumeVO', all_volume_uuid, "capability::virtio-scsi")
    tag_ops.create_system_tag('VolumeVO', rw_volume_uuid, "capability::virtio-scsi")
    tag_ops.create_system_tag('VolumeVO', volume_uuid_3, "capability::virtio-scsi")
    tag_ops.create_system_tag('VolumeVO', volume_uuid_4, "capability::virtio-scsi")
    tag_ops.create_system_tag('VolumeVO', volume_uuid_5, "capability::virtio-scsi")
    tag_ops.create_system_tag('VolumeVO', volume_uuid_6, "capability::virtio-scsi")

    vm.check()
    vm.reboot()

    vol_ops.detach_volume(all_volume_uuid, vm_inv.uuid)
    vol_ops.detach_volume(rw_volume_uuid, vm_inv.uuid)
    vol_ops.detach_volume(volume_uuid_3, vm_inv.uuid)
    vol_ops.detach_volume(volume_uuid_4, vm_inv.uuid)
    vol_ops.detach_volume(volume_uuid_5, vm_inv.uuid)
    vol_ops.detach_volume(volume_uuid_6, vm_inv.uuid)
     
    vm.check()
    
    vol_ops.attach_volume(all_volume_uuid, vm_inv.uuid)
    vol_ops.attach_volume(rw_volume_uuid, vm_inv.uuid)
    vol_ops.attach_volume(volume_uuid_3, vm_inv.uuid)
    vol_ops.attach_volume(volume_uuid_4, vm_inv.uuid)
    vol_ops.attach_volume(volume_uuid_5, vm_inv.uuid)
    vol_ops.attach_volume(volume_uuid_6, vm_inv.uuid)

    vm.reboot()
    vm.check()
    
    vol_ops.detach_volume(all_volume_uuid, vm_inv.uuid)
    vm.check()

    vol_ops.attach_volume(all_volume_uuid, vm_inv.uuid)

    vm.destroy()
    vm.check()

    vol_ops.delete_disk_offering(all_volume_offering_uuid)
    vol_ops.delete_disk_offering(rw_volume_offering_uuid)
    vol_ops.delete_disk_offering(volume_offering_3.uuid)
    vol_ops.delete_disk_offering(volume_offering_4.uuid)
    vol_ops.delete_disk_offering(volume_offering_5.uuid)
    vol_ops.delete_disk_offering(volume_offering_6.uuid)
    vol_ops.delete_volume(all_volume_uuid)
    vol_ops.delete_volume(rw_volume_uuid)
    vol_ops.delete_volume(volume_uuid_3)
    vol_ops.delete_volume(volume_uuid_4)
    vol_ops.delete_volume(volume_uuid_5)
    vol_ops.delete_volume(volume_uuid_6)
    vm_ops.delete_instance_offering(instance_offering_uuid)
    test_util.test_pass('Create VM with volumes and detach/attach and after reboot and detach/attach Test Success')
コード例 #13
0
def test():
    test_util.test_dsc('Test Change VM Image Function')
    #set overProvisioning.primaryStorage's value as 10
    con_ops.change_global_config('mevoco', 'overProvisioning.primaryStorage',
                                 10)
    global vm
    bs_cond = res_ops.gen_query_conditions("status", "=", "Connected")
    bss = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE,
                                        bs_cond,
                                        None,
                                        fields=['uuid'])
    if not bss:
        test_util.test_skip("not find available backup storage.Skip test")
    test_lib.lib_create_disk_offering(diskSize=1099511627776, name="1T")
    disk_offering_uuids = [
        test_lib.lib_get_disk_offering_by_name("smallDiskOffering").uuid,
        test_lib.lib_get_disk_offering_by_name("root-disk").uuid,
        test_lib.lib_get_disk_offering_by_name("1T").uuid
    ]
    #create vm with 3 data volumes
    vm = test_stub.create_vm(image_name="ttylinux",
                             vm_name="test-vm",
                             disk_offering_uuids=disk_offering_uuids)
    test_obj_dict.add_vm(vm)
    vm.check()

    vm_uuid = vm.get_vm().uuid
    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_ops.stop_vm(vm_uuid)
    image_option = test_util.ImageOption()
    image_option.set_name('windows_for_test')
    image_option.set_format('qcow2')
    image_option.set_mediaType('RootVolumeTemplate')
    image_option.set_platform('windows')
    image_option.set_url(
        'http://172.20.1.16:7480/diskimages/windows-telnet.qcow2')
    image_option.set_backup_storage_uuid_list([bss[0].uuid])
    image_option.set_timeout(1800 * 1000)
    new_image = zstack_image_header.ZstackTestImage()
    new_image.set_creation_option(image_option)
    new_image.add_root_volume_template()

    image_windows_uuid = test_lib.lib_get_image_by_name(
        "windows_for_test").uuid
    vm_ops.change_vm_image(vm_uuid, image_windows_uuid)
    vm_ops.start_vm(vm_uuid)
    vm.update()
    vm_ip = vm.get_vm().vmNics[0].ip
    #check whether the windows vm is running successfully
    if not test_lib.lib_wait_target_up(vm_ip, '23', 1200):
        test_util.test_fail(
            'vm:%s is not startup in 1200 seconds.Fail to reboot it.' %
            vm_uuid)
    #check whether data volumes attached to the vm has changed
    data_volumes_after_uuids = []
    data_volumes_after = test_lib.lib_get_data_volumes(vm.get_vm())
    for data_volume in data_volumes_after:
        data_volumes_after_uuids.append(data_volume.uuid)
    if set(last_data_volumes_uuids) != set(data_volumes_after_uuids):
        test_util.test_fail('Change Vm Image Failed.Data volumes changed.')
    #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.')
    #check whether the linux vm is running successfully
    image_linux_uuid = test_lib.lib_get_image_by_name("image_for_sg_test").uuid
    vm_ops.stop_vm(vm_uuid)
    vm_ops.change_vm_image(vm_uuid, image_linux_uuid)
    vm_ops.start_vm(vm_uuid)
    if not test_lib.lib_wait_target_up(vm_ip, '22', 120):
        test_util.test_fail(
            'vm:%s is not startup in 120 seconds.Fail to reboot it.' % vm_uuid)
    #check whether data volumes attached to the vm has changed
    data_volumes_after_uuids_linux = []
    data_volumes_after_linux = test_lib.lib_get_data_volumes(vm.get_vm())
    for data_volume in data_volumes_after_linux:
        data_volumes_after_uuids_linux.append(data_volume.uuid)
    if set(data_volumes_after_uuids) != set(data_volumes_after_uuids_linux):
        test_util.test_fail('Change Vm Image Failed.Data volumes changed.')
    #check whether the network config has changed
    l3network_uuid_after_linux = test_lib.lib_get_l3s_uuid_by_vm(vm.get_vm())
    if l3network_uuid_after != l3network_uuid_after_linux:
        test_util.test_fail(
            'Change VM Image Failed.The Network config has changed.')
    #check whether primarystorage has changed
    primarystorage_uuid_after_linux = test_lib.lib_get_root_volume(
        vm.get_vm()).primaryStorageUuid
    if primarystorage_uuid_after != primarystorage_uuid_after_linux:
        test_util.test_fail(
            'Change VM Image Failed.Primarystorage has changed.')

    test_lib.lib_destroy_vm_and_data_volumes(vm.get_vm())
    vm.expunge()
    img_ops.delete_image(image_windows_uuid)
    img_ops.expunge_image(image_windows_uuid)
    test_util.test_pass('Change Vm Image Test Success')
コード例 #14
0
def test():
    test_util.test_dsc('Test Change VM Image Function')
    #set overProvisioning.primaryStorage's value as 10
    con_ops.change_global_config('mevoco', 'overProvisioning.primaryStorage',
                                 10)
    global vm
    test_lib.lib_create_disk_offering(diskSize=1099511627776, name="1T")
    disk_offering_uuids = [
        test_lib.lib_get_disk_offering_by_name("smallDiskOffering").uuid,
        test_lib.lib_get_disk_offering_by_name("root-disk").uuid,
        test_lib.lib_get_disk_offering_by_name("1T").uuid
    ]
    vm = test_stub.create_vm(image_name="ttylinux",
                             vm_name="test-vm",
                             disk_offering_uuids=disk_offering_uuids)
    test_obj_dict.add_vm(vm)
    vm.check()

    vm_uuid = vm.get_vm().uuid
    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

    ps = test_lib.lib_get_primary_storage_by_uuid(last_primarystorage_uuid)
    avail_cap = ps.availableCapacity
    total_cap = ps.totalCapacity

    vm_ops.stop_vm(vm_uuid)
    image_uuid = test_lib.lib_get_image_by_name("image_for_sg_test").uuid
    vm_ops.change_vm_image(vm_uuid, image_uuid)
    vm_ops.start_vm(vm_uuid)
    vm.update()
    #check whether the vm is running successfully
    if not test_lib.lib_wait_target_up(vm.get_vm().vmNics[0].ip, '22', 120):
        test_util.test_fail(
            'vm:%s is not startup in 120 seconds.Fail to reboot it.' % vm_uuid)
    #check whether data volumes attached to the vm has changed
    data_volumes_after_uuids = []
    data_volumes_after = test_lib.lib_get_data_volumes(vm.get_vm())
    for data_volume in data_volumes_after:
        data_volumes_after_uuids.append(data_volume.uuid)
    if set(last_data_volumes_uuids) != set(data_volumes_after_uuids):
        test_util.test_fail('Change Vm Image Failed.Data volumes changed.')
    #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.')

    ps = test_lib.lib_get_primary_storage_by_uuid(primarystorage_uuid_after)
    avail_cap1 = ps.availableCapacity
    total_cap1 = ps.totalCapacity

    if total_cap != total_cap1:
        test_util.test_fail(
            'Primary Storage total capacity is not same,after changing vm image:%s.The previous value:%s, the current value:%s'
            % (image_uuid, total_cap, total_cap1))
    if avail_cap <= avail_cap1:
        test_util.test_fail(
            'Primary Storage available capacity is not correct,after changing larger image:%s.The previous value:%s, the current value:%s'
            % (image_uuid, avail_cap, avail_cap1))

    vm_ops.stop_vm(vm_uuid)
    image_tiny_uuid = test_lib.lib_get_image_by_name("ttylinux").uuid
    vm_ops.change_vm_image(vm_uuid, image_tiny_uuid)
    vm_ops.start_vm(vm_uuid)
    vm.update()
    #check whether the vm is running successfully
    if not test_lib.lib_wait_target_up(vm.get_vm().vmNics[0].ip, '22', 120):
        test_util.test_fail(
            'vm:%s is not startup in 120 seconds.Fail to reboot it.' % vm_uuid)
    #check whether data volumes attached to the vm has changed
    data_volumes_after_uuids_tiny = []
    data_volumes_after_tiny = test_lib.lib_get_data_volumes(vm.get_vm())
    for data_volume in data_volumes_after_tiny:
        data_volumes_after_uuids_tiny.append(data_volume.uuid)
    if set(data_volumes_after_uuids_tiny) != set(data_volumes_after_uuids):
        test_util.test_fail('Change Vm Image Failed.Data volumes changed.')
    #check whether the network config has changed
    l3network_uuid_after_tiny = test_lib.lib_get_l3s_uuid_by_vm(vm.get_vm())
    if l3network_uuid_after_tiny != l3network_uuid_after:
        test_util.test_fail(
            'Change VM Image Failed.The Network config has changed.')
    #check whether primarystorage has changed
    primarystorage_uuid_after_tiny = test_lib.lib_get_root_volume(
        vm.get_vm()).primaryStorageUuid
    if primarystorage_uuid_after_tiny != primarystorage_uuid_after:
        test_util.test_fail(
            'Change VM Image Failed.Primarystorage has changed.')

    ps = test_lib.lib_get_primary_storage_by_uuid(
        primarystorage_uuid_after_tiny)
    avail_cap2 = ps.availableCapacity
    total_cap2 = ps.totalCapacity

    if total_cap2 != total_cap1:
        test_util.test_fail(
            'Primary Storage total capacity is not same,after changing vm image:%s.The previous value:%s, the current value:%s'
            % (image_uuid, total_cap1, total_cap2))
    if avail_cap2 <= avail_cap1:
        test_util.test_fail(
            'Primary Storage available capacity is not correct,after changing smaller image:%s.The previous value:%s, the current value:%s'
            % (image_uuid, avail_cap1, avail_cap2))

    test_lib.lib_destroy_vm_and_data_volumes(vm.get_vm())
    vm.expunge()
    test_util.test_pass('Change Vm Image Test Success')
コード例 #15
0
def test():
   test_util.test_dsc('Test Change VM Image Function')
   #set overProvisioning.primaryStorage's value as 10
   con_ops.change_global_config('mevoco','overProvisioning.primaryStorage',10)
   global vm
   test_lib.lib_create_disk_offering(diskSize=1099511627776,name="1T")
   disk_offering_uuids = [test_lib.lib_get_disk_offering_by_name("smallDiskOffering").uuid,test_lib.lib_get_disk_offering_by_name("root-disk").uuid,test_lib.lib_get_disk_offering_by_name("1T").uuid]
   vm = test_stub.create_vm(image_name = "ttylinux",vm_name="test-vm",disk_offering_uuids = disk_offering_uuids)
   test_obj_dict.add_vm(vm)
   vm.check()

   vm_uuid = vm.get_vm().uuid
   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

   ps = test_lib.lib_get_primary_storage_by_uuid(last_primarystorage_uuid)
   avail_cap = ps.availableCapacity
   total_cap = ps.totalCapacity

   vm_ops.stop_vm(vm_uuid)
   image = test_lib.lib_get_image_by_name("image_for_sg_test")
   image_uuid = image.uuid
   image_tiny = test_lib.lib_get_image_by_name("ttylinux")
   image_tiny_uuid = image_tiny.uuid
   change_size = (image.size-image_tiny.size)/10

   vm_ops.change_vm_image(vm_uuid,image_uuid)
   vm_ops.start_vm(vm_uuid)
   vm.update()
   #check whether the vm is running successfully
   if not test_lib.lib_wait_target_up(vm.get_vm().vmNics[0].ip,'22',180):
      test_util.test_fail('vm:%s is not startup in 180 seconds.Fail to reboot it.' % vm_uuid)
   #check whether data volumes attached to the vm has changed
   data_volumes_after_uuids = []
   data_volumes_after = test_lib.lib_get_data_volumes(vm.get_vm())
   for data_volume in data_volumes_after:
      data_volumes_after_uuids.append(data_volume.uuid)
   if set(last_data_volumes_uuids) != set(data_volumes_after_uuids):
      test_util.test_fail('Change Vm Image Failed.Data volumes changed.')
   #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.')
   
   ps = test_lib.lib_get_primary_storage_by_uuid(primarystorage_uuid_after)
   avail_cap1 = ps.availableCapacity
   total_cap1 = ps.totalCapacity

   if total_cap != total_cap1:
      test_util.test_fail('Primary Storage total capacity is not same,after changing vm image:%s.The previous value:%s, the current value:%s' % (image_uuid,total_cap,total_cap1))
   if not (avail_cap1-1) <= (avail_cap - change_size) <= (avail_cap1+1):
      test_util.test_fail('Primary Storage available capacity is not correct,after changing larger image:%s.The previous value:%s, the current value:%s' % (image_uuid,avail_cap,avail_cap1))

   vm_ops.stop_vm(vm_uuid)
   image_tiny_uuid = image_tiny.uuid
   vm_ops.change_vm_image(vm_uuid,image_tiny_uuid)
   vm_ops.start_vm(vm_uuid)
   vm.update()
   #check whether the vm is running successfully
   if not test_lib.lib_wait_target_up(vm.get_vm().vmNics[0].ip,'22',180):
      test_util.test_fail('vm:%s is not startup in 180 seconds.Fail to reboot it.' % vm_uuid)
   #check whether data volumes attached to the vm has changed
   data_volumes_after_uuids_tiny = []
   data_volumes_after_tiny = test_lib.lib_get_data_volumes(vm.get_vm())
   for data_volume in data_volumes_after_tiny:
      data_volumes_after_uuids_tiny.append(data_volume.uuid)
   if set(data_volumes_after_uuids_tiny) != set(data_volumes_after_uuids):
      test_util.test_fail('Change Vm Image Failed.Data volumes changed.')
   #check whether the network config has changed
   l3network_uuid_after_tiny = test_lib.lib_get_l3s_uuid_by_vm(vm.get_vm())
   if l3network_uuid_after_tiny != l3network_uuid_after:
      test_util.test_fail('Change VM Image Failed.The Network config has changed.')
   #check whether primarystorage has changed
   primarystorage_uuid_after_tiny = test_lib.lib_get_root_volume(vm.get_vm()).primaryStorageUuid
   if primarystorage_uuid_after_tiny != primarystorage_uuid_after:
      test_util.test_fail('Change VM Image Failed.Primarystorage has changed.')

   ps = test_lib.lib_get_primary_storage_by_uuid(primarystorage_uuid_after_tiny)
   avail_cap2 = ps.availableCapacity
   total_cap2 = ps.totalCapacity

   if total_cap2 != total_cap1:
      test_util.test_fail('Primary Storage total capacity is not same,after changing vm image:%s.The previous value:%s, the current value:%s' % (image_tiny_uuid,total_cap1,total_cap2))
   if not (change_size-1)<=(avail_cap2 - avail_cap1)<= (change_size+1):
      test_util.test_fail('Primary Storage available capacity is not correct,after changing smaller image:%s.The previous value:%s, the current value:%s' % (image_tiny_uuid,avail_cap1,avail_cap2))



   test_lib.lib_destroy_vm_and_data_volumes(vm.get_vm())
   vm.expunge()
   test_util.test_pass('Change Vm Image Test Success')