Search in sources :

Example 1 with MigrationOptions

use of com.cloud.storage.MigrationOptions in project cloudstack by apache.

the class StorageSystemDataMotionStrategy method createLinkedCloneMigrationOptions.

/**
 * Return expected MigrationOptions for a linked clone volume live storage migration
 */
protected MigrationOptions createLinkedCloneMigrationOptions(VolumeInfo srcVolumeInfo, VolumeInfo destVolumeInfo, String srcVolumeBackingFile, String srcPoolUuid, Storage.StoragePoolType srcPoolType) {
    VMTemplateStoragePoolVO ref = templatePoolDao.findByPoolTemplate(destVolumeInfo.getPoolId(), srcVolumeInfo.getTemplateId(), null);
    boolean updateBackingFileReference = ref == null;
    String backingFile = ref != null ? ref.getInstallPath() : srcVolumeBackingFile;
    return new MigrationOptions(srcPoolUuid, srcPoolType, backingFile, updateBackingFileReference);
}
Also used : VMTemplateStoragePoolVO(com.cloud.storage.VMTemplateStoragePoolVO) MigrationOptions(com.cloud.storage.MigrationOptions)

Example 2 with MigrationOptions

use of com.cloud.storage.MigrationOptions in project cloudstack by apache.

the class StorageSystemDataMotionStrategy method setVolumeMigrationOptions.

/**
 * Prepare hosts for KVM live storage migration depending on volume type by setting MigrationOptions on destination volume:
 * - Linked clones (backing file on disk): Decide if template (backing file) should be copied to destination storage prior disk creation
 * - Full clones (no backing file): Take snapshot of the VM prior disk creation
 * Return this information
 */
protected void setVolumeMigrationOptions(VolumeInfo srcVolumeInfo, VolumeInfo destVolumeInfo, VirtualMachineTO vmTO, Host srcHost, StoragePoolVO destStoragePool) {
    if (!destStoragePool.isManaged()) {
        String srcVolumeBackingFile = getVolumeBackingFile(srcVolumeInfo);
        String srcPoolUuid = srcVolumeInfo.getDataStore().getUuid();
        StoragePoolVO srcPool = _storagePoolDao.findById(srcVolumeInfo.getPoolId());
        Storage.StoragePoolType srcPoolType = srcPool.getPoolType();
        MigrationOptions migrationOptions;
        if (StringUtils.isNotBlank(srcVolumeBackingFile)) {
            migrationOptions = createLinkedCloneMigrationOptions(srcVolumeInfo, destVolumeInfo, srcVolumeBackingFile, srcPoolUuid, srcPoolType);
        } else {
            migrationOptions = createFullCloneMigrationOptions(srcVolumeInfo, vmTO, srcHost, srcPoolUuid, srcPoolType);
        }
        migrationOptions.setTimeout(StorageManager.KvmStorageOnlineMigrationWait.value());
        destVolumeInfo.setMigrationOptions(migrationOptions);
    }
}
Also used : Storage(com.cloud.storage.Storage) VMTemplateStoragePoolVO(com.cloud.storage.VMTemplateStoragePoolVO) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) StoragePoolType(com.cloud.storage.Storage.StoragePoolType) MigrationOptions(com.cloud.storage.MigrationOptions)

Example 3 with MigrationOptions

use of com.cloud.storage.MigrationOptions in project cloudstack by apache.

the class KVMStorageProcessor method createVolume.

@Override
public Answer createVolume(final CreateObjectCommand cmd) {
    final VolumeObjectTO volume = (VolumeObjectTO) cmd.getData();
    final PrimaryDataStoreTO primaryStore = (PrimaryDataStoreTO) volume.getDataStore();
    KVMStoragePool primaryPool = null;
    KVMPhysicalDisk vol = null;
    long disksize;
    try {
        primaryPool = storagePoolMgr.getStoragePool(primaryStore.getPoolType(), primaryStore.getUuid());
        disksize = volume.getSize();
        PhysicalDiskFormat format;
        if (volume.getFormat() == null || StoragePoolType.RBD.equals(primaryStore.getPoolType())) {
            format = primaryPool.getDefaultFormat();
        } else {
            format = PhysicalDiskFormat.valueOf(volume.getFormat().toString().toUpperCase());
        }
        MigrationOptions migrationOptions = volume.getMigrationOptions();
        if (migrationOptions != null) {
            String srcStoreUuid = migrationOptions.getSrcPoolUuid();
            StoragePoolType srcPoolType = migrationOptions.getSrcPoolType();
            KVMStoragePool srcPool = storagePoolMgr.getStoragePool(srcPoolType, srcStoreUuid);
            int timeout = migrationOptions.getTimeout();
            if (migrationOptions.getType() == MigrationOptions.Type.LinkedClone) {
                vol = createLinkedCloneVolume(migrationOptions, srcPool, primaryPool, volume, format, timeout);
            } else if (migrationOptions.getType() == MigrationOptions.Type.FullClone) {
                vol = createFullCloneVolume(migrationOptions, volume, primaryPool, format);
            }
        } else {
            vol = primaryPool.createPhysicalDisk(volume.getUuid(), format, volume.getProvisioningType(), disksize);
        }
        final VolumeObjectTO newVol = new VolumeObjectTO();
        if (vol != null) {
            newVol.setPath(vol.getName());
        }
        newVol.setSize(volume.getSize());
        newVol.setFormat(ImageFormat.valueOf(format.toString().toUpperCase()));
        return new CreateObjectAnswer(newVol);
    } catch (final Exception e) {
        s_logger.debug("Failed to create volume: ", e);
        return new CreateObjectAnswer(e.toString());
    }
}
Also used : PrimaryDataStoreTO(org.apache.cloudstack.storage.to.PrimaryDataStoreTO) StoragePoolType(com.cloud.storage.Storage.StoragePoolType) CreateObjectAnswer(org.apache.cloudstack.storage.command.CreateObjectAnswer) VolumeObjectTO(org.apache.cloudstack.storage.to.VolumeObjectTO) RbdException(com.ceph.rbd.RbdException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) LibvirtException(org.libvirt.LibvirtException) QemuImgException(org.apache.cloudstack.utils.qemu.QemuImgException) FileNotFoundException(java.io.FileNotFoundException) InternalErrorException(com.cloud.exception.InternalErrorException) ConfigurationException(javax.naming.ConfigurationException) RadosException(com.ceph.rados.exceptions.RadosException) PhysicalDiskFormat(org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat) MigrationOptions(com.cloud.storage.MigrationOptions)

Aggregations

MigrationOptions (com.cloud.storage.MigrationOptions)3 StoragePoolType (com.cloud.storage.Storage.StoragePoolType)2 VMTemplateStoragePoolVO (com.cloud.storage.VMTemplateStoragePoolVO)2 RadosException (com.ceph.rados.exceptions.RadosException)1 RbdException (com.ceph.rbd.RbdException)1 InternalErrorException (com.cloud.exception.InternalErrorException)1 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)1 Storage (com.cloud.storage.Storage)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 ConfigurationException (javax.naming.ConfigurationException)1 CreateObjectAnswer (org.apache.cloudstack.storage.command.CreateObjectAnswer)1 StoragePoolVO (org.apache.cloudstack.storage.datastore.db.StoragePoolVO)1 PrimaryDataStoreTO (org.apache.cloudstack.storage.to.PrimaryDataStoreTO)1 VolumeObjectTO (org.apache.cloudstack.storage.to.VolumeObjectTO)1 PhysicalDiskFormat (org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat)1 QemuImgException (org.apache.cloudstack.utils.qemu.QemuImgException)1 LibvirtException (org.libvirt.LibvirtException)1