/** * Prepare the ViPR BlockSnapshotSession instance for the pass BlockSnapshot instance. * * @param snapshot A reference to the snapshot. * @return A reference to the newly created snapshot session. */ private BlockSnapshotSession prepareSnapshotSession(BlockSnapshot snapshot) { s_logger.info("Prepare BlockSnapshotSession for snapshot {}", snapshot.getId()); BlockSnapshotSession snapshotSession = new BlockSnapshotSession(); URI snapSessionURI = URIUtil.createId(BlockSnapshotSession.class); snapshotSession.setId(snapSessionURI); snapshotSession.setSessionLabel(getSessionLabelFromSettingsInstance(snapshot)); URI cgURI = snapshot.getConsistencyGroup(); if (NullColumnValueGetter.isNullURI(cgURI)) { snapshotSession.setParent(snapshot.getParent()); snapshotSession.setLabel(snapshot.getLabel()); } else { snapshotSession.setConsistencyGroup(cgURI); snapshotSession.setLabel(snapshot.getSnapsetLabel()); Volume parent = getDbClient().queryObject(Volume.class, snapshot.getParent()); if (parent != null) { snapshotSession.setReplicationGroupInstance(parent.getReplicationGroupInstance()); snapshotSession.setSessionSetName(parent.getReplicationGroupInstance()); } } snapshotSession.setProject(snapshot.getProject()); snapshotSession.setStorageController(snapshot.getStorageController()); snapshotSession.setSessionInstance(snapshot.getSettingsInstance()); StringSet linkedTargets = new StringSet(); linkedTargets.add(snapshot.getId().toString()); snapshotSession.setLinkedTargets(linkedTargets); return snapshotSession; }
/** * Add the application to the volume applicationIds attribute * * @param voluri The volume that will be updated * @param dbClient */ protected void addApplicationToVolume(URI voluri, DbClient dbClient) { Volume volume = dbClient.queryObject(Volume.class, voluri); StringSet applications = volume.getVolumeGroupIds(); if (applications == null) { applications = new StringSet(); } applications.add(getId().toString()); volume.setVolumeGroupIds(applications); dbClient.updateObject(volume); // handle clones StringSet fullCopies = volume.getFullCopies(); List<Volume> fullCopiesToUpdate = new ArrayList<Volume>(); if (fullCopies != null && !fullCopies.isEmpty()) { for (String fullCopyId : fullCopies) { Volume fullCopy = dbClient.queryObject(Volume.class, URI.create(fullCopyId)); if (fullCopy != null && NullColumnValueGetter.isNullValue(fullCopy.getFullCopySetName())) { fullCopy.setFullCopySetName(fullCopy.getReplicationGroupInstance()); fullCopiesToUpdate.add(fullCopy); } } } if (!fullCopiesToUpdate.isEmpty()) { dbClient.updateObject(fullCopiesToUpdate); } }