Search in sources :

Example 1 with HDSBlockCreateMirrorJob

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");
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) StoragePool(com.emc.storageos.db.client.model.StoragePool) HDSJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSJob) Volume(com.emc.storageos.db.client.model.Volume) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) BlockMirrorCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockMirrorCreateCompleter) HDSBlockCreateMirrorJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSBlockCreateMirrorJob)

Aggregations

StoragePool (com.emc.storageos.db.client.model.StoragePool)1 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)1 Volume (com.emc.storageos.db.client.model.Volume)1 HDSApiClient (com.emc.storageos.hds.api.HDSApiClient)1 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)1 BlockMirrorCreateCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockMirrorCreateCompleter)1 HDSBlockCreateMirrorJob (com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSBlockCreateMirrorJob)1 HDSJob (com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSJob)1