def test():
    #skip ceph in c74
    cmd = "cat /etc/redhat-release | grep '7.4'"
    mn_ip = res_ops.query_resource(res_ops.MANAGEMENT_NODE)[0].hostName
    rsp = test_lib.lib_execute_ssh_cmd(mn_ip, 'root', 'password', cmd, 180)
    if rsp != False:
        ps = res_ops.query_resource(res_ops.PRIMARY_STORAGE)
        for i in ps:
            if i.type == 'Ceph':
                test_util.test_skip('cannot hotplug iso to the vm in ceph,it is a libvirt bug:https://bugzilla.redhat.com/show_bug.cgi?id=1541702.')    

    global iso
    global test_obj_dict

    # run condition
    allow_bs_list = [inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE, inventory.CEPH_BACKUP_STORAGE_TYPE]
    test_lib.skip_test_when_bs_type_not_in_list(allow_bs_list)

    hosts = res_ops.query_resource(res_ops.HOST)
    if len(hosts) <= 1:
        test_util.test_skip("skip for host_num is not satisfy condition host_num>1")

    # add iso and create vm from iso
    iso = test_stub.add_test_minimal_iso('minimal_iso')
    test_obj_dict.add_image(iso)
    root_volume_offering = test_stub.add_test_root_volume_offering('root-disk-iso', 10737418240)
    test_obj_dict.add_disk_offering(root_volume_offering)
    vm_offering = test_stub.add_test_vm_offering(2, 1024*1024*1024, 'iso-vm-offering')
    test_obj_dict.add_instance_offering(vm_offering)
    vm = test_stub.create_vm_with_iso_for_test(vm_offering.uuid, iso.image.uuid, root_volume_offering.uuid, 'iso-vm')
    test_obj_dict.add_vm(vm)

    # check vm
    vm_inv = vm.get_vm()
    test_lib.lib_set_vm_host_l2_ip(vm_inv)
    test_lib.lib_wait_target_up(vm.get_vm().vmNics[0].ip, 22, 1800)

    # clone vm
    cloned_vm_name = ['cloned_vm']
    cloned_vm_obj = vm.clone(cloned_vm_name)[0]
    test_obj_dict.add_vm(cloned_vm_obj)

    # delete iso
    iso.delete()

    # vm ops test
    test_stub.vm_ops_test(cloned_vm_obj, "VM_TEST_ATTACH")

    # expunge iso
    iso.expunge()

    #detach iso
    img_ops.detach_iso(vm.vm.uuid)

    # vm ops test
    test_stub.vm_ops_test(cloned_vm_obj, "VM_TEST_MIGRATE")

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Cloned VM ops for BS Success')
def test():
    global iso
    global test_obj_dict

    # run condition
    allow_bs_list = [
        inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE,
        inventory.CEPH_BACKUP_STORAGE_TYPE
    ]
    test_lib.skip_test_when_bs_type_not_in_list(allow_bs_list)

    hosts = res_ops.query_resource(res_ops.HOST)
    if len(hosts) <= 1:
        test_util.test_skip(
            "skip for host_num is not satisfy condition host_num>1")

    # add iso and create vm from iso
    iso = test_stub.add_test_minimal_iso('minimal_iso')
    test_obj_dict.add_image(iso)
    root_volume_offering = test_stub.add_test_root_volume_offering(
        'root-disk-iso', 10737418240)
    test_obj_dict.add_disk_offering(root_volume_offering)
    vm_offering = test_stub.add_test_vm_offering(2, 1024 * 1024 * 1024,
                                                 'iso-vm-offering')
    test_obj_dict.add_instance_offering(vm_offering)
    vm = test_stub.create_vm_with_iso_for_test(vm_offering.uuid,
                                               iso.image.uuid,
                                               root_volume_offering.uuid,
                                               'iso-vm')
    test_obj_dict.add_vm(vm)

    # check vm
    vm_inv = vm.get_vm()
    test_lib.lib_set_vm_host_l2_ip(vm_inv)
    test_lib.lib_wait_target_up(vm.get_vm().vmNics[0].ip, 22, 1800)

    # clone vm
    cloned_vm_name = ['cloned_vm']
    cloned_vm_obj = vm.clone(cloned_vm_name)[0]
    test_obj_dict.add_vm(cloned_vm_obj)

    # delete iso
    iso.delete()

    # vm ops test
    test_stub.vm_ops_test(cloned_vm_obj, "VM_TEST_RESIZE_RVOL")

    # expunge iso
    iso.expunge()

    #detach iso
    img_ops.detach_iso(vm.vm.uuid)

    # vm ops test
    test_stub.vm_ops_test(cloned_vm_obj, "VM_TEST_STATE")

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Cloned VM ops for BS Success')
def test():
    global image1
    global test_obj_dict

    #run condition
    allow_bs_list = [inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE, inventory.CEPH_BACKUP_STORAGE_TYPE]
    test_lib.skip_test_when_bs_type_not_in_list(allow_bs_list)

    hosts = res_ops.query_resource(res_ops.HOST)
    if len(hosts) <= 1:
        test_util.test_skip("skip for host_num is not satisfy condition host_num>1")
    bs_cond = res_ops.gen_query_conditions("status", '=', "Connected")
    bss = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE, bs_cond, None, fields=['uuid'])

    image_name1 = 'image1_a'
    image_option = test_util.ImageOption()
    image_option.set_format('qcow2')
    image_option.set_name(image_name1)
    #image_option.set_system_tags('qemuga')
    image_option.set_mediaType('RootVolumeTemplate')
    image_option.set_url(os.environ.get('imageUrl_s'))
    image_option.set_backup_storage_uuid_list([bss[0].uuid])
    image_option.set_timeout(3600*1000)

    image1 = zstack_image_header.ZstackTestImage()
    image1.set_creation_option(image_option)
    image1.add_root_volume_template()
    image1.check()

    #export image
    if bss[0].type in [inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE]:
        image1.export()

    image_name = os.environ.get('imageName_net')
    l3_name = os.environ.get('l3VlanNetworkName1')
    vm = test_stub.create_vm('test-vm', image_name, l3_name)
    test_obj_dict.add_vm(vm)

    # clone vm
    cloned_vm_name = ['cloned_vm']
    cloned_vm_obj = vm.clone(cloned_vm_name)[0]
    test_obj_dict.add_vm(cloned_vm_obj)

    # delete image
    image1.delete()

    # vm ops test
    test_stub.vm_ops_test(cloned_vm_obj, "VM_TEST_SNAPSHOT")

    # expunge image
    image1.expunge()

    # vm ops test
    test_stub.vm_ops_test(cloned_vm_obj, "VM_TEST_RESIZE_DVOL")

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Cloned VM ops for BS Success')
def test():
    global image1
    global test_obj_dict

    #run condition
    allow_bs_list = [inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE, inventory.CEPH_BACKUP_STORAGE_TYPE]
    test_lib.skip_test_when_bs_type_not_in_list(allow_bs_list)

    hosts = res_ops.query_resource(res_ops.HOST)
    if len(hosts) <= 1:
        test_util.test_skip("skip for host_num is not satisfy condition host_num>1")
    bs_cond = res_ops.gen_query_conditions("status", '=', "Connected")
    bss = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE, bs_cond, None, fields=['uuid'])

    image_name1 = 'image1_a'
    image_option = test_util.ImageOption()
    image_option.set_format('qcow2')
    image_option.set_name(image_name1)
    #image_option.set_system_tags('qemuga')
    image_option.set_mediaType('RootVolumeTemplate')
    image_option.set_url(os.environ.get('imageUrl_s'))
    image_option.set_backup_storage_uuid_list([bss[0].uuid])
    image_option.set_timeout(3600*1000)

    image1 = zstack_image_header.ZstackTestImage()
    image1.set_creation_option(image_option)
    image1.add_root_volume_template()
    image1.check()

    #export image
    if bss[0].type in [inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE]:
        image1.export()

    image_name = os.environ.get('imageName_net')
    l3_name = os.environ.get('l3VlanNetworkName1')
    vm = test_stub.create_vm('test-vm', image_name, l3_name)
    test_obj_dict.add_vm(vm)

    # clone vm
    cloned_vm_name = ['cloned_vm']
    cloned_vm_obj = vm.clone(cloned_vm_name)[0]
    test_obj_dict.add_vm(cloned_vm_obj)

    # delete image
    image1.delete()

    # vm ops test
    test_stub.vm_ops_test(cloned_vm_obj, "VM_TEST_STATE")

    # expunge image
    image1.expunge()

    # vm ops test
    test_stub.vm_ops_test(cloned_vm_obj, "VM_TEST_RESIZE_RVOL")

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Cloned VM ops for BS Success')
def test():
    global image1

    allow_bs_list = [
        inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE,
        inventory.CEPH_BACKUP_STORAGE_TYPE, inventory.SFTP_BACKUP_STORAGE_TYPE
    ]
    test_lib.skip_test_when_bs_type_not_in_list(allow_bs_list)

    allow_ps_list = [
        inventory.CEPH_PRIMARY_STORAGE_TYPE,
        inventory.NFS_PRIMARY_STORAGE_TYPE, 'SharedMountPoint'
    ]
    test_lib.skip_test_when_ps_type_not_in_list(allow_ps_list)

    hosts = res_ops.query_resource(res_ops.HOST)
    if len(hosts) <= 1:
        test_util.test_skip(
            "skip for host_num is not satisfy condition host_num>1")

    bs_cond = res_ops.gen_query_conditions("status", '=', "Connected")
    bss = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE,
                                        bs_cond,
                                        None,
                                        fields=['uuid'])

    image_name1 = 'image1_a'
    image_option = test_util.ImageOption()
    image_option.set_format('qcow2')
    image_option.set_name(image_name1)
    #image_option.set_system_tags('qemuga')
    image_option.set_mediaType('RootVolumeTemplate')
    image_option.set_url(os.environ.get('imageUrl_s'))
    image_option.set_backup_storage_uuid_list([bss[0].uuid])
    image_option.set_timeout(3600 * 1000)

    image1 = zstack_image_header.ZstackTestImage()
    image1.set_creation_option(image_option)
    image1.add_root_volume_template()
    image1.check()

    image_name = os.environ.get('imageName_net')
    l3_name = os.environ.get('l3VlanNetworkName1')
    vm1 = test_stub.create_vm(image_name1, image_name, l3_name)
    test_obj_dict.add_vm(vm1)

    image1.delete()
    image1.expunge()

    #target_host = test_lib.lib_find_random_host(vm1.vm)
    #vm1.migrate(target_host.uuid)
    test_stub.vm_ops_test(vm1, "VM_TEST_MIGRATE")

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Create VM Image in Image Store Success')
def test():
    global iso
    global test_obj_dict

    # run condition
    allow_bs_list = [inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE, inventory.CEPH_BACKUP_STORAGE_TYPE]
    test_lib.skip_test_when_bs_type_not_in_list(allow_bs_list)

    hosts = res_ops.query_resource(res_ops.HOST)
    if len(hosts) <= 1:
        test_util.test_skip("skip for host_num is not satisfy condition host_num>1")

    # add iso and create vm from iso
    iso = test_stub.add_test_minimal_iso('minimal_iso')
    test_obj_dict.add_image(iso)
    root_volume_offering = test_stub.add_test_root_volume_offering('root-disk-iso', 10737418240)
    test_obj_dict.add_disk_offering(root_volume_offering)
    vm_offering = test_stub.add_test_vm_offering(2, 1024*1024*1024, 'iso-vm-offering')
    test_obj_dict.add_instance_offering(vm_offering)
    vm = test_stub.create_vm_with_iso_for_test(vm_offering.uuid, iso.image.uuid, root_volume_offering.uuid, 'iso-vm')
    test_obj_dict.add_vm(vm)

    # check vm
    vm_inv = vm.get_vm()
    test_lib.lib_set_vm_host_l2_ip(vm_inv)
    test_lib.lib_wait_target_up(vm.get_vm().vmNics[0].ip, 22, 1800)

    # clone vm
    cloned_vm_name = ['cloned_vm']
    cloned_vm_obj = vm.clone(cloned_vm_name)[0]
    test_obj_dict.add_vm(cloned_vm_obj)

    # delete iso
    iso.delete()

    # vm ops test
    test_stub.vm_ops_test(cloned_vm_obj, "VM_TEST_RESIZE_RVOL")

    # expunge iso
    iso.expunge()

    #detach iso
    img_ops.detach_iso(vm.vm.uuid)

    # vm ops test
    test_stub.vm_ops_test(cloned_vm_obj, "VM_TEST_STATE")

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Cloned VM ops for BS Success')
コード例 #7
0
def test():

    test_lib.skip_test_when_bs_type_not_in_list([inventory.SFTP_BACKUP_STORAGE_TYPE])

    global test_obj_dict
    image_name = os.environ.get('imageName_s')
    l3_name = os.environ.get('l3VlanNetworkName1')
    vm_name='multihost_basic_vm'
    vm = test_stub.create_vm(vm_name,image_name,l3_name)
    test_obj_dict.add_vm(vm)

    volume = test_stub.create_volume()
    test_obj_dict.add_volume(volume)
    volume.attach(vm)

    bss = res_ops.query_resource_fields(res_ops.SFTP_BACKUP_STORAGE, fields=["uuid"])
    sftp_uuid_list = []
    for bs in bss:
        sftp_uuid_list.append(bs.uuid)
    volume_template = volume.create_template(sftp_uuid_list)
    test_obj_dict.add_image(volume_template)


    ps = res_ops.query_resource(res_ops.PRIMARY_STORAGE)[0]
    ps_uuid = ps.uuid
    host_uuid=None
    if ps.type == inventory.LOCAL_STORAGE_TYPE:
        host_uuid=test_lib.lib_get_local_storage_volume_host(volume.get_volume().uuid).uuid

    new_volume_01 = volume_template.create_data_volume(ps_uuid,"new volume 01",host_uuid)
    test_obj_dict.add_volume(new_volume_01)
    new_volume_02 = volume_template.create_data_volume(ps_uuid,"new volume 02",host_uuid)
    test_obj_dict.add_volume(new_volume_02)

    volume.detach()

    # test volume attach to vm with vm on
    new_volume_01.attach(vm)
    new_volume_01.detach()

    # test volume attach to vm with vm off
    vm.stop()
    new_volume_02.attach(vm)
    vm.start()
    new_volume_02.detach()

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Create volume from volume template in sftp bs and attach it to vm success')
def test():
    global image1

    allow_bs_list = [inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE, inventory.CEPH_BACKUP_STORAGE_TYPE, inventory.SFTP_BACKUP_STORAGE_TYPE]
    test_lib.skip_test_when_bs_type_not_in_list(allow_bs_list)

    allow_ps_list = [inventory.CEPH_PRIMARY_STORAGE_TYPE, inventory.NFS_PRIMARY_STORAGE_TYPE, 'SharedMountPoint']
    test_lib.skip_test_when_ps_type_not_in_list(allow_ps_list)

    hosts = res_ops.query_resource(res_ops.HOST)
    if len(hosts) <= 1:
        test_util.test_skip("skip for host_num is not satisfy condition host_num>1")

    bs_cond = res_ops.gen_query_conditions("status", '=', "Connected")
    bss = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE, bs_cond, None, fields=['uuid'])

    image_name1 = 'image1_a'
    image_option = test_util.ImageOption()
    image_option.set_format('qcow2')
    image_option.set_name(image_name1)
    #image_option.set_system_tags('qemuga')
    image_option.set_mediaType('RootVolumeTemplate')
    image_option.set_url(os.environ.get('imageUrl_s'))
    image_option.set_backup_storage_uuid_list([bss[0].uuid])
    image_option.set_timeout(3600*1000)

    image1 = zstack_image_header.ZstackTestImage()
    image1.set_creation_option(image_option)
    image1.add_root_volume_template()
    image1.check()

    image_name = os.environ.get('imageName_net')
    l3_name = os.environ.get('l3VlanNetworkName1')
    vm1 = test_stub.create_vm(image_name1, image_name, l3_name)
    test_obj_dict.add_vm(vm1)

    image1.delete()
    image1.expunge()

    #target_host = test_lib.lib_find_random_host(vm1.vm)
    #vm1.migrate(target_host.uuid)
    test_stub.vm_ops_test(vm1, "VM_TEST_MIGRATE")

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Create VM Image in Image Store Success')
コード例 #9
0
def test():
    global image
    global test_obj_dict
    allow_bs_list = [
        inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE,
        inventory.CEPH_BACKUP_STORAGE_TYPE, inventory.SFTP_BACKUP_STORAGE_TYPE
    ]
    test_lib.skip_test_when_bs_type_not_in_list(allow_bs_list)

    allow_ps_list = [
        inventory.CEPH_PRIMARY_STORAGE_TYPE,
        inventory.NFS_PRIMARY_STORAGE_TYPE, 'SharedMountPoint'
    ]
    test_lib.skip_test_when_ps_type_not_in_list(allow_ps_list)

    #run condition
    hosts = res_ops.query_resource(res_ops.HOST)
    if len(hosts) <= 1:
        test_util.test_skip(
            "skip for host_num is not satisfy condition host_num>1")

    bs_cond = res_ops.gen_query_conditions("status", '=', "Connected")
    bss = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE,
                                        bs_cond,
                                        None,
                                        fields=['uuid'])

    #create disk offering
    data_volume_size = 10737418240
    disk_offering_option = test_util.DiskOfferingOption()
    disk_offering_option.set_name('root-disk-iso')
    disk_offering_option.set_diskSize(data_volume_size)
    data_volume_offering = vol_ops.create_volume_offering(disk_offering_option)
    test_obj_dict.add_disk_offering(data_volume_offering)

    #create instance offering
    cpuNum = 2
    memorySize = 2147483648
    name = 'iso-vm-offering'
    new_offering_option = test_util.InstanceOfferingOption()
    new_offering_option.set_cpuNum(cpuNum)
    new_offering_option.set_memorySize(memorySize)
    new_offering_option.set_name(name)
    new_offering = vm_ops.create_instance_offering(new_offering_option)
    test_obj_dict.add_instance_offering(new_offering)

    #add iso
    img_option = test_util.ImageOption()
    img_option.set_name('iso1')
    bs_uuid = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE, [],
                                            None)[0].uuid
    img_option.set_backup_storage_uuid_list([bs_uuid])
    img_option.set_url(
        'http://172.20.1.15:7480/iso/CentOS-x86_64-7.2-Minimal.iso')
    image_inv = img_ops.add_iso_template(img_option)
    image_uuid = image_inv.uuid
    image = test_image.ZstackTestImage()
    image.set_image(image_inv)
    image.set_creation_option(img_option)
    test_obj_dict.add_image(image)

    #create vm by iso
    l3_name = os.environ.get('l3VlanNetworkName1')
    l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
    root_disk_uuid = data_volume_offering.uuid
    vm = test_stub.create_vm_with_iso([l3_net_uuid], image_uuid, 'iso-vm',
                                      root_disk_uuid, new_offering.uuid)
    host_ip = test_lib.lib_find_host_by_vm(vm.get_vm()).managementIp
    test_obj_dict.add_vm(vm)

    #check vm
    vm_inv = vm.get_vm()
    vm_ip = vm_inv.vmNics[0].ip

    #cmd ='[ -e /root ]'
    #ssh_timeout = test_lib.SSH_TIMEOUT
    #test_lib.SSH_TIMEOUT = 3600
    test_lib.lib_set_vm_host_l2_ip(vm_inv)
    test_lib.lib_wait_target_up(vm.get_vm().vmNics[0].ip, 22, 1800)
    #if not test_lib.lib_ssh_vm_cmd_by_agent_with_retry(host_ip, vm_ip, 'root', 'password', cmd):
    #    test_lib.SSH_TIMEOUT = ssh_timeout
    #    test_util.test_fail("iso has been failed to installed.")

    #test_lib.SSH_TIMEOUT = ssh_timeout

    #clone vm
    cloned_vm_name = ['cloned_vm_name']
    cloned_vm_obj = vm.clone(cloned_vm_name)[0]
    test_obj_dict.add_vm(cloned_vm_obj)

    #delete iso
    image.delete()
    test_obj_dict.rm_image(image)

    #vm ops test
    test_stub.vm_ops_test(cloned_vm_obj, "VM_TEST_ALL")

    #expunge iso
    image.expunge()

    #detach iso
    img_ops.detach_iso(vm.vm.uuid)

    #vm ops test
    test_stub.vm_ops_test(cloned_vm_obj, "VM_TEST_ALL")

    #create image by vm root volume
    cloned_vm_img_name = "cloned_vm_image1"
    img_option2 = test_util.ImageOption()
    img_option2.set_backup_storage_uuid_list([bs_uuid])
    img_option2.set_root_volume_uuid(cloned_vm_obj.vm.rootVolumeUuid)
    img_option2.set_name(cloned_vm_img_name)
    image1 = test_image.ZstackTestImage()
    image1.set_creation_option(img_option2)
    image1.create()
    image1.check()
    test_obj_dict.add_image(image1)

    #export image
    image1.export()

    #create vm
    vm2 = test_stub.create_vm('image-vm', cloned_vm_img_name, l3_name)

    #delete image
    image1.delete()
    test_obj_dict.rm_image(image1)

    #vm ops test
    test_stub.vm_ops_test(vm2, "VM_TEST_ALL")

    #expunge image
    image1.expunge()

    #vm ops test
    test_stub.vm_ops_test(vm2, "VM_TEST_ALL")

    vm.destroy()
    vm2.destroy()
    cloned_vm_obj.destroy()

    vol_ops.delete_disk_offering(root_disk_uuid)
    vm_ops.delete_instance_offering(new_offering.uuid)
    test_obj_dict.rm_vm(vm)
    test_obj_dict.rm_disk_offering(data_volume_offering)
    test_obj_dict.rm_instance_offering(new_offering)

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Create VM Image in Image Store Success')
コード例 #10
0
def test():
    #skip ceph in c74
    cmd = "cat /etc/redhat-release | grep '7.4'"
    mn_ip = res_ops.query_resource(res_ops.MANAGEMENT_NODE)[0].hostName
    rsp = test_lib.lib_execute_ssh_cmd(mn_ip, 'root', 'password', cmd, 180)
    if rsp != False:
        ps = res_ops.query_resource(res_ops.PRIMARY_STORAGE)
        for i in ps:
            if i.type == 'Ceph':
                test_util.test_skip('cannot hotplug iso to the vm in ceph,it is a libvirt bug:https://bugzilla.redhat.com/show_bug.cgi?id=1541702.')

    global image
    global test_obj_dict
    allow_bs_list = [inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE, inventory.CEPH_BACKUP_STORAGE_TYPE]
    test_lib.skip_test_when_bs_type_not_in_list(allow_bs_list)

    allow_ps_list = [inventory.CEPH_PRIMARY_STORAGE_TYPE, inventory.NFS_PRIMARY_STORAGE_TYPE, 'SharedMountPoint']
    test_lib.skip_test_when_ps_type_not_in_list(allow_ps_list)

    #run condition
    hosts = res_ops.query_resource(res_ops.HOST)
    if len(hosts) <= 1:
        test_util.test_skip("skip for host_num is not satisfy condition host_num>1")

    bs_cond = res_ops.gen_query_conditions("status", '=', "Connected")
    bss = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE, bs_cond, None, fields=['uuid'])

    #create disk offering
    data_volume_size = 10737418240
    disk_offering_option = test_util.DiskOfferingOption()
    disk_offering_option.set_name('root-disk-iso')
    disk_offering_option.set_diskSize(data_volume_size)
    data_volume_offering = vol_ops.create_volume_offering(disk_offering_option)
    test_obj_dict.add_disk_offering(data_volume_offering)

    #create instance offering
    cpuNum = 2
    memorySize = 1024*1024*1024
    name = 'iso-vm-offering'
    new_offering_option = test_util.InstanceOfferingOption()
    new_offering_option.set_cpuNum(cpuNum)
    new_offering_option.set_memorySize(memorySize)
    new_offering_option.set_name(name)
    new_offering = vm_ops.create_instance_offering(new_offering_option)
    test_obj_dict.add_instance_offering(new_offering)

    #add iso
    img_option = test_util.ImageOption()
    img_option.set_name('iso1')
    bs_uuid = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE, [], None)[0].uuid
    img_option.set_backup_storage_uuid_list([bs_uuid])
    img_option.set_url(os.environ.get('isoForVmUrl'))
    image_inv = img_ops.add_iso_template(img_option)
    image_uuid = image_inv.uuid
    image = test_image.ZstackTestImage()
    image.set_image(image_inv)
    image.set_creation_option(img_option)
    test_obj_dict.add_image(image)

    #create vm by iso
    l3_name = os.environ.get('l3VlanNetworkName1')
    l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
    root_disk_uuid = data_volume_offering.uuid
    vm = test_stub.create_vm_with_iso([l3_net_uuid], image_uuid, 'iso-vm', root_disk_uuid, new_offering.uuid)
    host_ip = test_lib.lib_find_host_by_vm(vm.get_vm()).managementIp
    test_obj_dict.add_vm(vm)
    
    #check vm
    vm_inv = vm.get_vm()
    vm_ip = vm_inv.vmNics[0].ip

    #cmd ='[ -e /root ]'
    #ssh_timeout = test_lib.SSH_TIMEOUT
    #test_lib.SSH_TIMEOUT = 3600
    test_lib.lib_set_vm_host_l2_ip(vm_inv)
    test_lib.lib_wait_target_up(vm.get_vm().vmNics[0].ip, 22, 1800)
    #if not test_lib.lib_ssh_vm_cmd_by_agent_with_retry(host_ip, vm_ip, 'root', 'password', cmd):
    #    test_lib.SSH_TIMEOUT = ssh_timeout
    #    test_util.test_fail("iso has been failed to installed.")

    #test_lib.SSH_TIMEOUT = ssh_timeout

    #clone vm
    cloned_vm_name = ['cloned_vm_name']
    cloned_vm_obj = vm.clone(cloned_vm_name)[0]
    test_obj_dict.add_vm(cloned_vm_obj)

    #delete iso
    image.delete()
    test_obj_dict.rm_image(image)

    #vm ops test
    test_stub.vm_ops_test(cloned_vm_obj, "VM_TEST_ALL")

    #expunge iso
    image.expunge()

    #detach iso
    img_ops.detach_iso(vm.vm.uuid)

    #vm ops test
    test_stub.vm_ops_test(cloned_vm_obj, "VM_TEST_ALL")

    #create image by vm root volume
    cloned_vm_img_name = "cloned_vm_image1"
    img_option2 = test_util.ImageOption()
    img_option2.set_backup_storage_uuid_list([bs_uuid])
    img_option2.set_root_volume_uuid(cloned_vm_obj.vm.rootVolumeUuid)
    img_option2.set_name(cloned_vm_img_name)
    image1 = test_image.ZstackTestImage()
    image1.set_creation_option(img_option2)
    image1.create()
    image1.check()
    test_obj_dict.add_image(image1)

    bs_list = res_ops.query_resource(res_ops.BACKUP_STORAGE)
    if inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE == bs_list[0] and len(bs_list) == 1 :
        #export image
        image1.export()

    #create vm 
    vm2 = test_stub.create_vm('image-vm', cloned_vm_img_name, l3_name)

    #delete image
    image1.delete()
    test_obj_dict.rm_image(image1)

    #vm ops test
    test_stub.vm_ops_test(vm2, "VM_TEST_ALL")

    #expunge image
    image1.expunge()

    #vm ops test
    test_stub.vm_ops_test(vm2, "VM_TEST_ALL")

    vm.destroy()
    vm2.destroy()
    cloned_vm_obj.destroy()

    vol_ops.delete_disk_offering(root_disk_uuid)
    vm_ops.delete_instance_offering(new_offering.uuid)
    test_obj_dict.rm_vm(vm)
    test_obj_dict.rm_disk_offering(data_volume_offering)
    test_obj_dict.rm_instance_offering(new_offering)

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Create VM Image in Image Store Success')
def test():
    global image
    global test_obj_dict
    allow_bs_list = [inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE, inventory.CEPH_BACKUP_STORAGE_TYPE, inventory.SFTP_BACKUP_STORAGE_TYPE]
    test_lib.skip_test_when_bs_type_not_in_list(allow_bs_list)

    allow_ps_list = [inventory.CEPH_PRIMARY_STORAGE_TYPE, inventory.NFS_PRIMARY_STORAGE_TYPE, 'SharedMountPoint']
    test_lib.skip_test_when_ps_type_not_in_list(allow_ps_list)

    #run condition
    hosts = res_ops.query_resource(res_ops.HOST)
    if len(hosts) <= 1:
        test_util.test_skip("skip for host_num is not satisfy condition host_num>1")

    bs_cond = res_ops.gen_query_conditions("status", '=', "Connected")
    bss = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE, bs_cond, None, fields=['uuid'])

    #create disk offering
    data_volume_size = 10737418240
    disk_offering_option = test_util.DiskOfferingOption()
    disk_offering_option.set_name('root-disk-iso')
    disk_offering_option.set_diskSize(data_volume_size)
    data_volume_offering = vol_ops.create_volume_offering(disk_offering_option)
    test_obj_dict.add_disk_offering(data_volume_offering)

    #create instance offering
    cpuNum = 2
    memorySize = 1024*1024*1024
    name = 'iso-vm-offering'
    new_offering_option = test_util.InstanceOfferingOption()
    new_offering_option.set_cpuNum(cpuNum)
    new_offering_option.set_memorySize(memorySize)
    new_offering_option.set_name(name)
    new_offering = vm_ops.create_instance_offering(new_offering_option)
    test_obj_dict.add_instance_offering(new_offering)

    #add iso
    img_option = test_util.ImageOption()
    img_option.set_name('iso1')
    bs_uuid = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE, [], None)[0].uuid
    img_option.set_backup_storage_uuid_list([bs_uuid])
    img_option.set_url(os.environ.get('isoForVmUrl'))
    image_inv = img_ops.add_iso_template(img_option)
    image_uuid = image_inv.uuid
    image = test_image.ZstackTestImage()
    image.set_image(image_inv)
    image.set_creation_option(img_option)
    test_obj_dict.add_image(image)

    #create vm by iso
    l3_name = os.environ.get('l3VlanNetworkName1')
    l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
    root_disk_uuid = data_volume_offering.uuid
    vm = test_stub.create_vm_with_iso([l3_net_uuid], image_uuid, 'iso-vm', root_disk_uuid, new_offering.uuid)
    host_ip = test_lib.lib_find_host_by_vm(vm.get_vm()).managementIp
    test_obj_dict.add_vm(vm)
    
    #check vm
    vm_inv = vm.get_vm()
    vm_ip = vm_inv.vmNics[0].ip

    #cmd ='[ -e /root ]'
    #ssh_timeout = test_lib.SSH_TIMEOUT
    #test_lib.SSH_TIMEOUT = 3600
    test_lib.lib_set_vm_host_l2_ip(vm_inv)
    test_lib.lib_wait_target_up(vm.get_vm().vmNics[0].ip, 22, 1800)
    #if not test_lib.lib_ssh_vm_cmd_by_agent_with_retry(host_ip, vm_ip, 'root', 'password', cmd):
    #    test_lib.SSH_TIMEOUT = ssh_timeout
    #    test_util.test_fail("iso has been failed to installed.")

    #test_lib.SSH_TIMEOUT = ssh_timeout

    #delete iso
    image.delete()
    test_obj_dict.rm_image(image)

    #vm ops test
    test_stub.vm_ops_test(vm, "VM_TEST_ALL")

    #expunge iso
    image.expunge()

    #detach iso
    img_ops.detach_iso(vm.vm.uuid)

    #vm ops test
    test_stub.vm_ops_test(vm, "VM_TEST_MIGRATE")

    vm.destroy()
    vol_ops.delete_disk_offering(root_disk_uuid)
    vm_ops.delete_instance_offering(new_offering.uuid)
    test_obj_dict.rm_vm(vm)
    test_obj_dict.rm_disk_offering(data_volume_offering)
    test_obj_dict.rm_instance_offering(new_offering)

    test_lib.lib_robot_cleanup(test_obj_dict)
    test_util.test_pass('Create VM Image in Image Store Success')