Search in sources :

Example 1 with VNXUnityCreateCGSnapshotJob

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

the class VNXUnitySnapshotOperations method createGroupSnapshots.

@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());
        boolean inApplication = false;
        if (volume.getApplication(_dbClient) != null) {
            inApplication = true;
        } else if (volume.checkInternalFlags(Flag.INTERNAL_OBJECT)) {
            // Check if it is VPLEX backend volume and if the vplex volume is in an application
            final List<Volume> vplexVolumes = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, Volume.class, getVolumesByAssociatedId(volume.getId().toString()));
            for (Volume vplexVolume : vplexVolumes) {
                if (vplexVolume.getApplication(_dbClient) != null) {
                    inApplication = true;
                    break;
                }
            }
        }
        String groupName = volume.getReplicationGroupInstance();
        String snapLabelToUse = null;
        if (NullColumnValueGetter.isNotNullValue(groupName)) {
            String snapsetLabel = snapshotObj.getSnapsetLabel();
            if (inApplication) {
                // When in application, it could have more than one CGs in the same application, when creating
                // snapshot on the application, the snapset label would be the same for all volumes in the application.
                // if we use the same name to create snapshot for multiple CGs, it would fail.
                snapLabelToUse = String.format("%s-%s", snapsetLabel, groupName);
            } else {
                snapLabelToUse = snapsetLabel;
            }
            VNXeApiClient apiClient = getVnxeClient(storage);
            String cgId = apiClient.getConsistencyGroupIdByName(groupName);
            VNXeCommandJob job = apiClient.createSnap(cgId, snapLabelToUse, readOnly);
            if (job != null) {
                ControllerServiceImpl.enqueueJob(new QueueJob(new VNXUnityCreateCGSnapshotJob(job.getId(), storage.getId(), readOnly, taskCompleter)));
            }
        } else {
            String errorMsg = "Unable to find consistency group id when creating snapshot";
            log.error(errorMsg);
            ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateCGSnapshot", errorMsg);
            taskCompleter.error(_dbClient, error);
        }
    } catch (Exception ex) {
        log.error("Create volume snapshot got the exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateCGSnapshot", ex.getMessage());
        taskCompleter.error(_dbClient, error);
    }
}
Also used : VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) List(java.util.List) URI(java.net.URI) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) VNXUnityCreateCGSnapshotJob(com.emc.storageos.volumecontroller.impl.vnxunity.job.VNXUnityCreateCGSnapshotJob) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Aggregations

BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)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 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)1 VNXeCommandJob (com.emc.storageos.vnxe.models.VNXeCommandJob)1 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)1 VNXUnityCreateCGSnapshotJob (com.emc.storageos.volumecontroller.impl.vnxunity.job.VNXUnityCreateCGSnapshotJob)1 URI (java.net.URI)1 List (java.util.List)1