use of com.emc.storageos.volumecontroller.impl.smis.job.SmisVnxCreateCGMirrorJob in project coprhd-controller by CoprHD.
the class VnxMirrorOperations method createGroupMirrors.
/**
* Should implement create of a mirror 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 mirrorList [required] - mirror URI list
* @param createInactive whether the mirror 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 createGroupMirrors(StorageSystem storage, List<URI> mirrorList, Boolean createInactive, TaskCompleter taskCompleter) throws DeviceControllerException {
_log.info("createGroupMirrors operation START");
List<BlockMirror> mirrors = null;
List<String> targetDeviceIds = null;
try {
mirrors = _dbClient.queryObject(BlockMirror.class, mirrorList);
BlockMirror firstMirror = mirrors.get(0);
Volume sourceVolume = _dbClient.queryObject(Volume.class, firstMirror.getSource());
String 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);
}
List<String> sourceIds = new ArrayList<String>();
targetDeviceIds = new ArrayList<String>();
Map<String, String> tgtToSrcMap = new HashMap<String, String>();
for (BlockMirror mirror : mirrors) {
final URI poolId = mirror.getPool();
final Volume source = _dbClient.queryObject(Volume.class, mirror.getSource());
sourceIds.add(source.getNativeId());
// Create target devices
final List<String> newDeviceIds = ReplicationUtils.createTargetDevices(storage, sourceGroupName, mirror.getLabel(), createInactive, 1, poolId, mirror.getCapacity(), source.getThinlyProvisioned(), null, taskCompleter, _dbClient, _helper, _cimPath);
targetDeviceIds.addAll(newDeviceIds);
tgtToSrcMap.put(newDeviceIds.get(0), source.getNativeId());
}
CIMObjectPath[] targetDevicePaths = _cimPath.getVolumePaths(storage, targetDeviceIds.toArray(new String[targetDeviceIds.size()]));
CIMObjectPath[] sourceDevicePaths = _cimPath.getVolumePaths(storage, sourceIds.toArray(new String[sourceIds.size()]));
// Create list replica
CIMObjectPath replicationSvc = _cimPath.getControllerReplicationSvcPath(storage);
CIMArgument[] inArgs = _helper.getCreateListReplicaInputArguments(storage, sourceDevicePaths, targetDevicePaths);
CIMArgument[] outArgs = new CIMArgument[5];
_helper.invokeMethod(storage, replicationSvc, SmisConstants.CREATE_LIST_REPLICA, inArgs, outArgs);
CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
ControllerServiceImpl.enqueueJob(new QueueJob(new SmisVnxCreateCGMirrorJob(job, storage.getId(), tgtToSrcMap, taskCompleter)));
for (BlockMirror mirror : mirrors) {
mirror.setSyncState(SynchronizationState.SYNCHRONIZED.name());
}
_dbClient.persistObject(mirrors);
} catch (Exception e) {
_log.error("Problem making SMI-S call: ", e);
// Roll back changes
ReplicationUtils.rollbackCreateReplica(storage, null, targetDeviceIds, taskCompleter, _dbClient, _helper, _cimPath);
if (mirrors != null && !mirrors.isEmpty()) {
for (BlockMirror mirror : mirrors) {
mirror.setInactive(true);
}
}
_dbClient.persistObject(mirrors);
ServiceError error = DeviceControllerErrors.smis.methodFailed("createGroupMirrors", e.getMessage());
taskCompleter.error(_dbClient, error);
}
_log.info("createGroupMirrors operation END");
}
Aggregations