Search in sources :

Example 1 with SmisBlockCreateCGSnapshotJob

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

the class VmaxSnapshotOperations method createGroupSnapshots.

/**
 * Should implement create of a snapshot 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 snaps. Upon the successful
 * device creation, the post operations will take place, which will include the
 * creation of the target group and the group snapshot operation.
 *
 * @param storage [required] - StorageSystem object representing the array
 * @param snapshotList [required] - BlockSnapshot URI list representing the previously created
 *            snap for the volume
 * @param createInactive whether the snapshot needs to to be created with sync_active=true/false
 * @param readOnly - Indicates if the snapshot should be read only.
 * @param taskCompleter - TaskCompleter object used for the updating operation status.
 * @throws DeviceControllerException
 */
@Override
public void createGroupSnapshots(StorageSystem storage, List<URI> snapshotList, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("START createGroupSnapshots");
    // Target group CIM Path
    CIMObjectPath targetGroupPath = null;
    // List of target device ids
    List<String> targetDeviceIds = null;
    // The source consistency group name
    String sourceGroupName = null;
    try {
        final BlockSnapshot first = _dbClient.queryObject(BlockSnapshot.class, snapshotList.get(0));
        sourceGroupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(first, _dbClient);
        Volume snapVolume = _dbClient.queryObject(Volume.class, first.getParent());
        boolean thinProvisioning = snapVolume.getThinlyProvisioned() != null && snapVolume.getThinlyProvisioned();
        TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, snapVolume.getTenant().getURI());
        String tenantName = tenant.getLabel();
        final String snapLabelToUse = _nameGenerator.generate(tenantName, first.getLabel(), snapshotList.get(0).toString(), '-', storage.getUsingSmis80() ? SmisConstants.MAX_SMI80_SNAPSHOT_NAME_LENGTH : SmisConstants.MAX_SNAPSHOT_NAME_LENGTH);
        // CTRL-5640: ReplicationGroup may not be accessible after provider fail-over.
        ReplicationUtils.checkReplicationGroupAccessibleOrFail(storage, first, _dbClient, _helper, _cimPath);
        final Map<String, List<Volume>> volumesBySizeMap = new HashMap<String, List<Volume>>();
        // Group volumes by pool and size
        for (URI uri : snapshotList) {
            final BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, uri);
            final Volume volume = _dbClient.queryObject(Volume.class, snapshot.getParent().getURI());
            final String key = volume.getPool() + "-" + volume.getCapacity();
            final List<Volume> currentVolumes = volumesBySizeMap.containsKey(key) ? volumesBySizeMap.get(key) : new ArrayList<Volume>();
            currentVolumes.add(volume);
            volumesBySizeMap.put(key, currentVolumes);
        }
        // For VMAX3, we need the target group to tag the setting instance
        if (storage.checkIfVmax3() || !storage.getUsingSmis80()) {
            targetDeviceIds = new ArrayList<String>();
            for (Entry<String, List<Volume>> entry : volumesBySizeMap.entrySet()) {
                final List<Volume> volumes = entry.getValue();
                final Volume volume = volumes.get(0);
                final URI poolId = volume.getPool();
                CIMObjectPath volumeGroupPath = _helper.getVolumeGroupPath(storage, storage, volume, null);
                // Create target devices based on the array model
                final List<String> newDeviceIds = kickOffTargetDevicesCreation(storage, volumeGroupPath, sourceGroupName, snapLabelToUse, createInactive, thinProvisioning, volumes.size(), poolId, volume.getCapacity(), taskCompleter);
                targetDeviceIds.addAll(newDeviceIds);
            }
            // Create target device group
            targetGroupPath = ReplicationUtils.createTargetDeviceGroup(storage, sourceGroupName, targetDeviceIds, taskCompleter, _dbClient, _helper, _cimPath, SYNC_TYPE.SNAPSHOT);
        }
        // Create CG snapshot
        CIMObjectPath job = VmaxGroupOperationsUtils.internalCreateGroupReplica(storage, sourceGroupName, snapLabelToUse, targetGroupPath, createInactive, thinProvisioning, taskCompleter, SYNC_TYPE.SNAPSHOT, _dbClient, _helper, _cimPath);
        if (job != null) {
            ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockCreateCGSnapshotJob(job, storage.getId(), !createInactive, sourceGroupName, taskCompleter)));
        }
    } catch (Exception e) {
        final String errMsg = format("An exception occurred when trying to create snapshots for consistency group {0} on storage system {1}", sourceGroupName, storage.getId());
        _log.error(errMsg, e);
        ServiceError error = DeviceControllerErrors.smis.methodFailed("createGroupSnapshots", e.getMessage());
        taskCompleter.error(_dbClient, error);
        // Roll back changes
        rollbackCreateSnapshot(storage, targetGroupPath, targetDeviceIds, taskCompleter);
        throw new SmisException(errMsg, e);
    }
}
Also used : SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) HashMap(java.util.HashMap) CIMObjectPath(javax.cim.CIMObjectPath) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) URI(java.net.URI) 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) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) NamedElementQueryResultList(com.emc.storageos.db.client.constraint.NamedElementQueryResultList) ArrayList(java.util.ArrayList) List(java.util.List) SmisBlockCreateCGSnapshotJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockCreateCGSnapshotJob) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob)

Example 2 with SmisBlockCreateCGSnapshotJob

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

the class VnxSnapshotOperations method createGroupSnapshots.

/**
 * Should implement create of a snapshot from a source volume that is part of a
 * consistency group.
 *
 * @param storage [required] - StorageSystem object representing the array
 * @param snapshot [required] - BlockSnapshot URI representing the previously created
 *            snap for the volume
 * @param createInactive - Indicates if the snapshots should be created but not
 *            activated
 * @param readOnly - Indicates if the snapshot should be read only.
 * @param taskCompleter - TaskCompleter object used for the updating operation status.
 * @throws DeviceControllerException
 */
@Override
public void createGroupSnapshots(StorageSystem storage, List<URI> snapshotList, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        URI snapshot = snapshotList.get(0);
        BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
        Volume volume = _dbClient.queryObject(Volume.class, snapshotObj.getParent());
        if (ControllerUtils.isNotInRealVNXRG(volume, _dbClient)) {
            throw DeviceControllerException.exceptions.groupSnapshotNotSupported(volume.getReplicationGroupInstance());
        }
        // CTRL-5640: ReplicationGroup may not be accessible after provider fail-over.
        ReplicationUtils.checkReplicationGroupAccessibleOrFail(storage, snapshotObj, _dbClient, _helper, _cimPath);
        TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, volume.getTenant().getURI());
        String tenantName = tenant.getLabel();
        String snapLabelToUse = _nameGenerator.generate(tenantName, snapshotObj.getLabel(), snapshot.toString(), '-', SmisConstants.MAX_SNAPSHOT_NAME_LENGTH);
        String groupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(snapshotObj, _dbClient);
        CIMObjectPath cgPath = _cimPath.getReplicationGroupPath(storage, groupName);
        CIMObjectPath replicationSvc = _cimPath.getControllerReplicationSvcPath(storage);
        CIMArgument[] inArgs = _helper.getCreateGroupReplicaInputArgumentsForVNX(storage, cgPath, createInactive, snapLabelToUse, SYNC_TYPE.SNAPSHOT.getValue());
        CIMArgument[] outArgs = new CIMArgument[5];
        _helper.invokeMethod(storage, replicationSvc, SmisConstants.CREATE_GROUP_REPLICA, inArgs, outArgs);
        CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
        if (job != null) {
            ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockCreateCGSnapshotJob(job, storage.getId(), !createInactive, null, taskCompleter)));
        }
    } catch (Exception e) {
        _log.info("Problem making SMI-S call: ", e);
        ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
        taskCompleter.error(_dbClient, error);
        setInactive(((BlockSnapshotCreateCompleter) taskCompleter).getSnapshotURIs(), true);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) CIMObjectPath(javax.cim.CIMObjectPath) URI(java.net.URI) BlockSnapshotCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotCreateCompleter) WBEMException(javax.wbem.WBEMException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) Volume(com.emc.storageos.db.client.model.Volume) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) SmisBlockCreateCGSnapshotJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockCreateCGSnapshotJob) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) CIMArgument(javax.cim.CIMArgument)

Aggregations

BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)2 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)2 Volume (com.emc.storageos.db.client.model.Volume)2 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)2 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)2 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)2 SmisBlockCreateCGSnapshotJob (com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockCreateCGSnapshotJob)2 URI (java.net.URI)2 CIMObjectPath (javax.cim.CIMObjectPath)2 WBEMException (javax.wbem.WBEMException)2 NamedElementQueryResultList (com.emc.storageos.db.client.constraint.NamedElementQueryResultList)1 BlockSnapshotCreateCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotCreateCompleter)1 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)1 WorkflowException (com.emc.storageos.workflow.WorkflowException)1 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 CIMArgument (javax.cim.CIMArgument)1