/** * Creates the BlockObject BlockSnapshot data. * * @param name * @param numSnapshots * @throws Exception */ private void prepareBlockSnapshotData(String name, int numSnapshots) throws Exception { // Create the volume for the snapshots Volume volume = new Volume(); URI volumeURI = URIUtil.createId(Volume.class); StorageSystem storageSystem = createStorageSystem(false); volume.setId(volumeURI); volume.setStorageController(storageSystem.getId()); String volName = "blockSnapshotVolume"; volume.setLabel(volName); BlockConsistencyGroup cg = createBlockConsistencyGroup( "blockSnapshotConsistencyGroup", storageSystem.getId(), Types.LOCAL.name(), true); volume.setConsistencyGroup(cg.getId()); _dbClient.createObject(volume); for (int i = 1; i <= numSnapshots; i++) { BlockSnapshot blockSnapshot = new BlockSnapshot(); URI blockSnapshotURI = URIUtil.createId(BlockSnapshot.class); blockSnapshotURIs.add(blockSnapshotURI); blockSnapshot.setId(blockSnapshotURI); blockSnapshot.setLabel(name + i); blockSnapshot.setSnapsetLabel(name + i); blockSnapshot.setParent(new NamedURI(volume.getId(), name + i)); blockSnapshot.addConsistencyGroup(cg.getId().toString()); _dbClient.createObject(blockSnapshot); } }
/** * creates snapshot objects * * @param numSnapshots * @param volume * @param name snapshot name */ public void addSnapshots( int numSnapshots, Volume volume, BlockConsistencyGroup cg, ProtectionSet ps, String name) { for (int i = 1; i <= numSnapshots; i++) { BlockSnapshot blockSnapshot = new BlockSnapshot(); URI blockSnapshotURI = URIUtil.createId(BlockSnapshot.class); blockSnapshotURIs.add(blockSnapshotURI); blockSnapshot.setId(blockSnapshotURI); blockSnapshot.setLabel(name + i); blockSnapshot.setSnapsetLabel(name + i); blockSnapshot.setParent(new NamedURI(volume.getId(), name + i)); blockSnapshot.addConsistencyGroup(cg.getId().toString()); blockSnapshot.setProtectionSet(ps.getId()); _dbClient.createObject(blockSnapshot); } }