Search in sources :

Example 1 with SmisBlockSnapshotSessionLinkTargetJob

use of com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockSnapshotSessionLinkTargetJob in project coprhd-controller by CoprHD.

the class VmaxSnapshotOperations method linkSnapshotSessionTarget.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("rawtypes")
@Override
public void linkSnapshotSessionTarget(StorageSystem system, URI snapSessionURI, URI snapshotURI, String copyMode, Boolean targetExists, TaskCompleter completer) throws DeviceControllerException {
    if (system.checkIfVmax3()) {
        // Only supported for VMAX3 storage systems.
        try {
            _log.info("Link new target {} to snapshot session {} START", snapshotURI, snapSessionURI);
            CIMObjectPath sourcePath = null;
            CIMObjectPath targetPath = null;
            BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, snapshotURI);
            URI sourceObjURI = snapshot.getParent().getURI();
            BlockObject sourceObj = BlockObject.fetch(_dbClient, sourceObjURI);
            if (!targetExists) {
                // of snapshot.
                if (URIUtil.isType(sourceObjURI, Volume.class)) {
                    // Provision the new target volume.
                    Volume sourceVolume = (Volume) sourceObj;
                    CIMObjectPath volumeGroupPath = _helper.getVolumeGroupPath(system, system, sourceVolume, null);
                    // COP-17240: For VMAX3, we will derive the target volumes from the source volumes SRP Pool
                    CIMObjectPath poolPath = _helper.getVolumeStoragePoolPath(system, sourceVolume);
                    TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, sourceVolume.getTenant().getURI());
                    String tenantName = tenant.getLabel();
                    String label = _nameGenerator.generate(tenantName, snapshot.getLabel(), snapshotURI.toString(), '-', SmisConstants.MAX_SMI80_SNAPSHOT_NAME_LENGTH);
                    List<String> targetDeviceIds = createTargetDevices(system, poolPath, volumeGroupPath, null, "SingleSnapshot", label, Boolean.FALSE, 1, sourceVolume.getCapacity(), completer);
                    if (targetDeviceIds.isEmpty()) {
                        throw DeviceControllerException.exceptions.createTargetForSnapshotSessionFailed(snapSessionURI.toString());
                    }
                    sourcePath = _cimPath.getVolumePath(system, sourceVolume.getNativeId());
                    targetPath = _cimPath.getVolumePath(system, targetDeviceIds.get(0));
                    // Set the native id into the snapshot. This will allow a rollback
                    // to delete the target if we subsequently fail to link the target
                    // to the array snapshot.
                    String targetDeviceId = targetDeviceIds.get(0);
                    snapshot.setNativeId(targetDeviceId);
                    _dbClient.updateObject(snapshot);
                } else {
                    throw DeviceControllerException.exceptions.blockDeviceOperationNotSupported();
                }
            } else {
                // When the passed flag indicates the target exists and just needs to be
                // linked, this is the special case where we link a source volume to a snapshot
                // session of a linked target volume for the purpose of restoring the source
                // volume from the linked target volume for VMAX3. In this case, the source
                // of the passed snapshot is itself a BlockSnapshot.
                sourcePath = _cimPath.getBlockObjectPath(system, sourceObj);
                targetPath = _cimPath.getBlockObjectPath(system, snapshot);
            }
            // Now link the target to the array snapshot represented by the session.
            CIMObjectPath replicationSvcPath = _cimPath.getControllerReplicationSvcPath(system);
            BlockSnapshotSession snapSession = _dbClient.queryObject(BlockSnapshotSession.class, snapSessionURI);
            String syncAspectPath = snapSession.getSessionInstance();
            CIMObjectPath settingsStatePath = _cimPath.getSyncSettingsPath(system, sourcePath, syncAspectPath);
            CIMArgument[] inArgs = null;
            CIMArgument[] outArgs = new CIMArgument[5];
            inArgs = _helper.getModifySettingsDefinedStateForLinkTargets(system, settingsStatePath, targetPath, copyMode);
            _helper.invokeMethod(system, replicationSvcPath, SmisConstants.MODIFY_SETTINGS_DEFINE_STATE, inArgs, outArgs);
            CIMObjectPath jobPath = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
            ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockSnapshotSessionLinkTargetJob(jobPath, system.getId(), snapshotURI, copyMode, completer)));
        } catch (Exception e) {
            _log.error("Exception creating and linking snapshot session target", e);
            ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
            completer.error(_dbClient, error);
        }
    } else {
        throw DeviceControllerException.exceptions.blockDeviceOperationNotSupported();
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) CIMObjectPath(javax.cim.CIMObjectPath) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) URI(java.net.URI) SmisBlockSnapshotSessionLinkTargetJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockSnapshotSessionLinkTargetJob) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) Volume(com.emc.storageos.db.client.model.Volume) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) BlockObject(com.emc.storageos.db.client.model.BlockObject) CIMArgument(javax.cim.CIMArgument)

Aggregations

BlockObject (com.emc.storageos.db.client.model.BlockObject)1 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)1 BlockSnapshotSession (com.emc.storageos.db.client.model.BlockSnapshotSession)1 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)1 Volume (com.emc.storageos.db.client.model.Volume)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)1 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)1 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)1 SmisBlockSnapshotSessionLinkTargetJob (com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockSnapshotSessionLinkTargetJob)1 URI (java.net.URI)1 CIMArgument (javax.cim.CIMArgument)1 CIMObjectPath (javax.cim.CIMObjectPath)1 WBEMException (javax.wbem.WBEMException)1