use of com.emc.storageos.volumecontroller.impl.utils.labels.LabelFormatFactory in project coprhd-controller by CoprHD.
the class ReplicaDeviceController method prepareSnapshot.
private BlockSnapshot prepareSnapshot(Volume volume, String repGroupName) {
BlockSnapshot snapshot = new BlockSnapshot();
snapshot.setId(URIUtil.createId(BlockSnapshot.class));
URI cgUri = volume.getConsistencyGroup();
if (cgUri != null) {
snapshot.setConsistencyGroup(cgUri);
}
snapshot.setSourceNativeId(volume.getNativeId());
snapshot.setParent(new NamedURI(volume.getId(), volume.getLabel()));
snapshot.setReplicationGroupInstance(repGroupName);
snapshot.setStorageController(volume.getStorageController());
snapshot.setSystemType(volume.getSystemType());
snapshot.setVirtualArray(volume.getVirtualArray());
snapshot.setProtocol(new StringSet());
snapshot.getProtocol().addAll(volume.getProtocol());
NamedURI project = volume.getProject();
// get the project from VPLEX volume as backend volume have different project set with internal flag.
if (Volume.checkForVplexBackEndVolume(_dbClient, volume)) {
Volume vplexVolume = Volume.fetchVplexVolume(_dbClient, volume);
project = vplexVolume.getProject();
}
snapshot.setProject(new NamedURI(project.getURI(), project.getName()));
String existingSnapSnapSetLabel = ControllerUtils.getSnapSetLabelFromExistingSnaps(repGroupName, volume.getStorageController(), _dbClient);
if (null == existingSnapSnapSetLabel) {
log.warn("Not able to find any snapshots with group {}", repGroupName);
existingSnapSnapSetLabel = repGroupName;
}
snapshot.setSnapsetLabel(existingSnapSnapSetLabel);
Set<String> existingLabels = ControllerUtils.getSnapshotLabelsFromExistingSnaps(repGroupName, volume, _dbClient);
LabelFormatFactory labelFormatFactory = new LabelFormatFactory();
LabelFormat labelFormat = labelFormatFactory.getLabelFormat(existingLabels);
snapshot.setLabel(labelFormat.next());
snapshot.setTechnologyType(BlockSnapshot.TechnologyType.NATIVE.name());
_dbClient.createObject(snapshot);
return snapshot;
}
Aggregations