use of com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSBlockCreateMirrorJob in project coprhd-controller by CoprHD.
the class HDSProtectionOperations method createSecondaryVolumeForMirror.
/**
* Creates secondary volume for ShadowImage pair operations.
*
* @param storageSystem
* @param sourceVolume
* @param mirror
* @throws Exception
*/
public void createSecondaryVolumeForMirror(StorageSystem storageSystem, URI sourceVolume, BlockMirror mirror) throws Exception {
log.info("SecondaryVolume for mirror creation operation started");
String taskId = UUID.randomUUID().toString();
TaskCompleter taskCompleter = new BlockMirrorCreateCompleter(mirror.getId(), taskId);
String asyncTaskMessageId = null;
HDSApiClient hdsApiClient = HDSUtils.getHDSApiClient(hdsApiFactory, storageSystem);
String systemObjectID = HDSUtils.getSystemObjectID(storageSystem);
StoragePool targetPool = dbClient.queryObject(StoragePool.class, mirror.getPool());
Volume source = dbClient.queryObject(Volume.class, sourceVolume);
TenantOrg tenant = dbClient.queryObject(TenantOrg.class, source.getTenant().getURI());
String tenantName = tenant.getLabel();
String targetLabelToUse = nameGenerator.generate(tenantName, mirror.getLabel(), mirror.getId().toString(), '-', HDSConstants.MAX_VOLUME_NAME_LENGTH);
if (mirror.getThinlyProvisioned()) {
asyncTaskMessageId = hdsApiClient.createThinVolumes(systemObjectID, targetPool.getNativeId(), mirror.getCapacity(), 1, targetLabelToUse, HDSConstants.QUICK_FORMAT_TYPE, storageSystem.getModel());
} else {
String poolObjectID = HDSUtils.getPoolObjectID(targetPool);
asyncTaskMessageId = hdsApiClient.createThickVolumes(systemObjectID, poolObjectID, mirror.getCapacity(), 1, targetLabelToUse, null, storageSystem.getModel(), null);
}
if (asyncTaskMessageId != null) {
HDSJob createHDSJob = new HDSBlockCreateMirrorJob(asyncTaskMessageId, mirror.getStorageController(), targetPool.getId(), taskCompleter);
hdsCommandHelper.waitForAsyncHDSJob(createHDSJob);
} else {
throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the create volume call");
}
log.info("SecondaryVolume for mirror creation operation completed successfully");
}
Aggregations