/** * Convenience method that creates VPlex volumes. * * @param name * @param numberOfVols * @param storageSystem * @return */ private List<Volume> createVPlexVolumes(String name, int numberOfVols, URI storageSystem) { List<Volume> volumes = new ArrayList<Volume>(); for (int i = 1; i <= numberOfVols; i++) { Volume vplexVolume = new Volume(); URI vplexVolumeUri = URIUtil.createId(Volume.class); vplexVolumeURIs.add(vplexVolumeUri); vplexVolume.setId(vplexVolumeUri); vplexVolume.setLabel(name + i); vplexVolume.setNativeId( "/clusters/cluster-1/virtual-volumes/device_V000195701573-01E7F_vol" + i); vplexVolume.setStorageController(storageSystem); StringSet associatedVolumes = new StringSet(); associatedVolumes.add("associatedVol1"); vplexVolume.setAssociatedVolumes(associatedVolumes); volumes.add(vplexVolume); } return volumes; }
/** * Creates the RP source volume/journal and the specified number of target/journal volumes. * * @param volumeName * @param numTargets */ private List<Volume> createRpVolumes( String volumeName, int numTargets, ProtectionSet protectionSet, boolean isRpVPlex) { List<Volume> volumes = new ArrayList<Volume>(); StringSet associatedVolumes = new StringSet(); associatedVolumes.add("associatedVol1"); StorageSystem storageSystem = null; if (isRpVPlex) { storageSystem = createStorageSystem(true); } else { storageSystem = createStorageSystem(false); } String rsetName = "RSet-" + volumeName; Volume sourceVolume = new Volume(); URI sourceVolumeURI = URIUtil.createId(Volume.class); volumes.add(sourceVolume); sourceVolume.setId(sourceVolumeURI); sourceVolume.setLabel(volumeName); sourceVolume.setPersonality(Volume.PersonalityTypes.SOURCE.toString()); sourceVolume.setRSetName(rsetName); sourceVolume.setProtectionSet(new NamedURI(protectionSet.getId(), sourceVolume.getLabel())); sourceVolume.setStorageController(storageSystem.getId()); if (isRpVPlex) { sourceVolume.setAssociatedVolumes(associatedVolumes); sourceVolume.setNativeId( "/clusters/cluster-1/virtual-volumes/device_V000195701573-01E7A_vol"); // Create a VPLEX ViPR BlockConsistencyGroup for the source volume BlockConsistencyGroup sourceVolumeCg = createBlockConsistencyGroup( sourceVolume.getLabel() + "-CG", storageSystem.getId(), Types.VPLEX.name(), true); addVolumeToBlockConsistencyGroup(sourceVolumeCg.getId(), sourceVolume); rpVplexVolumeToCgMapping.put(sourceVolumeURI, sourceVolumeCg.getId()); } else { rpVolumeURIs.add(sourceVolumeURI); } _dbClient.createObject(sourceVolume); Volume sourceVolumeJournal = new Volume(); URI sourceVolumeJournalURI = URIUtil.createId(Volume.class); volumes.add(sourceVolumeJournal); sourceVolumeJournal.setId(sourceVolumeJournalURI); sourceVolumeJournal.setLabel(volumeName + RP_SRC_JOURNAL_APPEND); sourceVolumeJournal.setPersonality(Volume.PersonalityTypes.METADATA.toString()); sourceVolumeJournal.setProtectionSet( new NamedURI(protectionSet.getId(), sourceVolumeJournal.getLabel())); sourceVolumeJournal.setStorageController(storageSystem.getId()); if (isRpVPlex) { sourceVolumeJournal.setAssociatedVolumes(associatedVolumes); sourceVolumeJournal.setNativeId( "/clusters/cluster-1/virtual-volumes/device_V000195701573-01E7B_vol"); // Create a VPLEX ViPR BlockConsistencyGroup for the source journal volume BlockConsistencyGroup sourceVolumeJournalCg = createBlockConsistencyGroup( sourceVolumeJournal.getLabel() + "-CG", storageSystem.getId(), Types.VPLEX.name(), true); addVolumeToBlockConsistencyGroup(sourceVolumeJournalCg.getId(), sourceVolumeJournal); rpVplexVolumeToCgMapping.put(sourceVolumeJournalURI, sourceVolumeJournalCg.getId()); } else { rpVolumeURIs.add(sourceVolumeJournalURI); } _dbClient.createObject(sourceVolumeJournal); for (int i = 1; i <= numTargets; i++) { Volume sourceVolumeTarget = new Volume(); URI sourceVolumeTargetURI = URIUtil.createId(Volume.class); volumes.add(sourceVolumeTarget); sourceVolumeTarget.setId(sourceVolumeTargetURI); sourceVolumeTarget.setLabel(volumeName + RP_TGT_APPEND + "vArray" + i); sourceVolumeTarget.setPersonality(Volume.PersonalityTypes.TARGET.toString()); sourceVolumeTarget.setRSetName(rsetName); sourceVolumeTarget.setProtectionSet( new NamedURI(protectionSet.getId(), sourceVolumeTarget.getLabel())); sourceVolumeTarget.setStorageController(storageSystem.getId()); if (isRpVPlex) { sourceVolumeTarget.setAssociatedVolumes(associatedVolumes); sourceVolumeTarget.setNativeId( "/clusters/cluster-2/virtual-volumes/device_V000195701573-01E7C_vol" + i); // Create a VPLEX ViPR BlockConsistencyGroup for the target volume BlockConsistencyGroup sourceVolumeTargetCg = createBlockConsistencyGroup( sourceVolumeTarget.getLabel() + "-CG", storageSystem.getId(), Types.VPLEX.name(), true); addVolumeToBlockConsistencyGroup(sourceVolumeTargetCg.getId(), sourceVolumeTarget); rpVplexVolumeToCgMapping.put(sourceVolumeTargetURI, sourceVolumeTargetCg.getId()); } else { rpVolumeURIs.add(sourceVolumeTargetURI); } _dbClient.createObject(sourceVolumeTarget); Volume sourceVolumeTargetJournal = new Volume(); URI sourceVolumeTargetJournalURI = URIUtil.createId(Volume.class); volumes.add(sourceVolumeTargetJournal); sourceVolumeTargetJournal.setId(sourceVolumeTargetJournalURI); sourceVolumeTargetJournal.setLabel(volumeName + RP_TGT_JOURNAL_APPEND + "vArray" + i); sourceVolumeTargetJournal.setPersonality(Volume.PersonalityTypes.METADATA.toString()); sourceVolumeTargetJournal.setProtectionSet( new NamedURI(protectionSet.getId(), sourceVolumeTargetJournal.getLabel())); sourceVolumeTargetJournal.setStorageController(storageSystem.getId()); if (isRpVPlex) { sourceVolumeTargetJournal.setAssociatedVolumes(associatedVolumes); sourceVolumeTargetJournal.setNativeId( "/clusters/cluster-2/virtual-volumes/device_V000195701573-01ED_vol" + i); // Create a VPLEX ViPR BlockConsistencyGroup for the source target journal volume BlockConsistencyGroup sourceVolumeTargetJournalCg = createBlockConsistencyGroup( sourceVolumeTargetJournal.getLabel() + "-CG", storageSystem.getId(), Types.VPLEX.name(), true); addVolumeToBlockConsistencyGroup( sourceVolumeTargetJournalCg.getId(), sourceVolumeTargetJournal); rpVplexVolumeToCgMapping.put( sourceVolumeTargetJournalURI, sourceVolumeTargetJournalCg.getId()); } else { rpVolumeURIs.add(sourceVolumeTargetJournalURI); } _dbClient.createObject(sourceVolumeTargetJournal); } return volumes; }
/** * Prepares the VPLEX volume copies. * * @param name The base name for the volume. * @param copyCount The total number of copies. * @param copyIndex The index for this copy. * @param size The size for the HA volume. * @param srcVPlexVolume The VPLEX volume being copied. * @param srcProject The project for the VPLEX volume being copied. * @param srcVarray The virtual array for the VPLEX volume being copied. * @param srcVpool The virtual pool for the VPLEX volume being copied. * @param srcSystemURI The VPLEX system URI. * @param primaryVolume The primary volume for the copy. * @param haVolume The HA volume for the copy, or null. * @param taskId The task identifier. * @param volumeDescriptors The list of descriptors. * @return A reference to the prepared VPLEX volume copy. */ private Volume prepareFullCopyVPlexVolume( String name, int copyCount, int copyIndex, long size, Volume srcVPlexVolume, Project srcProject, VirtualArray srcVarray, VirtualPool srcVpool, URI srcSystemURI, Volume primaryVolume, Volume haVolume, String taskId, List<VolumeDescriptor> volumeDescriptors) { // Determine the VPLEX volume copy name. StringBuilder nameBuilder = new StringBuilder(name); if (copyCount > 1) { nameBuilder.append("-"); nameBuilder.append(copyIndex + 1); } // Prepare the VPLEX volume copy. Volume vplexCopyVolume = VPlexBlockServiceApiImpl.prepareVolumeForRequest( size, srcProject, srcVarray, srcVpool, srcSystemURI, NullColumnValueGetter.getNullURI(), nameBuilder.toString(), ResourceOperationTypeEnum.CREATE_VOLUME_FULL_COPY, taskId, _dbClient); // Create a volume descriptor and add it to the passed list. VolumeDescriptor vplexCopyVolumeDescr = new VolumeDescriptor( VolumeDescriptor.Type.VPLEX_VIRT_VOLUME, srcSystemURI, vplexCopyVolume.getId(), null, null); volumeDescriptors.add(vplexCopyVolumeDescr); // Set the associated volumes for this new VPLEX volume copy to // the copy of the backend primary and the newly prepared HA // volume if the VPLEX volume being copied is distributed. vplexCopyVolume.setAssociatedVolumes(new StringSet()); StringSet assocVolumes = vplexCopyVolume.getAssociatedVolumes(); assocVolumes.add(primaryVolume.getId().toString()); if (haVolume != null) { assocVolumes.add(haVolume.getId().toString()); } // Set the VPLEX source volume for the copy. vplexCopyVolume.setAssociatedSourceVolume(srcVPlexVolume.getId()); // Copies always created active. vplexCopyVolume.setSyncActive(Boolean.TRUE); // Persist the copy. _dbClient.persistObject(vplexCopyVolume); return vplexCopyVolume; }