Search in sources :

Example 21 with VolumeClone

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

the class CreateGroupCloneSimulatorOperation method updateGroupCloneInfo.

/**
 * Update the clone information after successfully being created.
 *
 * @param consistencyGroup A reference to the consistency group.
 * @param clones A list of the clones to be updated.
 */
public void updateGroupCloneInfo(VolumeConsistencyGroup consistencyGroup, List<VolumeClone> clones) {
    String cloneTimestamp = Long.toString(System.currentTimeMillis());
    for (VolumeClone clone : clones) {
        clone.setNativeId("clone-" + clone.getParentId() + clone.getDisplayName());
        clone.setWwn(String.format("%s%s", clone.getStorageSystemId(), clone.getNativeId()));
        clone.setReplicationState(VolumeClone.ReplicationState.SYNCHRONIZED);
        clone.setProvisionedCapacity(clone.getRequestedCapacity());
        clone.setAllocatedCapacity(clone.getRequestedCapacity());
        clone.setDeviceLabel(clone.getNativeId());
        clone.setConsistencyGroup(consistencyGroup.getNativeId() + "_clone-" + cloneTimestamp);
    }
}
Also used : VolumeClone(com.emc.storageos.storagedriver.model.VolumeClone)

Example 22 with VolumeClone

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

the class HP3PARCGHelper method createConsistencyGroupClone.

/**
 * Creating physical copy for VVset or CG clone Rest API expects created
 * VVset with its corresponding volumes types for clone destination So,
 * There are many ways for implementation
 *
 * 1. Customer will provide the VVSet name which already exist in Array
 * with its corresponding similar volumes for cloning
 *
 * 2. Customer will not provide any existing and matching VV set with
 * corresponding volumes for CG clone
 *
 * 3. Customer will provide VVset name which is created but volumes are not
 * matching for clone creation.
 *
 * Create new VV Set / CG . Create new volumes similar to parent VVSet
 * volumes Use this newly created VV set for CG clone
 *
 * option 2 is implemented, need to handle negative / error cases of option
 * 3
 */
public DriverTask createConsistencyGroupClone(VolumeConsistencyGroup consistencyGroup, List<VolumeClone> clones, List<CapabilityInstance> capabilities, DriverTask task, Registry driverRegistry) {
    _log.info("3PARDriver: createConsistencyGroupClone for storage system  id {}, Base CG name {} , Base CG native id {} - start", consistencyGroup.getStorageSystemId(), consistencyGroup.getDisplayName(), consistencyGroup.getNativeId());
    String VVsetNameForClone = consistencyGroup.getDisplayName();
    VolumeDetailsCommandResult volResult = null;
    HashMap<String, VolumeClone> clonesMap = new HashMap<String, VolumeClone>();
    try {
        Boolean saveSnapshot = true;
        // get Api client
        HP3PARApi hp3parApi = hp3parUtil.getHP3PARDeviceFromNativeId(consistencyGroup.getStorageSystemId(), driverRegistry);
        // get Vipr generated clone name
        for (VolumeClone clone : clones) {
            // native id = null ,
            _log.info("3PARDriver: createConsistencyGroupClone generated clone parent id {}, display name {} ", clone.getParentId(), clone.getDisplayName());
            String generatedCloneName = clone.getDisplayName();
            VVsetNameForClone = generatedCloneName.substring(0, generatedCloneName.lastIndexOf("-"));
            _log.info("3PARDriver: createConsistencyGroupClone CG name {} to be used in cloning ", VVsetNameForClone);
            clonesMap.put(clone.getParentId(), clone);
        }
        _log.info("3PARDriver: createConsistencyGroupClone  clonesMap {}", clonesMap.toString());
        // Create vvset clone
        VVSetVolumeClone[] result = hp3parApi.createVVsetPhysicalCopy(consistencyGroup.getNativeId(), VVsetNameForClone, clones, saveSnapshot);
        _log.info("3PARDriver: createConsistencyGroupClone outPut of CG clone result  {} ", result.toString());
        for (VVSetVolumeClone cloneCreated : result) {
            VolumeClone clone = clonesMap.get(cloneCreated.getParent());
            _log.info("createConsistencyGroupClone cloneCreated {} and local clone obj nativeid = {} , parent id = {}", cloneCreated.getValues(), clone.getNativeId(), clone.getParentId());
            volResult = hp3parApi.getVolumeDetails(cloneCreated.getChild());
            _log.info("createConsistencyGroupClone cloneCreated All values {} ", volResult.getAllValues());
            clone.setWwn(volResult.getWwn());
            clone.setNativeId(volResult.getId());
            clone.setDeviceLabel(volResult.getName());
            // snap.setAccessStatus(volResult.getAccessStatus());
            clone.setDisplayName(volResult.getName());
            clone.setReplicationState(VolumeClone.ReplicationState.SYNCHRONIZED);
            clone.setProvisionedCapacity(clone.getRequestedCapacity());
            // Allocated capacity is the sum of user, snapshot and admin reserved space
            Long allocatedCapacity = volResult.getUserSpace().getReservedMiB();
            allocatedCapacity += volResult.getSnapshotSpace().getReservedMiB();
            allocatedCapacity += volResult.getAdminSpace().getReservedMiB();
            clone.setAllocatedCapacity(allocatedCapacity * HP3PARConstants.MEGA_BYTE);
        }
        task.setStatus(DriverTask.TaskStatus.READY);
        _log.info("createConsistencyGroupClone for storage system native id {}, CG display Name {}, CG native id {} - end", consistencyGroup.getStorageSystemId(), consistencyGroup.getDisplayName(), consistencyGroup.getNativeId());
    } catch (Exception e) {
        String msg = String.format("3PARDriver: createConsistencyGroupClone Unable to create vv set snap name %s and its native id %s whose storage system  id is %s; Error: %s.\n", VVsetNameForClone, consistencyGroup.getNativeId(), consistencyGroup.getStorageSystemId(), e.getMessage());
        _log.error(msg);
        task.setMessage(msg);
        task.setStatus(DriverTask.TaskStatus.PARTIALLY_FAILED);
        e.printStackTrace();
    }
    return task;
}
Also used : HashMap(java.util.HashMap) VVSetVolumeClone(com.emc.storageos.hp3par.command.VVSetCloneList.VVSetVolumeClone) VolumeDetailsCommandResult(com.emc.storageos.hp3par.command.VolumeDetailsCommandResult) VolumeClone(com.emc.storageos.storagedriver.model.VolumeClone) VVSetVolumeClone(com.emc.storageos.hp3par.command.VVSetCloneList.VVSetVolumeClone)

Example 23 with VolumeClone

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

the class ExternalBlockStorageDevice method doDetachClone.

@Override
public void doDetachClone(StorageSystem storageSystem, URI cloneVolume, TaskCompleter taskCompleter) {
    BlockStorageDriver driver = getDriver(storageSystem.getSystemType());
    DriverTask task = null;
    Volume clone = dbClient.queryObject(Volume.class, cloneVolume);
    _log.info("Detaching volume clone on storage system {}, clone: {} .", storageSystem.getNativeId(), clone.toString());
    try {
        BlockObject sourceVolume = BlockObject.fetch(dbClient, clone.getAssociatedSourceVolume());
        VolumeClone driverClone = new VolumeClone();
        driverClone.setStorageSystemId(storageSystem.getNativeId());
        driverClone.setNativeId(clone.getNativeId());
        driverClone.setParentId(sourceVolume.getNativeId());
        driverClone.setConsistencyGroup(clone.getReplicationGroupInstance());
        // Call driver
        task = driver.detachVolumeClone(Collections.unmodifiableList(Collections.singletonList(driverClone)));
        // todo: need to implement support for async case.
        if (task.getStatus() == DriverTask.TaskStatus.READY) {
            ReplicationUtils.removeDetachedFullCopyFromSourceFullCopiesList(clone, dbClient);
            clone.setAssociatedSourceVolume(NullColumnValueGetter.getNullURI());
            clone.setReplicaState(Volume.ReplicationState.DETACHED.name());
            String msg = String.format("doDetachClone -- Detached volume clone: %s .", task.getMessage());
            _log.info(msg);
            dbClient.updateObject(clone);
            taskCompleter.ready(dbClient);
        } else {
            String msg = String.format("Failed to detach volume clone on storage system %s, clone: %s .", storageSystem.getNativeId(), clone.toString());
            _log.error(msg);
            // todo: add error
            ServiceError serviceError = ExternalDeviceException.errors.detachVolumeCloneFailed("doDetachClone", msg);
            taskCompleter.error(dbClient, serviceError);
        }
    } catch (Exception e) {
        String msg = String.format("Failed to detach volume clone on storage system %s, clone: %s .", storageSystem.getNativeId(), clone.toString());
        _log.error(msg, e);
        ServiceError serviceError = ExternalDeviceException.errors.detachVolumeCloneFailed("doDetachClone", msg);
        taskCompleter.error(dbClient, serviceError);
    }
}
Also used : DriverTask(com.emc.storageos.storagedriver.DriverTask) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) Volume(com.emc.storageos.db.client.model.Volume) VolumeClone(com.emc.storageos.storagedriver.model.VolumeClone) BlockStorageDriver(com.emc.storageos.storagedriver.BlockStorageDriver) BlockObject(com.emc.storageos.db.client.model.BlockObject) StorageBlockObject(com.emc.storageos.storagedriver.model.StorageBlockObject) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) IOException(java.io.IOException)

Example 24 with VolumeClone

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

the class ExternalBlockStorageDevice method hasExports.

/**
 * Check if block object has exports on device
 *
 * @param driver storage driver
 * @param driverBlockObject driver block object
 * @return true/false
 */
private boolean hasExports(BlockStorageDriver driver, StorageBlockObject driverBlockObject) {
    Map<String, HostExportInfo> blocObjectToHostExportInfo = null;
    // get HostExportInfo data for this block object from the driver
    if (driverBlockObject instanceof VolumeClone) {
        VolumeClone driverClone = (VolumeClone) driverBlockObject;
        blocObjectToHostExportInfo = driver.getCloneExportInfoForHosts(driverClone);
        _log.info("Export info for clone {} is {}:", driverClone, blocObjectToHostExportInfo);
    } else if (driverBlockObject instanceof VolumeSnapshot) {
        VolumeSnapshot driverSnapshot = (VolumeSnapshot) driverBlockObject;
        blocObjectToHostExportInfo = driver.getSnapshotExportInfoForHosts(driverSnapshot);
        _log.info("Export info for snapshot {} is {}:", driverSnapshot, blocObjectToHostExportInfo);
    } else if (driverBlockObject instanceof StorageVolume) {
        StorageVolume driverVolume = (StorageVolume) driverBlockObject;
        blocObjectToHostExportInfo = driver.getVolumeExportInfoForHosts(driverVolume);
        _log.info("Export info for volume {} is {}:", driverVolume, blocObjectToHostExportInfo);
    } else {
        // not supported type in this method
        String errorMsg = String.format("Method is not supported for %s objects.", driverBlockObject.getClass().getSimpleName());
        throw new RuntimeException(errorMsg);
    }
    return !(blocObjectToHostExportInfo == null || blocObjectToHostExportInfo.isEmpty());
}
Also used : StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) HostExportInfo(com.emc.storageos.storagedriver.HostExportInfo) VolumeClone(com.emc.storageos.storagedriver.model.VolumeClone) VolumeSnapshot(com.emc.storageos.storagedriver.model.VolumeSnapshot)

Example 25 with VolumeClone

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

the class ExternalBlockStorageDevice method doRestoreFromClone.

@Override
public void doRestoreFromClone(StorageSystem storageSystem, URI cloneVolume, TaskCompleter taskCompleter) {
    BlockStorageDriver driver = getDriver(storageSystem.getSystemType());
    DriverTask task = null;
    Volume clone = dbClient.queryObject(Volume.class, cloneVolume);
    _log.info("Restore from volume clone on storage system {}, clone: {} .", storageSystem.getNativeId(), clone.toString());
    try {
        BlockObject sourceVolume = BlockObject.fetch(dbClient, clone.getAssociatedSourceVolume());
        VolumeClone driverClone = new VolumeClone();
        driverClone.setStorageSystemId(storageSystem.getNativeId());
        driverClone.setNativeId(clone.getNativeId());
        driverClone.setParentId(sourceVolume.getNativeId());
        driverClone.setConsistencyGroup(clone.getReplicationGroupInstance());
        // Call driver
        task = driver.restoreFromClone(Collections.unmodifiableList(Collections.singletonList(driverClone)));
        if (!isTaskInTerminalState(task.getStatus())) {
            // If the task is not in a terminal state and will be completed asynchronously
            // create a job to monitor the progress of the request and update the clone
            // volume replica state and call the completer as appropriate based on the result
            // of the request.
            RestoreFromCloneExternalDeviceJob job = new RestoreFromCloneExternalDeviceJob(storageSystem.getId(), cloneVolume, task.getTaskId(), taskCompleter);
            ControllerServiceImpl.enqueueJob(new QueueJob(job));
        } else if (task.getStatus() == DriverTask.TaskStatus.READY) {
            String msg = String.format("doRestoreFromClone -- Restored volume from clone: %s .", task.getMessage());
            _log.info(msg);
            ExternalDeviceUtils.updateRestoredClone(clone, driverClone, dbClient, true);
            taskCompleter.ready(dbClient);
        } else {
            String msg = String.format("Failed to restore volume from clone on storage system %s, clone: %s .", storageSystem.getNativeId(), clone.toString());
            _log.error(msg);
            // todo: add error
            ServiceError serviceError = ExternalDeviceException.errors.restoreVolumesFromClonesFailed("doRestoreFromClone", msg);
            taskCompleter.error(dbClient, serviceError);
        }
    } catch (Exception e) {
        String msg = String.format("Failed to restore volume from clone on storage system %s, clone: %s .", storageSystem.getNativeId(), clone.toString());
        _log.error(msg, e);
        ServiceError serviceError = ExternalDeviceException.errors.restoreVolumesFromClonesFailed("doRestoreFromClone", msg);
        taskCompleter.error(dbClient, serviceError);
    }
}
Also used : DriverTask(com.emc.storageos.storagedriver.DriverTask) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) RestoreFromCloneExternalDeviceJob(com.emc.storageos.volumecontroller.impl.externaldevice.job.RestoreFromCloneExternalDeviceJob) StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) Volume(com.emc.storageos.db.client.model.Volume) VolumeClone(com.emc.storageos.storagedriver.model.VolumeClone) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) BlockStorageDriver(com.emc.storageos.storagedriver.BlockStorageDriver) BlockObject(com.emc.storageos.db.client.model.BlockObject) StorageBlockObject(com.emc.storageos.storagedriver.model.StorageBlockObject) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) IOException(java.io.IOException)

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