Search in sources :

Example 1 with SmisCreateCGCloneJob

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

the class VmaxCloneOperations 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 cloneList [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) {
    _log.info("START create group clone operation");
    // Target group CIM Path
    CIMObjectPath targetGroupPath = null;
    // 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);
        URI tenant = sourceVolume.getTenant().getURI();
        TenantOrg tenantOrg = _dbClient.queryObject(TenantOrg.class, tenant);
        String targetGroupLabel = generateLabel(tenantOrg, sourceVolume);
        // CTRL-5640: ReplicationGroup may not be accessible after provider fail-over.
        ReplicationUtils.checkReplicationGroupAccessibleOrFail(storage, sourceVolume, _dbClient, _helper, _cimPath);
        final Map<String, List<Volume>> clonesBySizeMap = new HashMap<String, List<Volume>>();
        List<Volume> clones = _dbClient.queryObject(Volume.class, cloneList);
        // created separately before 'CreateGroupReplica' call.
        if (storage.checkIfVmax3() || !storage.getUsingSmis80()) {
            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);
            }
            // Create target device group
            targetGroupPath = ReplicationUtils.createTargetDeviceGroup(storage, sourceGroupName, targetDeviceIds, taskCompleter, _dbClient, _helper, _cimPath, SYNC_TYPE.CLONE);
        }
        // Create CG clone
        CIMObjectPath job = VmaxGroupOperationsUtils.internalCreateGroupReplica(storage, sourceGroupName, targetGroupLabel, targetGroupPath, createInactive, taskCompleter, SYNC_TYPE.CLONE, _dbClient, _helper, _cimPath);
        if (job != null) {
            ControllerServiceImpl.enqueueJob(new QueueJob(new SmisCreateCGCloneJob(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, targetGroupPath, 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);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) HashMap(java.util.HashMap) CIMObjectPath(javax.cim.CIMObjectPath) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) SmisCreateCGCloneJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisCreateCGCloneJob) Volume(com.emc.storageos.db.client.model.Volume) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) ArrayList(java.util.ArrayList) List(java.util.List) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob)

Aggregations

TenantOrg (com.emc.storageos.db.client.model.TenantOrg)1 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 SmisCreateCGCloneJob (com.emc.storageos.volumecontroller.impl.smis.job.SmisCreateCGCloneJob)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 CIMObjectPath (javax.cim.CIMObjectPath)1