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);
}
}
Aggregations