Search in sources :

Example 1 with SmisVnxCreateCGCloneJob

use of com.emc.storageos.volumecontroller.impl.smis.job.SmisVnxCreateCGCloneJob in project coprhd-controller by CoprHD.

the class VnxCloneOperations method createGroupClone.

/**
 * Should implement create of a clone from a source volume that is part of a
 * consistency group.
 *
 * Implementation note: In this method we will kick of the asynchronous creation
 * of the target devices required for the CG clones. Upon the successful
 * device creation, the post operations will take place, which will include the
 * creation of the target group and the group clone operation.
 *
 * @param storage [required] - StorageSystem object representing the array
 * @param clonetList [required] - clone URI list
 * @param createInactive whether the clone needs to to be created with sync_active=true/false
 * @param taskCompleter - TaskCompleter object used for the updating operation status.
 * @throws DeviceControllerException
 */
@Override
public void createGroupClone(StorageSystem storage, List<URI> cloneList, Boolean createInactive, TaskCompleter taskCompleter) throws DeviceControllerException {
    log.info("START create group clone operation");
    // List of target device ids
    List<String> targetDeviceIds = null;
    // The source consistency group name
    String sourceGroupName = null;
    try {
        final Volume first = _dbClient.queryObject(Volume.class, cloneList.get(0));
        Volume sourceVolume = _dbClient.queryObject(Volume.class, first.getAssociatedSourceVolume());
        sourceGroupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(sourceVolume, _dbClient);
        if (!ControllerUtils.isNotInRealVNXRG(sourceVolume, _dbClient)) {
            // CTRL-5640: ReplicationGroup may not be accessible after provider fail-over.
            ReplicationUtils.checkReplicationGroupAccessibleOrFail(storage, sourceVolume, _dbClient, _helper, _cimPath);
        }
        // Group volumes by pool and size
        List<String> sourceIds = new ArrayList<String>();
        List<Volume> clones = _dbClient.queryObject(Volume.class, cloneList);
        for (Volume clone : clones) {
            final Volume volume = _dbClient.queryObject(Volume.class, clone.getAssociatedSourceVolume());
            sourceIds.add(volume.getNativeId());
        }
        targetDeviceIds = new ArrayList<String>();
        for (Volume clone : clones) {
            final URI poolId = clone.getPool();
            Volume source = _dbClient.queryObject(Volume.class, clone.getAssociatedSourceVolume());
            // Create target devices
            final List<String> newDeviceIds = ReplicationUtils.createTargetDevices(storage, sourceGroupName, clone.getLabel(), createInactive, 1, poolId, clone.getCapacity(), source.getThinlyProvisioned(), source, taskCompleter, _dbClient, _helper, _cimPath);
            targetDeviceIds.addAll(newDeviceIds);
        }
        CIMObjectPath[] cloneVolumePaths = _cimPath.getVolumePaths(storage, targetDeviceIds.toArray(new String[targetDeviceIds.size()]));
        CIMObjectPath[] sourceVolumePaths = _cimPath.getVolumePaths(storage, sourceIds.toArray(new String[sourceIds.size()]));
        // Create list replica
        CIMObjectPath replicationSvc = _cimPath.getControllerReplicationSvcPath(storage);
        CIMArgument[] inArgs = _helper.getCreateListReplicaInputArguments(storage, sourceVolumePaths, cloneVolumePaths);
        CIMArgument[] outArgs = new CIMArgument[5];
        _helper.invokeMethod(storage, replicationSvc, CREATE_LIST_REPLICA, inArgs, outArgs);
        CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, JOB);
        if (job != null) {
            ControllerServiceImpl.enqueueJob(new QueueJob(new SmisVnxCreateCGCloneJob(job, storage.getId(), !createInactive, taskCompleter)));
        }
    } catch (Exception e) {
        final String errMsg = format("An exception occurred when trying to create clones for consistency group {0} on storage system {1}", sourceGroupName, storage.getId());
        log.error(errMsg, e);
        // Roll back changes
        ReplicationUtils.rollbackCreateReplica(storage, null, targetDeviceIds, taskCompleter, _dbClient, _helper, _cimPath);
        List<Volume> clones = _dbClient.queryObject(Volume.class, cloneList);
        for (Volume clone : clones) {
            clone.setInactive(true);
        }
        _dbClient.persistObject(clones);
        ServiceError error = DeviceControllerErrors.smis.methodFailed("createGroupClones", e.getMessage());
        taskCompleter.error(_dbClient, error);
    }
    log.info("createGroupClone operation END");
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ArrayList(java.util.ArrayList) CIMObjectPath(javax.cim.CIMObjectPath) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) SmisVnxCreateCGCloneJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisVnxCreateCGCloneJob) Volume(com.emc.storageos.db.client.model.Volume) ArrayList(java.util.ArrayList) List(java.util.List) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) CIMArgument(javax.cim.CIMArgument)

Aggregations

Volume (com.emc.storageos.db.client.model.Volume)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)1 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)1 SmisVnxCreateCGCloneJob (com.emc.storageos.volumecontroller.impl.smis.job.SmisVnxCreateCGCloneJob)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CIMArgument (javax.cim.CIMArgument)1 CIMObjectPath (javax.cim.CIMObjectPath)1