use of com.emc.storageos.db.client.model.RemoteDirectorGroup in project coprhd-controller by CoprHD.
the class SRDFDeviceController method createNonCGSRDFActiveModeVolumes.
/**
* This method creates steps to add non CG SRDF Active mode volumes in the RDF group.
*
* @param workflow Reference to Workflow
* @param waitFor String waitFor of previous step, we wait on this to complete
* @param sourceDescriptors list of source volume descriptors
* @param targetDescriptors list of target volume descriptors
* @param uriVolumeMap map of volume URI to volume object
*/
protected void createNonCGSRDFActiveModeVolumes(Workflow workflow, String waitFor, List<VolumeDescriptor> sourceDescriptors, List<VolumeDescriptor> targetDescriptors, Map<URI, Volume> uriVolumeMap) {
RemoteDirectorGroup group = getRAGroup(targetDescriptors, uriVolumeMap);
StorageSystem system = dbClient.queryObject(StorageSystem.class, group.getSourceStorageSystemUri());
StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, group.getRemoteStorageSystemUri());
// finding actual volumes from Provider
Set<String> volumesInRDFGroupsOnProvider = findVolumesPartOfRDFGroups(system, group);
if (group.getVolumes() == null) {
group.setVolumes(new StringSet());
}
if ((group.getVolumes().isEmpty() && !volumesInRDFGroupsOnProvider.isEmpty()) || (!group.getVolumes().isEmpty() && volumesInRDFGroupsOnProvider.isEmpty())) {
log.info("RDF Group {} in ViPR DB is not sync with the one on the provider. ", group.getNativeGuid());
clearSourceAndTargetVolumes(sourceDescriptors, targetDescriptors);
throw DeviceControllerException.exceptions.rdfGroupInViprDBNotInSyncWithArray(group.getNativeGuid());
}
if (volumesInRDFGroupsOnProvider.isEmpty() && !SupportedCopyModes.ALL.toString().equalsIgnoreCase(group.getSupportedCopyMode())) {
log.info("RDF Group {} is empty and supported copy mode is {} ", group.getNativeGuid(), group.getSupportedCopyMode());
clearSourceAndTargetVolumes(sourceDescriptors, targetDescriptors);
throw DeviceControllerException.exceptions.rdfGroupInViprDBNotInSyncWithArray(group.getNativeGuid());
}
if (!group.getVolumes().isEmpty()) {
// ViPR Controller should not attempt to suspend them
try {
// The below call will return an error if there is a single volume in the group that does not have an associated Volume URI
List<Volume> volumes = utils.getAssociatedVolumesForSRDFGroup(system, group);
} catch (Exception e) {
log.info("RDF Group {} has devices created outside ViPRController", group.getNativeGuid());
clearSourceAndTargetVolumes(sourceDescriptors, targetDescriptors);
throw DeviceControllerException.exceptions.rdfGroupHasPairsCreatedOutsideViPR(group.getNativeGuid());
}
}
String createSrdfPairStep = null;
if (volumesInRDFGroupsOnProvider.isEmpty() && SupportedCopyModes.ALL.toString().equalsIgnoreCase(group.getSupportedCopyMode())) {
log.info("RA Group {} was empty", group.getId());
createSrdfPairStep = createNonCGSrdfPairStepsOnEmptyGroup(sourceDescriptors, targetDescriptors, group, uriVolumeMap, waitFor, workflow);
} else {
log.info("RA Group {} not empty", group.getId());
createSrdfPairStep = createNonCGSrdfPairStepsOnPopulatedGroup(sourceDescriptors, targetDescriptors, group, uriVolumeMap, waitFor, workflow);
}
// Generate workflow step to refresh source and target system .
String refreshSourceSystemStep = null;
if (null != system) {
refreshSourceSystemStep = addStepToRefreshSystem(CREATE_SRDF_MIRRORS_STEP_GROUP, system, null, createSrdfPairStep, workflow);
}
String refreshTargetSystemStep = null;
if (null != targetSystem) {
refreshTargetSystemStep = addStepToRefreshSystem(CREATE_SRDF_MIRRORS_STEP_GROUP, targetSystem, null, refreshSourceSystemStep, workflow);
}
// Refresh target volume properties
refreshVolumeProperties(targetDescriptors, targetSystem, refreshTargetSystemStep, workflow);
}
use of com.emc.storageos.db.client.model.RemoteDirectorGroup in project coprhd-controller by CoprHD.
the class SRDFDeviceController method generateLocks.
private List<String> generateLocks(List<VolumeDescriptor> volumeDescriptors, Map<URI, Volume> uriVolumeMap) {
// List of resulting locks
List<String> locks = new ArrayList<>();
// Resources for building the locks
Volume firstTarget = getFirstTarget(volumeDescriptors, uriVolumeMap);
Volume source = uriVolumeMap.get(firstTarget.getSrdfParent().getURI());
if (source == null) {
log.error("Source volume was not found: {}", firstTarget.getSrdfParent().getURI());
throw DeviceControllerException.exceptions.invalidObjectNull();
}
StorageSystem sourceSystem = dbClient.queryObject(StorageSystem.class, source.getStorageController());
RemoteDirectorGroup rdfGroup = dbClient.queryObject(RemoteDirectorGroup.class, firstTarget.getSrdfGroup());
// Generate the locks
locks.add(generateRDFGroupLock(sourceSystem, rdfGroup));
return locks;
}
use of com.emc.storageos.db.client.model.RemoteDirectorGroup in project coprhd-controller by CoprHD.
the class SRDFDeviceController method canRemoveSrdfCg.
private boolean canRemoveSrdfCg(Map<URI, Volume> volumeMap) {
Volume targetVol = null;
boolean volumePartOfCG = false;
for (Volume source : volumeMap.values()) {
volumePartOfCG = null != source.getConsistencyGroup();
StringSet targets = source.getSrdfTargets();
if (targets == null) {
return false;
}
for (String target : targets) {
targetVol = dbClient.queryObject(Volume.class, URI.create(target));
break;
}
break;
}
RemoteDirectorGroup group = dbClient.queryObject(RemoteDirectorGroup.class, targetVol.getSrdfGroup());
if (null == group) {
return true;
}
StorageSystem system = getStorageSystem(group.getSourceStorageSystemUri());
Set<String> volumes = findVolumesPartOfRDFGroups(system, group);
if (group.getVolumes() == null) {
group.setVolumes(new StringSet());
}
group.getVolumes().replace(volumes);
log.info("# volumes : {} in RDF Group {} after refresh", Joiner.on(",").join(group.getVolumes()), group.getNativeGuid());
dbClient.persistObject(group);
if (null != volumes && volumes.size() == volumeMap.size() && volumePartOfCG) {
log.info("Deleting all the volumes {} in CG in one attempt", Joiner.on(",").join(volumeMap.keySet()));
return true;
}
return false;
}
Aggregations