Search in sources :

Example 6 with BlockSnapshotCreateCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotCreateCompleter in project coprhd-controller by CoprHD.

the class SmisBlockCreateSnapshotJob method updateStatus.

@Override
public void updateStatus(JobContext jobContext) throws Exception {
    CloseableIterator<CIMObjectPath> syncVolumeIter = null;
    DbClient dbClient = jobContext.getDbClient();
    JobStatus jobStatus = getJobStatus();
    try {
        if (jobStatus == JobStatus.IN_PROGRESS) {
            return;
        }
        BlockSnapshotCreateCompleter completer = (BlockSnapshotCreateCompleter) getTaskCompleter();
        List<BlockSnapshot> snapshots = dbClient.queryObject(BlockSnapshot.class, completer.getSnapshotURIs());
        StorageSystem storage = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
        if (jobStatus == JobStatus.SUCCESS) {
            _log.info(String.format("Post-processing successful snap creation task:%s. Expected: snapshot.size() = 1; Actual: snapshots.size() = %d", getTaskCompleter().getOpId(), snapshots.size()));
            // Get the snapshot device ID and set it against the BlockSnapshot object
            CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
            WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
            syncVolumeIter = client.associatorNames(getCimJob(), null, SmisConstants.CIM_STORAGE_VOLUME, null, null);
            if (syncVolumeIter.hasNext()) {
                // Get the sync volume native device id
                CIMObjectPath syncVolumePath = syncVolumeIter.next();
                CIMInstance syncVolume = client.getInstance(syncVolumePath, false, false, null);
                String syncDeviceID = syncVolumePath.getKey(SmisConstants.CP_DEVICE_ID).getValue().toString();
                String elementName = CIMPropertyFactory.getPropertyValue(syncVolume, SmisConstants.CP_ELEMENT_NAME);
                String wwn = CIMPropertyFactory.getPropertyValue(syncVolume, SmisConstants.CP_WWN_NAME);
                String alternateName = CIMPropertyFactory.getPropertyValue(syncVolume, SmisConstants.CP_NAME);
                // Lookup the associated snapshot based on the volume native device id
                BlockSnapshot snapshot = snapshots.get(0);
                Volume volume = dbClient.queryObject(Volume.class, snapshot.getParent().getURI());
                snapshot.setNativeId(syncDeviceID);
                snapshot.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(storage, snapshot));
                snapshot.setDeviceLabel(elementName);
                snapshot.setInactive(false);
                snapshot.setIsSyncActive(_wantSyncActive);
                snapshot.setCreationTime(Calendar.getInstance());
                snapshot.setWWN(wwn.toUpperCase());
                snapshot.setAlternateName(alternateName);
                commonSnapshotUpdate(snapshot, syncVolume, client, storage, volume.getNativeId(), syncDeviceID, true, dbClient);
                _log.info(String.format("For sync volume path %1$s, going to set blocksnapshot %2$s nativeId to %3$s (%4$s). Associated volume is %5$s (%6$s)", syncVolumePath.toString(), snapshot.getId().toString(), syncDeviceID, elementName, volume.getNativeId(), volume.getDeviceLabel()));
                dbClient.persistObject(snapshot);
            }
        } else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
            _log.info("Failed to create snapshot");
            BlockSnapshot snapshot = snapshots.get(0);
            snapshot.setInactive(true);
            dbClient.persistObject(snapshot);
        }
    } catch (Exception e) {
        setPostProcessingErrorStatus("Encountered an internal error during block create snapshot job status processing: " + e.getMessage());
        _log.error("Caught an exception while trying to updateStatus for SmisBlockCreateSnapshotJob", e);
    } finally {
        if (syncVolumeIter != null) {
            syncVolumeIter.close();
        }
        super.updateStatus(jobContext);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) CIMObjectPath(javax.cim.CIMObjectPath) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) BlockSnapshotCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotCreateCompleter) CIMInstance(javax.cim.CIMInstance) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) Volume(com.emc.storageos.db.client.model.Volume) WBEMClient(javax.wbem.client.WBEMClient) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 7 with BlockSnapshotCreateCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotCreateCompleter in project coprhd-controller by CoprHD.

the class HDSProtectionOperations method createSecondaryVolumeForSnapshot.

/**
 * Creates Snapshot Volume
 *
 * @param storageSystem
 * @param sourceVolume
 * @param snapshotObj
 * @throws Exception
 */
public void createSecondaryVolumeForSnapshot(StorageSystem storageSystem, Volume sourceVolume, BlockSnapshot snapshotObj) throws Exception {
    log.info("SecondaryVolume for snapshot creation operation started");
    String taskId = UUID.randomUUID().toString();
    TaskCompleter taskCompleter = new BlockSnapshotCreateCompleter(Arrays.asList(snapshotObj.getId()), taskId);
    String asyncTaskMessageId = null;
    HDSApiClient hdsApiClient = HDSUtils.getHDSApiClient(hdsApiFactory, storageSystem);
    String systemObjectID = HDSUtils.getSystemObjectID(storageSystem);
    asyncTaskMessageId = hdsApiClient.createSnapshotVolume(systemObjectID, sourceVolume.getCapacity(), storageSystem.getModel());
    if (asyncTaskMessageId != null) {
        HDSJob createHDSJob = new HDSBlockCreateSnapshotJob(asyncTaskMessageId, snapshotObj.getStorageController(), taskCompleter);
        hdsCommandHelper.waitForAsyncHDSJob(createHDSJob);
    } else {
        throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the create snapshot volume call");
    }
    log.info("SecondaryVolume for snapshot creation operation completed successfully");
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) HDSBlockCreateSnapshotJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSBlockCreateSnapshotJob) HDSJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSJob) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) BlockSnapshotCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotCreateCompleter)

Example 8 with BlockSnapshotCreateCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotCreateCompleter in project coprhd-controller by CoprHD.

the class VNXeBlockSnapshotCreateJob method updateStatus.

public void updateStatus(JobContext jobContext) throws Exception {
    DbClient dbClient = jobContext.getDbClient();
    try {
        if (_status == JobStatus.IN_PROGRESS) {
            return;
        }
        BlockSnapshotCreateCompleter completer = (BlockSnapshotCreateCompleter) getTaskCompleter();
        List<BlockSnapshot> snapshots = dbClient.queryObject(BlockSnapshot.class, completer.getSnapshotURIs());
        if (_status == JobStatus.SUCCESS) {
            _logger.info(String.format("Post-processing successful snap creation task:%s. Expected: snapshot.size() = 1; Actual: snapshots.size() = %d", getTaskCompleter().getOpId(), snapshots.size()));
            StorageSystem storage = dbClient.queryObject(StorageSystem.class, getStorageSystemUri());
            VNXeApiClient vnxeApiClient = getVNXeClient(jobContext);
            VNXeCommandJob vnxeJob = vnxeApiClient.getJob(getJobIds().get(0));
            ParametersOut output = vnxeJob.getParametersOut();
            BlockSnapshot snapshot = snapshots.get(0);
            Volume volume = dbClient.queryObject(Volume.class, snapshot.getParent().getURI());
            snapshot.setNativeId(output.getId());
            snapshot.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(storage, snapshot));
            snapshot.setIsSyncActive(true);
            snapshot.setInactive(false);
            snapshot.setCreationTime(Calendar.getInstance());
            if (vnxeApiClient.isUnityClient()) {
                Snap snap = vnxeApiClient.getSnapshot(output.getId());
                snapshot.setDeviceLabel(snap.getName());
                snapshot.setAllocatedCapacity(snap.getSize());
                snapshot.setProvisionedCapacity(snap.getSize());
            } else {
                VNXeLunSnap vnxeLunSnap = vnxeApiClient.getLunSnapshot(output.getId());
                VNXeLun lun = vnxeApiClient.getLun(vnxeLunSnap.getLun().getId());
                snapshot.setDeviceLabel(vnxeLunSnap.getName());
                snapshot.setAllocatedCapacity(lun.getSnapsSizeAllocated());
                snapshot.setProvisionedCapacity(lun.getSnapsSize());
            }
            _logger.info(String.format("Going to set blocksnapshot %1$s nativeId to %2$s. Associated volume is %3$s (%4$s)", snapshot.getId().toString(), output.getId(), volume.getNativeId(), volume.getLabel()));
            dbClient.updateObject(snapshot);
            getTaskCompleter().ready(dbClient);
        } else if (_status == JobStatus.FAILED) {
            _logger.info("Failed to create snapshot");
            BlockSnapshot snapshot = snapshots.get(0);
            snapshot.setInactive(true);
            dbClient.updateObject(snapshot);
        }
    } catch (Exception e) {
        _logger.error("Caught an exception while trying to updateStatus for VNXeBlockSnapshotCreateJob", e);
        setErrorStatus("Encountered an internal error during volume snapshot create job status processing : " + e.getMessage());
    } finally {
        super.updateStatus(jobContext);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) ParametersOut(com.emc.storageos.vnxe.models.ParametersOut) BlockSnapshotCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotCreateCompleter) Snap(com.emc.storageos.vnxe.models.Snap) VNXeLunSnap(com.emc.storageos.vnxe.models.VNXeLunSnap) VNXeLunSnap(com.emc.storageos.vnxe.models.VNXeLunSnap) VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) Volume(com.emc.storageos.db.client.model.Volume) VNXeLun(com.emc.storageos.vnxe.models.VNXeLun) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 9 with BlockSnapshotCreateCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotCreateCompleter in project coprhd-controller by CoprHD.

the class BlockStorageDeviceTest method testCreateSnapshot.

@Test
public void testCreateSnapshot() {
    Boolean createInactive = false;
    List<BlockSnapshot> snapshots = createSnapshots();
    List<URI> snapshotList = new ArrayList<URI>();
    for (BlockSnapshot snapshot : snapshots) {
        snapshotList.add(snapshot.getId());
        break;
    }
    String token = UUID.randomUUID().toString() + UUID.randomUUID().toString();
    TaskCompleter taskCompleter = new BlockSnapshotCreateCompleter(snapshotList, token);
    _deviceController.doCreateSnapshot(_storageSystem, snapshotList, createInactive, false, taskCompleter);
}
Also used : BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) ArrayList(java.util.ArrayList) ExportTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter) VolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) BlockSnapshotCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotCreateCompleter) Test(org.junit.Test)

Example 10 with BlockSnapshotCreateCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotCreateCompleter in project coprhd-controller by CoprHD.

the class BlockDeviceController method createSnapshot.

@Override
public void createSnapshot(URI storage, List<URI> snapshotList, Boolean createInactive, Boolean readOnly, String opId) throws ControllerException {
    TaskCompleter completer = null;
    try {
        boolean isListReplicaFlow = false;
        StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
        BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshotList.get(0));
        Volume sourceVolumeObj = _dbClient.queryObject(Volume.class, snapshotObj.getParent().getURI());
        URI cgURI = null;
        completer = new BlockSnapshotCreateCompleter(snapshotList, opId);
        /**
         * VPLEX/RP CG volumes may not be having back end Array Group.
         * In this case we should create element replica using createListReplica.
         * We should not use createGroup replica as backend cg will not be available in this case.
         */
        boolean isVnxVolume = ControllerUtils.isVnxVolume(sourceVolumeObj, _dbClient);
        // VNX doesn't support list replica for snapshot
        isListReplicaFlow = !isVnxVolume && isListReplicaFlow(sourceVolumeObj);
        if (!isListReplicaFlow) {
            getDevice(storageObj.getSystemType()).doCreateSnapshot(storageObj, snapshotList, createInactive, readOnly, completer);
        } else {
            // List Replica
            completer.addConsistencyGroupId(cgURI);
            getDevice(storageObj.getSystemType()).doCreateListReplica(storageObj, snapshotList, createInactive, completer);
        }
    } catch (Exception e) {
        if (completer != null) {
            ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
            completer.error(_dbClient, serviceError);
        } else {
            throw DeviceControllerException.exceptions.createVolumeSnapshotFailed(e);
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) ScanTaskCompleter(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.ScanTaskCompleter) BlockSnapshotEstablishGroupTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotEstablishGroupTaskCompleter) BlockMirrorTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockMirrorTaskCompleter) CloneTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneTaskCompleter) ApplicationTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ApplicationTaskCompleter) SimpleTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SimpleTaskCompleter) VolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter) DiscoverTaskCompleter(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.DiscoverTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter) NamedURI(com.emc.storageos.db.client.model.NamedURI) FCTN_MIRROR_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_MIRROR_TO_URI) URI(java.net.URI) BlockSnapshotCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotCreateCompleter) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) DataBindingException(javax.xml.bind.DataBindingException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

BlockSnapshotCreateCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotCreateCompleter)13 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)10 Volume (com.emc.storageos.db.client.model.Volume)9 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)8 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)6 DbClient (com.emc.storageos.db.client.DbClient)5 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)5 WorkflowException (com.emc.storageos.workflow.WorkflowException)5 URI (java.net.URI)5 NamedURI (com.emc.storageos.db.client.model.NamedURI)4 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)4 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)4 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)4 ControllerException (com.emc.storageos.volumecontroller.ControllerException)4 MultiVolumeTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter)4 VolumeTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter)4 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)3 ApplicationTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.ApplicationTaskCompleter)3 BlockMirrorTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockMirrorTaskCompleter)3 BlockSnapshotEstablishGroupTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotEstablishGroupTaskCompleter)3