def create_image(vm_obj, dvol): volume_uuid = dvol.volume.uuid bs_list = test_lib.lib_get_backup_storage_list_by_vm(vm_obj.vm) image_option = test_util.ImageOption() image_option.set_data_volume_uuid(volume_uuid) image_option.set_name('image_resize_template') image_option.set_backup_storage_uuid_list([bs_list[0].uuid]) image = img_ops.create_data_volume_template(image_option) new_image = zstack_image_header.ZstackTestImage() new_image.set_creation_option(image_option) new_image.set_image(image) new_image.check() new_image.delete() new_image.expunge()
def create(self, apiid=None, root=True): ''' Create image template from Root Volume using CreateRootVolumeTemplateFromRootVolume ''' if test_lib.lib_check_version_is_mevoco_1_8(): if test_lib.lib_check_version_is_mevoco(): self.image = img_ops.commit_volume_as_image_apiid(self.image_creation_option, apiid) else: self.image = img_ops.create_root_volume_template_apiid(self.image_creation_option, apiid) else: if root: self.image = img_ops.create_root_volume_template_apiid(self.image_creation_option, apiid) else: self.image = img_ops.create_data_volume_template(self.image_creation_option) super(ZstackTestImage, self).create()
def test(): global test_obj_dict volume_creation_option = test_util.VolumeOption() test_util.test_dsc('Create volume and check') disk_offering = test_lib.lib_get_disk_offering_by_name( os.environ.get('smallDiskOfferingName')) volume_creation_option.set_disk_offering_uuid(disk_offering.uuid) volume = test_stub.create_volume(volume_creation_option) test_obj_dict.add_volume(volume) volume.check() volume_uuid = volume.volume.uuid vol_size = volume.volume.size image_name = os.environ.get('imageName_net') l3_name = os.environ.get('l3VlanNetworkName1') vm = test_stub.create_vm("test_resize_vm", image_name, l3_name) vm.check() test_obj_dict.add_vm(vm) volume.attach(vm) vm.stop() vm.check() set_size = 1024 * 1024 * 1024 * 5 vol_ops.resize_data_volume(volume_uuid, set_size) vm.update() vol_size_after = test_lib.lib_get_data_volumes(vm.get_vm())[0].size if set_size != vol_size_after: test_util.test_fail('Resize Data Volume failed, size = %s' % vol_size_after) bs_list = test_lib.lib_get_backup_storage_list_by_vm(vm.vm) image_option = test_util.ImageOption() image_option.set_data_volume_uuid(volume_uuid) image_option.set_name('data_resize_template') image_option.set_backup_storage_uuid_list([bs_list[0].uuid]) data_image = img_ops.create_data_volume_template(image_option) target_host = test_lib.lib_find_random_host(vm.get_vm()) new_data = vol_ops.create_volume_from_template( data_image.uuid, volume.volume.primaryStorageUuid, host_uuid=target_host.uuid) if set_size != new_data.size: test_util.test_fail('Resize Data Volume failed, size = %s' % new_data.size) test_lib.lib_error_cleanup(test_obj_dict) test_util.test_pass('Resize Data Volume Test Success')
def test(): global test_obj_dict volume_creation_option = test_util.VolumeOption() test_util.test_dsc('Create volume and check') disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('smallDiskOfferingName')) volume_creation_option.set_disk_offering_uuid(disk_offering.uuid) volume = test_stub.create_volume(volume_creation_option) test_obj_dict.add_volume(volume) volume.check() volume_uuid = volume.volume.uuid vol_size = volume.volume.size image_name = os.environ.get('imageName_net') l3_name = os.environ.get('l3VlanNetworkName1') vm = test_stub.create_vm("test_resize_vm", image_name, l3_name) vm.check() test_obj_dict.add_vm(vm) volume.attach(vm) vm.stop() vm.check() set_size = 1024*1024*1024*5 vol_ops.resize_data_volume(volume_uuid, set_size) vm.update() vol_size_after = test_lib.lib_get_data_volumes(vm.get_vm())[0].size if set_size != vol_size_after: test_util.test_fail('Resize Data Volume failed, size = %s' % vol_size_after) bs_list = test_lib.lib_get_backup_storage_list_by_vm(vm.vm) image_option = test_util.ImageOption() image_option.set_data_volume_uuid(volume_uuid) image_option.set_name('data_resize_template') image_option.set_backup_storage_uuid_list([bs_list[0].uuid]) data_image = img_ops.create_data_volume_template(image_option) target_host = test_lib.lib_find_random_host(vm.get_vm()) new_data = vol_ops.create_volume_from_template(data_image.uuid, volume.volume.primaryStorageUuid, host_uuid = target_host.uuid) if set_size != new_data.size: test_util.test_fail('Resize Data Volume failed, size = %s' % new_data.size) test_lib.lib_error_cleanup(test_obj_dict) test_util.test_pass('Resize Data Volume Test Success')
def test(): global test_obj_dict volume_creation_option = test_util.VolumeOption() ps_uuid = res_ops.query_resource(res_ops.PRIMARY_STORAGE, [])[0].uuid test_util.test_dsc('Create volume and check') disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('smallDiskOfferingName')) volume_creation_option.set_disk_offering_uuid(disk_offering.uuid) volume_creation_option.set_primary_storage_uuid(ps_uuid) if res_ops.query_resource(res_ops.PRIMARY_STORAGE, [])[0].type == "LocalStorage": host = test_lib.lib_find_random_host() volume_creation_option.set_system_tags(["localStorage::hostUuid::%s" % host.uuid]) volume = test_stub.create_volume(volume_creation_option) test_obj_dict.add_volume(volume) volume.check() volume_uuid = volume.volume.uuid vol_size = volume.volume.size set_size = 1024*1024*1024*5 vol_ops.resize_data_volume(volume_uuid, set_size) cond = res_ops.gen_query_conditions('type', '=', "Data") cond = res_ops.gen_query_conditions('status', '=', "Ready", cond) vol_size_after = res_ops.query_resource(res_ops.VOLUME, cond)[0].size if set_size != vol_size_after: test_util.test_fail('Resize Data Volume failed, size = %s' % vol_size_after) bs_uuid = res_ops.query_resource(res_ops.BACKUP_STORAGE, [])[0].uuid image_option = test_util.ImageOption() image_option.set_data_volume_uuid(volume_uuid) image_option.set_name('data_resize_template') image_option.set_backup_storage_uuid_list([bs_uuid]) data_image = img_ops.create_data_volume_template(image_option) if res_ops.query_resource(res_ops.PRIMARY_STORAGE, [])[0].type == "LocalStorage": new_data = vol_ops.create_volume_from_template(data_image.uuid, volume.volume.primaryStorageUuid, host_uuid = host.uuid) else: new_data = vol_ops.create_volume_from_template(data_image.uuid, volume.volume.primaryStorageUuid) if set_size != new_data.size: test_util.test_fail('Resize Data Volume failed, size = %s' % new_data.size) test_lib.lib_error_cleanup(test_obj_dict) test_util.test_pass('Resize Data Volume Test Success')
def test(): global disaster_bs_uuid global data_volume_uuid global image_uuid disasterBsUrls = os.environ.get('disasterBsUrls') name = 'disaster_bs' description = 'backup storage for disaster' url = '/zstack_bs' sshport = 22 hostname = disasterBsUrls.split('@')[1] username = disasterBsUrls.split(':')[0] password = disasterBsUrls.split('@')[0].split(':')[1] test_util.test_logger( 'Disaster bs server hostname is %s, username is %s, password is %s' % (hostname, username, password)) #AddDisasterImageStoreBackupStorage disaster_backup_storage = bs_ops.add_disaster_image_store_bs( url, hostname, username, password, sshport, name, description) disaster_bs_uuid = disaster_backup_storage.uuid #AttachBackupStorageToZone zone_uuid = res_ops.query_resource(res_ops.ZONE)[0].uuid bs_ops.attach_backup_storage(disaster_bs_uuid, zone_uuid) #Create data volume cond = res_ops.gen_query_conditions( 'name', '=', os.environ.get('nfsPrimaryStorageName')) primary_storage_uuid = res_ops.query_resource(res_ops.PRIMARY_STORAGE, cond)[0].uuid disk_offering_uuid = res_ops.query_resource(res_ops.DISK_OFFERING)[0].uuid cond = res_ops.gen_query_conditions( 'name', '=', os.environ.get('imageStoreBackupStorageName')) local_bs_uuid = res_ops.query_resource(res_ops.BACKUP_STORAGE, cond)[0].uuid volume_option = test_util.VolumeOption() volume_option.set_disk_offering_uuid(disk_offering_uuid) volume_option.set_name('data_volume_for_data_protect_test') volume_option.set_primary_storage_uuid(primary_storage_uuid) data_volume = vol_ops.create_volume_from_offering(volume_option) #CreateDataVolumeTemplateFromVolume data_volume_uuid = data_volume.uuid image_option = test_util.ImageOption() image_option.set_data_volume_uuid(data_volume_uuid) image_option.set_name('create_data_iso_to_image_store') image_option.set_backup_storage_uuid_list([disaster_bs_uuid]) image = img_ops.create_data_volume_template(image_option) disaster_bs_image_uuid = image.uuid #Check if the image's media_type correct cond = res_ops.gen_query_conditions('uuid', '=', disaster_bs_image_uuid) media_type = res_ops.query_resource(res_ops.IMAGE, cond)[0].mediaType if media_type != 'DataVolumeTemplate': test_util.test_fail( 'Wrong image media type, the expect is "DataVolumeTemplate", the real is "%s"' % media_type) #Check if create data volume with volume template success cond = res_ops.gen_query_conditions( 'name', '=', os.environ.get('nfsPrimaryStorageName')) ps_uuid = res_ops.query_resource(res_ops.PRIMARY_STORAGE, cond)[0].uuid new_volume = vol_ops.create_volume_from_template(disaster_bs_image_uuid, ps_uuid) vol_ops.delete_volume(new_volume.uuid) #Check if the system tag of the image in disaster bs is 'remote' cond = res_ops.gen_query_conditions('resourceUuid', '=', disaster_bs_image_uuid) system_tag = res_ops.query_resource(res_ops.SYSTEM_TAG, cond)[0] if system_tag.tag != "remote": test_util.test_fail( "Here isn't 'remote' system tag for image in data protect bs") #Check recovery data volume recovery_image = img_ops.recovery_image_from_image_store_backup_storage( local_bs_uuid, disaster_bs_uuid, disaster_bs_image_uuid) #Check the process status when recoverying image cond = res_ops.gen_query_conditions('resourceUuid', '=', local_bs_uuid) system_tag = res_ops.query_resource(res_ops.SYSTEM_TAG, cond)[0].tag status = system_tag.split('::')[7] if status not in ['running', 'success']: test_util.test_fail('Error status for recovery image, status: %s' % status) #Check if recovery data volume success if recovery_image.backupStorageRefs[0].backupStorageUuid != local_bs_uuid: test_util.test_fail('Recovery image failed, image uuid is %s' % recovery_image.uuid) if recovery_image.mediaType != 'DataVolumeTemplate': test_util.test_fail( 'Wrong image media type after recovery, the expect is "DataVolumeTemplate", the real is "%s"' % media_type) image_uuid = recovery_image.uuid try: #Try to recovery the same image again, it's negative test recovery_image = img_ops.recovery_image_from_image_store_backup_storage( local_bs_uuid, disaster_bs_uuid, disaster_bs_image_uuid) except Exception, e: if unicode(e).encode("utf-8").find('包含') != -1: test_util.test_pass( 'Try to recovery the same image again and get the error info expectly: %s' % unicode(e).encode("utf-8"))
def test(): global image1 global test_obj_dict #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']) 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() test_obj_dict.add_image(image1) 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) #create data volume disk_offering = test_lib.lib_get_disk_offering_by_name( os.environ.get('smallDiskOfferingName')) volume_creation_option = test_util.VolumeOption() volume_creation_option.set_name('volume1') volume_creation_option.set_disk_offering_uuid(disk_offering.uuid) volume = test_stub.create_volume(volume_creation_option) test_obj_dict.add_volume(volume) volume.check() volume.attach(vm1) volume.detach() # dvol ops test test_stub.dvol_ops_test(volume.volume, vm1, "DVOL_TEST_ALL") volume.attach(vm1) #create data volume from template image_option2 = test_util.ImageOption() image_option2.set_data_volume_uuid(volume.volume.uuid) image_option2.set_name('data_template') image_option2.set_backup_storage_uuid_list([bss[0].uuid]) vol_image = img_ops.create_data_volume_template(image_option2) #export vol template if bss[0].type in [inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE]: img_ops.export_image_from_backup_storage(vol_image.uuid, bss[0].uuid) target_host = test_lib.lib_find_host_by_vm(vm1.vm) volume2 = vol_ops.create_volume_from_template( vol_image.uuid, volume.volume.primaryStorageUuid, host_uuid=target_host.uuid) #del data volume template img_ops.delete_image(vol_image.uuid) # dvol ops test test_stub.dvol_ops_test(volume2, vm1, "DVOL_TEST_ALL") #expunge data volume template img_ops.expunge_image(vol_image.uuid) # dvol ops test test_stub.dvol_ops_test(volume2, vm1, "DVOL_TEST_ALL") test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('deleting and expunge vol image check vol ops Success')
def test(): global image1 global test_obj_dict #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") cond = res_ops.gen_query_conditions("status", '=', "Connected") ps = res_ops.query_resource_fields(res_ops.PRIMARY_STORAGE, cond, None, fields=['uuid']) bss = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE, cond, None, fields=['uuid']) # 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, 2147483648, '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) #add data volume template template_option = test_util.ImageOption() template_option.set_name('data-volume-template') template_option.set_backup_storage_uuid_list([bss[0].uuid]) template_option.set_format('qcow2') template_option.set_url('http://192.168.200.100/mirror/diskimages/data_volume_image_chunli_200M-4M.qcow2') template_inv = img_ops.add_data_volume_template(template_option) template = test_image.ZstackTestImage() template.set_image(template_inv) template.set_creation_option(template_option) test_obj_dict.add_image(template) #export vol template if bss[0].type in [inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE]: img_ops.export_image_from_backup_storage(template.image.uuid, bss[0].uuid) #create data volume from template target_host = test_lib.lib_find_host_by_vm(vm.vm) volume = vol_ops.create_volume_from_template(template.image.uuid, ps[0].uuid, host_uuid=target_host.uuid) # create template from data volume template_option2 = test_util.ImageOption() template_option2.set_data_volume_uuid(volume.uuid) template_option2.set_name('data-template-from-vol') template_option2.set_backup_storage_uuid_list([bss[0].uuid]) template2 = img_ops.create_data_volume_template(template_option2) #export vol template if bss[0].type in [inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE]: img_ops.export_image_from_backup_storage(template2.uuid, bss[0].uuid) volume2 = vol_ops.create_volume_from_template(template2.uuid, volume.primaryStorageUuid, host_uuid = target_host.uuid) #del data volume template img_ops.delete_image(template2.uuid) # dvol ops test test_stub.dvol_ops_test(volume2, vm, "DVOL_TEST_ALL") #expunge data volume template img_ops.expunge_image(template2.uuid) # dvol ops test test_stub.dvol_ops_test(volume2, vm, "DVOL_TEST_ALL") test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('deleting and expunge vol image check vol ops Success')
def test(): global image1 global test_obj_dict #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") cond = res_ops.gen_query_conditions("status", '=', "Connected") ps = res_ops.query_resource_fields(res_ops.PRIMARY_STORAGE, cond, None, fields=['uuid']) bss = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE, cond, None, fields=['uuid']) # 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) #add data volume template template_option = test_util.ImageOption() template_option.set_name('data-volume-template') template_option.set_backup_storage_uuid_list([bss[0].uuid]) template_option.set_format('qcow2') template_option.set_url(os.environ.get('data_vol_qcow2')) template_inv = img_ops.add_data_volume_template(template_option) template = test_image.ZstackTestImage() template.set_image(template_inv) template.set_creation_option(template_option) test_obj_dict.add_image(template) #export vol template if bss[0].type in [inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE]: img_ops.export_image_from_backup_storage(template.image.uuid, bss[0].uuid) #create data volume from template target_host = test_lib.lib_find_host_by_vm(vm.vm) volume = vol_ops.create_volume_from_template(template.image.uuid, ps[0].uuid, host_uuid=target_host.uuid) # create template from data volume template_option2 = test_util.ImageOption() template_option2.set_data_volume_uuid(volume.uuid) template_option2.set_name('data-template-from-vol') template_option2.set_backup_storage_uuid_list([bss[0].uuid]) template2 = img_ops.create_data_volume_template(template_option2) #export vol template if bss[0].type in [inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE]: img_ops.export_image_from_backup_storage(template2.uuid, bss[0].uuid) volume2 = vol_ops.create_volume_from_template(template2.uuid, volume.primaryStorageUuid, host_uuid = target_host.uuid) #del data volume template img_ops.delete_image(template2.uuid) # dvol ops test test_stub.dvol_ops_test(volume2, vm, "DVOL_TEST_ALL") #expunge data volume template img_ops.expunge_image(template2.uuid) # dvol ops test test_stub.dvol_ops_test(volume2, vm, "DVOL_TEST_ALL") test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('deleting and expunge vol image check vol ops Success')
def test(): global disaster_bs_uuid global data_volume_uuid global image_uuid disasterBsUrls = os.environ.get('disasterBsUrls') name = 'disaster_bs' description = 'backup storage for disaster' url = '/zstack_bs' sshport = 22 hostname = disasterBsUrls.split('@')[1] username = disasterBsUrls.split(':')[0] password = disasterBsUrls.split('@')[0].split(':')[1] test_util.test_logger('Disaster bs server hostname is %s, username is %s, password is %s' %(hostname, username, password)) #AddDisasterImageStoreBackupStorage disaster_backup_storage = bs_ops.add_disaster_image_store_bs(url, hostname, username, password, sshport, name, description) disaster_bs_uuid = disaster_backup_storage.uuid #AttachBackupStorageToZone zone_uuid = res_ops.query_resource(res_ops.ZONE)[0].uuid bs_ops.attach_backup_storage(disaster_bs_uuid, zone_uuid) #Create data volume cond = res_ops.gen_query_conditions('name', '=', os.environ.get('nfsPrimaryStorageName')) primary_storage_uuid = res_ops.query_resource(res_ops.PRIMARY_STORAGE, cond)[0].uuid disk_offering_uuid = res_ops.query_resource(res_ops.DISK_OFFERING)[0].uuid cond = res_ops.gen_query_conditions('name', '=', os.environ.get('imageStoreBackupStorageName')) local_bs_uuid = res_ops.query_resource(res_ops.BACKUP_STORAGE, cond)[0].uuid volume_option = test_util.VolumeOption() volume_option.set_disk_offering_uuid(disk_offering_uuid) volume_option.set_name('data_volume_for_data_protect_test') volume_option.set_primary_storage_uuid(primary_storage_uuid) data_volume = vol_ops.create_volume_from_offering(volume_option) #CreateDataVolumeTemplateFromVolume data_volume_uuid = data_volume.uuid image_option = test_util.ImageOption() image_option.set_data_volume_uuid(data_volume_uuid) image_option.set_name('create_data_iso_to_image_store') image_option.set_backup_storage_uuid_list([disaster_bs_uuid]) image = img_ops.create_data_volume_template(image_option) disaster_bs_image_uuid = image.uuid #Check if the image's media_type correct cond = res_ops.gen_query_conditions('uuid', '=', disaster_bs_image_uuid) media_type = res_ops.query_resource(res_ops.IMAGE, cond)[0].mediaType if media_type != 'DataVolumeTemplate': test_util.test_fail('Wrong image media type, the expect is "DataVolumeTemplate", the real is "%s"' %media_type) #Check if create data volume with volume template success cond = res_ops.gen_query_conditions('name', '=', os.environ.get('nfsPrimaryStorageName')) ps_uuid = res_ops.query_resource(res_ops.PRIMARY_STORAGE, cond)[0].uuid new_volume = vol_ops.create_volume_from_template(disaster_bs_image_uuid, ps_uuid) vol_ops.delete_volume(new_volume.uuid) #Check if the system tag of the image in disaster bs is 'remote' cond = res_ops.gen_query_conditions('resourceUuid', '=', disaster_bs_image_uuid) system_tag = res_ops.query_resource(res_ops.SYSTEM_TAG, cond)[0] if system_tag.tag != "remote": test_util.test_fail("Here isn't 'remote' system tag for image in data protect bs") #Check recovery data volume recovery_image = img_ops.recovery_image_from_image_store_backup_storage(local_bs_uuid, disaster_bs_uuid, disaster_bs_image_uuid) #Check the process status when recoverying image cond = res_ops.gen_query_conditions('resourceUuid', '=', local_bs_uuid) system_tag = res_ops.query_resource(res_ops.SYSTEM_TAG, cond)[0].tag status = system_tag.split('::')[7] if status not in ['running', 'success']: test_util.test_fail('Error status for recovery image, status: %s' %status) #Check if recovery data volume success if recovery_image.backupStorageRefs[0].backupStorageUuid != local_bs_uuid: test_util.test_fail('Recovery image failed, image uuid is %s' %recovery_image.uuid) if recovery_image.mediaType != 'DataVolumeTemplate': test_util.test_fail('Wrong image media type after recovery, the expect is "DataVolumeTemplate", the real is "%s"' %media_type) image_uuid = recovery_image.uuid try: #Try to recovery the same image again, it's negative test recovery_image = img_ops.recovery_image_from_image_store_backup_storage(local_bs_uuid, disaster_bs_uuid, disaster_bs_image_uuid) except Exception,e: if unicode(e).encode("utf-8").find('包含') != -1: test_util.test_pass('Try to recovery the same image again and get the error info expectly: %s' %unicode(e).encode("utf-8"))
def test(): global image1 global test_obj_dict #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']) 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() test_obj_dict.add_image(image1) 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) #create data volume disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('smallDiskOfferingName')) volume_creation_option = test_util.VolumeOption() volume_creation_option.set_name('volume1') volume_creation_option.set_disk_offering_uuid(disk_offering.uuid) volume = test_stub.create_volume(volume_creation_option) test_obj_dict.add_volume(volume) volume.check() volume.attach(vm1) volume.detach() # dvol ops test test_stub.dvol_ops_test(volume.volume, vm1, "DVOL_TEST_ALL") volume.attach(vm1) #create data volume from template image_option2 = test_util.ImageOption() image_option2.set_data_volume_uuid(volume.volume.uuid) image_option2.set_name('data_template') image_option2.set_backup_storage_uuid_list([bss[0].uuid]) vol_image = img_ops.create_data_volume_template(image_option2) #export vol template if bss[0].type in [inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE]: img_ops.export_image_from_backup_storage(vol_image.uuid, bss[0].uuid) target_host = test_lib.lib_find_host_by_vm(vm1.vm) volume2 = vol_ops.create_volume_from_template(vol_image.uuid, volume.volume.primaryStorageUuid, host_uuid = target_host.uuid) #del data volume template img_ops.delete_image(vol_image.uuid) # dvol ops test test_stub.dvol_ops_test(volume2, vm1, "DVOL_TEST_ALL") #expunge data volume template img_ops.expunge_image(vol_image.uuid) # dvol ops test test_stub.dvol_ops_test(volume2, vm1, "DVOL_TEST_ALL") test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('deleting and expunge vol image check vol ops Success')