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");
}
Aggregations