Search in sources :

Example 1 with LabelFormatFactory

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;
}
Also used : LabelFormat(com.emc.storageos.volumecontroller.impl.utils.labels.LabelFormat) NamedURI(com.emc.storageos.db.client.model.NamedURI) Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) StringSet(com.emc.storageos.db.client.model.StringSet) LabelFormatFactory(com.emc.storageos.volumecontroller.impl.utils.labels.LabelFormatFactory) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Aggregations

BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 Volume (com.emc.storageos.db.client.model.Volume)1 LabelFormat (com.emc.storageos.volumecontroller.impl.utils.labels.LabelFormat)1 LabelFormatFactory (com.emc.storageos.volumecontroller.impl.utils.labels.LabelFormatFactory)1 URI (java.net.URI)1