Search in sources :

Example 16 with VolumeClone

use of com.emc.storageos.storagedriver.model.VolumeClone in project coprhd-controller by CoprHD.

the class CreateVolumeCloneSimulatorOperation method getSuccessMessage.

@SuppressWarnings("unchecked")
@Override
public String getSuccessMessage(Object... args) {
    List<VolumeClone> clones;
    if ((args != null) && (args.length > 0)) {
        clones = (List<VolumeClone>) args[0];
    } else {
        // Must be asynchronous, so updated clones are in the task.
        CreateVolumeCloneDriverTask createCloneTask = (CreateVolumeCloneDriverTask) _task;
        clones = createCloneTask.getClones();
    }
    return String.format("StorageDriver: createVolumeClone information for storage system %s, clone nativeIds %s - end", clones.get(0).getStorageSystemId(), clones.toString());
}
Also used : CreateVolumeCloneDriverTask(com.emc.storageos.storagedriver.task.CreateVolumeCloneDriverTask) VolumeClone(com.emc.storageos.storagedriver.model.VolumeClone)

Example 17 with VolumeClone

use of com.emc.storageos.storagedriver.model.VolumeClone in project coprhd-controller by CoprHD.

the class RestoreFromCloneSimulatorOperation method getSuccessMessage.

@SuppressWarnings("unchecked")
@Override
public String getSuccessMessage(Object... args) {
    List<VolumeClone> clones;
    if ((args != null) && (args.length > 0)) {
        clones = (List<VolumeClone>) args[0];
    } else {
        // Must be asynchronous, so updated clones are in the task.
        RestoreFromCloneDriverTask restoreCloneTask = (RestoreFromCloneDriverTask) _task;
        clones = restoreCloneTask.getClones();
    }
    return String.format("StorageDriver: restoreFromClone : clones %s", clones.toString());
}
Also used : RestoreFromCloneDriverTask(com.emc.storageos.storagedriver.task.RestoreFromCloneDriverTask) VolumeClone(com.emc.storageos.storagedriver.model.VolumeClone)

Example 18 with VolumeClone

use of com.emc.storageos.storagedriver.model.VolumeClone in project coprhd-controller by CoprHD.

the class ExternalDeviceUnManagedVolumeDiscoverer method processUnManagedClones.

/**
 * Process clones of unManaged volume.
 * Check if unManaged clone should be created and create unManaged volume instance for a clone in such a case.
 * Add unManaged clone to parent volume CG if needed and update the clone with parent volume CG information.
 * Gets export information for clones and stores it in the provided map.
 *
 * @param driverVolume              driver volume for clone parent volume. [IN]
 * @param unManagedParentVolume     unManaged parent volume [IN/OUT]
 * @param storageSystem             storage system [IN]
 * @param storagePool               storage pool [IN]
 * @param unManagedVolumesToCreate  list of unmanaged volumes to create [OUT]
 * @param unManagedVolumesToUpdate  list of unmanaged volumes to update [OUT]
 * @param allCurrentUnManagedCgURIs set of unManaged CG uris found in the current discovery [OUT]
 * @param unManagedCGToUpdateMap    map of unManaged CG GUID to unManaged CG instance [IN/OUT]
 * @param unManagedVolumeNativeIdToUriMap map of unmanaged volumes nativeId to their uri [OUT]
 * @param hostToUnManagedVolumeExportInfoMap map  with export data for unmanaged volumes (including snaps and clones)
 * @param driver                    storage driver [IN]
 * @param dbClient                  reference to db client [IN]
 * @return                          set of URIs for unmanaged clones
 * @throws Exception
 */
private Set<URI> processUnManagedClones(StorageVolume driverVolume, UnManagedVolume unManagedParentVolume, com.emc.storageos.db.client.model.StorageSystem storageSystem, com.emc.storageos.db.client.model.StoragePool storagePool, List<UnManagedVolume> unManagedVolumesToCreate, List<UnManagedVolume> unManagedVolumesToUpdate, Set<URI> allCurrentUnManagedCgURIs, Map<String, UnManagedConsistencyGroup> unManagedCGToUpdateMap, Map<String, URI> unManagedVolumeNativeIdToUriMap, Map<String, List<HostExportInfo>> hostToUnManagedVolumeExportInfoMap, BlockStorageDriver driver, DbClient dbClient) throws Exception {
    log.info("Processing clones for volume {} ", unManagedParentVolume.getNativeGuid());
    Set<URI> cloneUris = new HashSet<>();
    List<VolumeClone> driverClones = driver.getVolumeClones(driverVolume);
    if (driverClones == null || driverClones.isEmpty()) {
        log.info("There are no clones for volume {} ", unManagedParentVolume.getNativeGuid());
    } else {
        log.info("Clones for unManaged volume {}:" + Joiner.on("\t").join(driverClones), unManagedParentVolume.getNativeGuid());
        StringSet unManagedClones = new StringSet();
        for (VolumeClone driverClone : driverClones) {
            String managedCloneNativeGuid = NativeGUIDGenerator.generateNativeGuidForVolumeOrBlockSnapShot(storageSystem.getNativeGuid(), driverClone.getNativeId());
            Volume systemClone = DiscoveryUtils.checkStorageVolumeExistsInDB(dbClient, managedCloneNativeGuid);
            if (null != systemClone) {
                log.info("Skipping clone {} as it is already managed by the system.", managedCloneNativeGuid);
                continue;
            }
            String unManagedCloneNatvieGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingVolume(storageSystem.getNativeGuid(), driverClone.getNativeId());
            UnManagedVolume unManagedClone = createUnManagedClone(driverClone, unManagedParentVolume, storageSystem, storagePool, unManagedVolumesToCreate, unManagedVolumesToUpdate, dbClient);
            cloneUris.add(unManagedClone.getId());
            unManagedClones.add(unManagedCloneNatvieGuid);
            // Check if this clone is for a volume in consistency group on device.
            String isParentVolumeInCG = unManagedParentVolume.getVolumeCharacterstics().get(UnManagedVolume.SupportedVolumeCharacterstics.IS_VOLUME_ADDED_TO_CONSISTENCYGROUP.toString());
            if (isParentVolumeInCG.equals(Boolean.TRUE.toString())) {
                log.info("Clone {} is for volume in CG. ", managedCloneNativeGuid);
                // add clone to parent volume unManaged consistency group, update clone with parent volume CG information.
                addObjectToUnManagedConsistencyGroup(storageSystem, driverVolume.getConsistencyGroup(), unManagedClone, allCurrentUnManagedCgURIs, unManagedCGToUpdateMap, driver, dbClient);
            }
            // get export data for the clone
            unManagedVolumeNativeIdToUriMap.put(driverClone.getNativeId(), unManagedClone.getId());
            getCloneExportInfo(driver, driverClone, hostToUnManagedVolumeExportInfoMap);
        }
        if (!unManagedClones.isEmpty()) {
            // set the HAS_REPLICAS property
            unManagedParentVolume.getVolumeCharacterstics().put(UnManagedVolume.SupportedVolumeCharacterstics.HAS_REPLICAS.toString(), TRUE);
            StringSetMap unManagedVolumeInformation = unManagedParentVolume.getVolumeInformation();
            log.info("New unManaged clones for unManaged volume {}:" + Joiner.on("\t").join(unManagedClones), unManagedParentVolume.getNativeGuid());
            if (unManagedVolumeInformation.containsKey(UnManagedVolume.SupportedVolumeInformation.FULL_COPIES.toString())) {
                log.info("Old unManaged clones for unManaged volume {}:" + Joiner.on("\t").join(unManagedVolumeInformation.get(UnManagedVolume.SupportedVolumeInformation.FULL_COPIES.toString())), unManagedParentVolume.getNativeGuid());
                // replace with new StringSet
                unManagedVolumeInformation.get(UnManagedVolume.SupportedVolumeInformation.FULL_COPIES.toString()).replace(unManagedClones);
                log.info("Replaced clones :" + Joiner.on("\t").join(unManagedVolumeInformation.get(UnManagedVolume.SupportedVolumeInformation.FULL_COPIES.toString())));
            } else {
                unManagedVolumeInformation.put(UnManagedVolume.SupportedVolumeInformation.FULL_COPIES.toString(), unManagedClones);
            }
        } else {
            log.info("All clones for volume {} are already managed.", unManagedParentVolume.getNativeGuid());
        }
    }
    return cloneUris;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) StringSet(com.emc.storageos.db.client.model.StringSet) VolumeClone(com.emc.storageos.storagedriver.model.VolumeClone) URI(java.net.URI) HashSet(java.util.HashSet)

Example 19 with VolumeClone

use of com.emc.storageos.storagedriver.model.VolumeClone in project coprhd-controller by CoprHD.

the class CreateGroupCloneExternalDeviceJob method doTaskSucceeded.

/**
 * {@inheritDoc}
 */
@Override
protected void doTaskSucceeded(DriverTask driverTask, DbClient dbClient) throws Exception {
    s_logger.info(String.format("Successfully created group clone: %s", driverTask.getMessage()));
    // Update the ViPR volumes representing the clone with the
    // corresponding driver clone.
    List<Volume> updatedVolumes = new ArrayList<>();
    for (URI volumeURI : _volumeURIs) {
        Volume volume = dbClient.queryObject(Volume.class, volumeURI);
        if (volume == null) {
            s_logger.error(String.format("Failed to find volume %s", volumeURI));
            throw DeviceControllerException.exceptions.objectNotFound(volumeURI);
        }
        // Update the ViPR clone with the driver clone information.
        CreateGroupCloneDriverTask createCloneDriverTask = (CreateGroupCloneDriverTask) driverTask;
        List<VolumeClone> updatedClones = createCloneDriverTask.getClones();
        for (VolumeClone updatedClone : updatedClones) {
            if (ExternalDeviceUtils.isVolumeExternalDeviceClone(volume, updatedClone, dbClient)) {
                ExternalDeviceUtils.updateNewlyCreatedGroupClone(volume, updatedClone, _cgURI, dbClient);
                updatedVolumes.add(volume);
                break;
            }
        }
    }
    dbClient.updateObject(updatedVolumes);
    try {
        // post process storage pool capacity for clone's pools
        // map clones to their storage pool
        updateStoragePoolCapacityAfterOperationComplete(updatedVolumes, dbClient);
    } catch (Exception ex) {
        s_logger.error("Failed to update storage pool after create group clone operation completion.", ex);
    }
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) ArrayList(java.util.ArrayList) CreateGroupCloneDriverTask(com.emc.storageos.storagedriver.task.CreateGroupCloneDriverTask) VolumeClone(com.emc.storageos.storagedriver.model.VolumeClone) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 20 with VolumeClone

use of com.emc.storageos.storagedriver.model.VolumeClone in project coprhd-controller by CoprHD.

the class RestoreFromCloneExternalDeviceJob method doTaskSucceeded.

/**
 * {@inheritDoc}
 */
@Override
protected void doTaskSucceeded(DriverTask driverTask, DbClient dbClient) throws Exception {
    // Get the ViPR volume representing the clone.
    s_logger.info(String.format("Successfully restored clone %s:%s", _volumeURI, driverTask.getMessage()));
    Volume volume = dbClient.queryObject(Volume.class, _volumeURI);
    if (volume == null) {
        s_logger.error(String.format("Failed to find volume %s", _volumeURI));
        throw DeviceControllerException.exceptions.objectNotFound(_volumeURI);
    }
    // Update the ViPR clone with the driver clone information.
    // Note that we know ViPR only allows you to restore a single
    // non-group clone at a time.
    RestoreFromCloneDriverTask restoreDriverTask = (RestoreFromCloneDriverTask) driverTask;
    List<VolumeClone> updatedClones = restoreDriverTask.getClones();
    VolumeClone updatedClone = updatedClones.get(0);
    ExternalDeviceUtils.updateRestoredClone(volume, updatedClone, dbClient, true);
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) RestoreFromCloneDriverTask(com.emc.storageos.storagedriver.task.RestoreFromCloneDriverTask) VolumeClone(com.emc.storageos.storagedriver.model.VolumeClone)

Aggregations

VolumeClone (com.emc.storageos.storagedriver.model.VolumeClone)27 Volume (com.emc.storageos.db.client.model.Volume)13 StorageVolume (com.emc.storageos.storagedriver.model.StorageVolume)10 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)9 ArrayList (java.util.ArrayList)9 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)7 BlockStorageDriver (com.emc.storageos.storagedriver.BlockStorageDriver)7 DriverTask (com.emc.storageos.storagedriver.DriverTask)7 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)7 IOException (java.io.IOException)7 BlockObject (com.emc.storageos.db.client.model.BlockObject)6 StorageBlockObject (com.emc.storageos.storagedriver.model.StorageBlockObject)6 VolumeDetailsCommandResult (com.emc.storageos.hp3par.command.VolumeDetailsCommandResult)4 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)4 URI (java.net.URI)4 HashMap (java.util.HashMap)4 CreateGroupCloneDriverTask (com.emc.storageos.storagedriver.task.CreateGroupCloneDriverTask)3 RestoreFromCloneDriverTask (com.emc.storageos.storagedriver.task.RestoreFromCloneDriverTask)3 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)2 StoragePool (com.emc.storageos.db.client.model.StoragePool)2