use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet in project coprhd-controller by CoprHD.
the class VolumeIngestionUtil method getUnManagedProtectionSetForManagedVolume.
/**
* Get the unmanaged protection set corresponding to the managed volume
*
* @param managedVolume the Volume object to find an UnManagedProtectionSet for
* @param dbClient a reference to the database client
* @return unmanaged protection set
*/
public static UnManagedProtectionSet getUnManagedProtectionSetForManagedVolume(IngestionRequestContext requestContext, BlockObject managedVolume, DbClient dbClient) {
UnManagedProtectionSet umpset = null;
// Find the UnManagedProtectionSet associated with this managed volume
List<UnManagedProtectionSet> umpsets = CustomQueryUtility.getUnManagedProtectionSetByManagedVolumeId(dbClient, managedVolume.getId().toString());
Iterator<UnManagedProtectionSet> umpsetsItr = umpsets.iterator();
if (umpsetsItr.hasNext()) {
umpset = umpsetsItr.next();
}
if (umpset != null) {
DataObject alreadyLoadedUmpset = requestContext.findInUpdatedObjects(umpset.getId());
if (alreadyLoadedUmpset != null && (alreadyLoadedUmpset instanceof UnManagedProtectionSet)) {
umpset = (UnManagedProtectionSet) alreadyLoadedUmpset;
}
}
return umpset;
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet in project coprhd-controller by CoprHD.
the class RPUnManagedObjectDiscoverer method discoverUnManagedObjects.
/**
* Discovers the RP CGs and all the volumes therein. It updates/creates the UnManagedProtectionSet
* objects and updates (if it exists) the UnManagedVolume objects with RP information needed for
* ingestion
*
* @param accessProfile access profile
* @param dbClient db client
* @param partitionManager partition manager
* @throws Exception
*/
public void discoverUnManagedObjects(AccessProfile accessProfile, DbClient dbClient, PartitionManager partitionManager) throws Exception {
this.partitionManager = partitionManager;
log.info("Started discovery of UnManagedVolumes for system {}", accessProfile.getSystemId());
ProtectionSystem protectionSystem = dbClient.queryObject(ProtectionSystem.class, accessProfile.getSystemId());
if (protectionSystem == null) {
log.error("Discovery is not run! Protection System not found: " + accessProfile.getSystemId());
return;
}
RecoverPointClient rp = RPHelper.getRecoverPointClient(protectionSystem);
unManagedCGsInsert = new ArrayList<UnManagedProtectionSet>();
unManagedCGsUpdate = new ArrayList<UnManagedProtectionSet>();
unManagedVolumesToDelete = new ArrayList<UnManagedVolume>();
unManagedVolumesToUpdateByWwn = new HashMap<String, UnManagedVolume>();
unManagedCGsReturnedFromProvider = new HashSet<URI>();
// Get all of the consistency groups (and their volumes) from RP
Set<GetCGsResponse> cgs = rp.getAllCGs();
if (cgs == null) {
log.warn("No CGs were found on protection system: " + protectionSystem.getLabel());
return;
}
// This section of code allows us to cache XIO native GUID to workaround an issue
// with RP's understanding of XIO volume WWNs (128-bit) and the rest of the world's
// understanding of the XIO volume WWN once it's exported (64-bit)
Map<String, String> rpWwnToNativeWwn = new HashMap<String, String>();
List<URI> storageSystemIds = dbClient.queryByType(StorageSystem.class, true);
List<String> storageNativeIdPrefixes = new ArrayList<String>();
if (storageSystemIds != null) {
Iterator<StorageSystem> storageSystemsItr = dbClient.queryIterativeObjects(StorageSystem.class, storageSystemIds);
while (storageSystemsItr.hasNext()) {
StorageSystem storageSystem = storageSystemsItr.next();
if (storageSystem.getSystemType().equalsIgnoreCase(Type.xtremio.name())) {
storageNativeIdPrefixes.add(storageSystem.getNativeGuid());
}
}
}
for (GetCGsResponse cg : cgs) {
try {
log.info("Processing returned CG: " + cg.getCgName());
boolean newCG = false;
// UnManagedProtectionSet native GUID is protection system GUID + consistency group ID
String nativeGuid = protectionSystem.getNativeGuid() + Constants.PLUS + cg.getCgId();
// First check to see if this protection set is already part of our managed DB
if (null != DiscoveryUtils.checkProtectionSetExistsInDB(dbClient, nativeGuid)) {
log.info("Protection Set " + nativeGuid + " already is managed by ViPR, skipping unmanaged discovery");
continue;
}
// Now check to see if the unmanaged CG exists in the database
UnManagedProtectionSet unManagedProtectionSet = DiscoveryUtils.checkUnManagedProtectionSetExistsInDB(dbClient, nativeGuid);
if (null == unManagedProtectionSet) {
log.info("Creating new unmanaged protection set for CG: " + cg.getCgName());
unManagedProtectionSet = new UnManagedProtectionSet();
unManagedProtectionSet.setId(URIUtil.createId(UnManagedProtectionSet.class));
unManagedProtectionSet.setNativeGuid(nativeGuid);
unManagedProtectionSet.setProtectionSystemUri(protectionSystem.getId());
StringSet protectionId = new StringSet();
protectionId.add("" + cg.getCgId());
unManagedProtectionSet.putCGInfo(SupportedCGInformation.PROTECTION_ID.toString(), protectionId);
// Default MP to false until proven otherwise
unManagedProtectionSet.getCGCharacteristics().put(UnManagedProtectionSet.SupportedCGCharacteristics.IS_MP.name(), Boolean.FALSE.toString());
newCG = true;
} else {
log.info("Found existing unmanaged protection set for CG: " + cg.getCgName() + ", using " + unManagedProtectionSet.getId().toString());
}
unManagedCGsReturnedFromProvider.add(unManagedProtectionSet.getId());
// Update the fields for the CG
unManagedProtectionSet.setCgName(cg.getCgName());
unManagedProtectionSet.setLabel(cg.getCgName());
// Indicate whether the CG is in a healthy state or not to ingest.
unManagedProtectionSet.getCGCharacteristics().put(UnManagedProtectionSet.SupportedCGCharacteristics.IS_HEALTHY.name(), cg.getCgState().equals(GetCGStateResponse.HEALTHY) ? Boolean.TRUE.toString() : Boolean.FALSE.toString());
// Indicate whether the CG is sync or async
unManagedProtectionSet.getCGCharacteristics().put(UnManagedProtectionSet.SupportedCGCharacteristics.IS_SYNC.name(), cg.getCgPolicy().synchronous ? Boolean.TRUE.toString() : Boolean.FALSE.toString());
// Fill in RPO type and value information
StringSet rpoType = new StringSet();
rpoType.add(cg.getCgPolicy().rpoType);
unManagedProtectionSet.putCGInfo(SupportedCGInformation.RPO_TYPE.toString(), rpoType);
StringSet rpoValue = new StringSet();
rpoValue.add(cg.getCgPolicy().rpoValue.toString());
unManagedProtectionSet.putCGInfo(SupportedCGInformation.RPO_VALUE.toString(), rpoValue);
if (null == cg.getCopies()) {
log.info("Protection Set " + nativeGuid + " does not contain any copies. Skipping...");
continue;
}
if (null == cg.getRsets()) {
log.info("Protection Set " + nativeGuid + " does not contain any replication sets. Skipping...");
continue;
}
// clean up the existing journal and replicationsets info in the unmanaged protection set, so that updated info is populated
if (!newCG) {
cleanUpUnManagedResources(unManagedProtectionSet, unManagedVolumesToUpdateByWwn, dbClient);
}
// Now map UnManagedVolume objects to the journal and rset (sources/targets) and put RP fields in them
Map<String, String> rpCopyAccessStateMap = new HashMap<String, String>();
mapCgJournals(unManagedProtectionSet, cg, rpCopyAccessStateMap, rpWwnToNativeWwn, storageNativeIdPrefixes, dbClient);
mapCgSourceAndTargets(unManagedProtectionSet, cg, rpCopyAccessStateMap, rpWwnToNativeWwn, storageNativeIdPrefixes, dbClient);
if (newCG) {
unManagedCGsInsert.add(unManagedProtectionSet);
} else {
unManagedCGsUpdate.add(unManagedProtectionSet);
}
} catch (Exception ex) {
log.error("Error processing RP CG {}", cg.getCgName(), ex);
}
}
handlePersistence(dbClient, false);
cleanUp(protectionSystem, dbClient);
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet in project coprhd-controller by CoprHD.
the class RPUnManagedObjectDiscoverer method cleanUp.
/**
* Flushes the rest of the UnManagedProtectionSet changes to the database
* and cleans up (i.e., removes) any UnManagedProtectionSets that no longer
* exist on the RecoverPoint device, but are still in the database.
*
* @param protectionSystem the ProtectionSystem to clean up
* @param dbClient a reference to the database client
*/
private void cleanUp(ProtectionSystem protectionSystem, DbClient dbClient) {
// flush all remaining changes to the database
handlePersistence(dbClient, true);
// remove any UnManagedProtectionSets found in the database
// but no longer found on the RecoverPoint device
Set<URI> umpsetsFoundInDbForProtectionSystem = DiscoveryUtils.getAllUnManagedProtectionSetsForSystem(dbClient, protectionSystem.getId().toString());
SetView<URI> onlyFoundInDb = Sets.difference(umpsetsFoundInDbForProtectionSystem, unManagedCGsReturnedFromProvider);
if (onlyFoundInDb != null && !onlyFoundInDb.isEmpty()) {
Iterator<UnManagedProtectionSet> umpsesToDelete = dbClient.queryIterativeObjects(UnManagedProtectionSet.class, onlyFoundInDb, true);
while (umpsesToDelete.hasNext()) {
UnManagedProtectionSet umps = umpsesToDelete.next();
log.info("Deleting orphaned UnManagedProtectionSet {} no longer found on RecoverPoint device.", umps.getNativeGuid());
dbClient.markForDeletion(umps);
}
}
// reset all tracking collections
unManagedCGsInsert = null;
unManagedCGsUpdate = null;
unManagedVolumesToDelete = null;
unManagedVolumesToUpdateByWwn = null;
unManagedCGsReturnedFromProvider = null;
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet in project coprhd-controller by CoprHD.
the class VolumeIngestionUtil method setupRPCG.
/**
* Sets up the Recover Point CG by creating the protection set, block CG and associating the RP volumes
* with the protection set and the block CG.
* It also clears the RP volumes' replicas' flags.
*
* @param requestContext current unManagedVolume Ingestion context.
* @param umpset Unmanaged protection set for which a protection set has to be created
* @param unManagedVolume the current iterating UnManagedVolume
* @param updatedObjects a Set of DataObjects to be updated in the database at the end of ingestion
* @param dbClient - dbClient reference.
*/
public static void setupRPCG(IngestionRequestContext requestContext, UnManagedProtectionSet umpset, UnManagedVolume unManagedVolume, Set<DataObject> updatedObjects, DbClient dbClient) {
_logger.info("All volumes in UnManagedProtectionSet {} have been ingested, creating RecoverPoint Consistency Group now", umpset.forDisplay());
ProtectionSet pset = VolumeIngestionUtil.findOrCreateProtectionSet(requestContext, unManagedVolume, umpset, dbClient);
BlockConsistencyGroup cg = VolumeIngestionUtil.findOrCreateRPBlockConsistencyGroup(requestContext, unManagedVolume, pset, dbClient);
List<Volume> volumes = new ArrayList<Volume>();
StringSet managedVolumesInDB = new StringSet(pset.getVolumes());
// the RP volumes. If not found in updated objects list, get from the DB.
for (String volumeId : pset.getVolumes()) {
DataObject bo = requestContext.findInUpdatedObjects(URI.create(volumeId));
if (null != bo && bo instanceof Volume) {
_logger.info("\tadding volume object " + bo.forDisplay());
volumes.add((Volume) bo);
managedVolumesInDB.remove(bo.getId().toString());
}
}
if (!managedVolumesInDB.isEmpty()) {
Iterator<Volume> volumesItr = dbClient.queryIterativeObjects(Volume.class, URIUtil.toURIList(managedVolumesInDB));
while (volumesItr.hasNext()) {
Volume volume = volumesItr.next();
_logger.info("\tadding volume object " + volume.forDisplay());
volumes.add(volume);
updatedObjects.add(volume);
managedVolumesInDB.remove(volume.getId().toString());
}
for (String remainingVolumeId : managedVolumesInDB) {
BlockObject bo = requestContext.getRootIngestionRequestContext().findCreatedBlockObject(URI.create(remainingVolumeId));
if (null != bo && bo instanceof Volume) {
_logger.info("\tadding volume object " + bo.forDisplay());
volumes.add((Volume) bo);
}
}
}
VolumeIngestionUtil.decorateRPVolumesCGInfo(volumes, pset, cg, updatedObjects, dbClient, requestContext);
clearPersistedReplicaFlags(requestContext, volumes, updatedObjects, dbClient);
clearReplicaFlagsInIngestionContext(requestContext, volumes, dbClient);
RecoverPointVolumeIngestionContext rpContext = null;
// new objects and deleting the old UnManagedProtectionSet
if (requestContext instanceof RecoverPointVolumeIngestionContext) {
rpContext = (RecoverPointVolumeIngestionContext) requestContext;
} else if (requestContext.getVolumeContext() instanceof RecoverPointVolumeIngestionContext) {
rpContext = (RecoverPointVolumeIngestionContext) requestContext.getVolumeContext();
}
if (rpContext != null) {
_logger.info("setting managed BlockConsistencyGroup on RecoverPoint context {} to {}", rpContext, cg);
rpContext.setManagedBlockConsistencyGroup(cg);
rpContext.getCGObjectsToCreateMap().put(cg.getId().toString(), cg);
_logger.info("setting managed ProtectionSet on RecoverPoint context {} to {}", rpContext, pset);
rpContext.setManagedProtectionSet(pset);
} else {
// In case of replica ingested last, the ingestion context will not be RecoverPointVolumeIngestionContext
if (requestContext.getVolumeContext() instanceof BlockVolumeIngestionContext) {
// In order to decorate the CG properly with all system types, we need to add the CG to the context to be persisted later.
_logger.info("Adding BlockConsistencyGroup {} to the BlockVolumeIngestContext (hash {})", cg.forDisplay(), cg.hashCode());
((BlockVolumeIngestionContext) requestContext.getVolumeContext()).getCGObjectsToCreateMap().put(cg.getId().toString(), cg);
} else {
_logger.info("Persisting BlockConsistencyGroup {} (hash {})", cg.forDisplay(), cg.hashCode());
dbClient.createObject(cg);
}
_logger.info("Persisting ProtectionSet {} (hash {})", pset.forDisplay(), pset.hashCode());
dbClient.createObject(pset);
// the protection set was created, so delete the unmanaged one
_logger.info("Deleting UnManagedProtectionSet {} (hash {})", umpset.forDisplay(), umpset.hashCode());
dbClient.removeObject(umpset);
}
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet in project coprhd-controller by CoprHD.
the class VolumeIngestionUtil method findOrCreateProtectionSet.
/**
* Creates a protection set for the given unmanaged protection set, or finds one first
* if it has already been created in another volume context within the scope of this
* ingestion request.
*
* @param requestContext the current IngestionRequestContext
* @param unManagedVolume the currently ingesting UnManagedVolume
* @param umpset Unmanaged protection set for which a protection set has to be created
* @param dbClient a reference to the database client
* @return newly created protection set
*/
public static ProtectionSet findOrCreateProtectionSet(IngestionRequestContext requestContext, UnManagedVolume unManagedVolume, UnManagedProtectionSet umpset, DbClient dbClient) {
ProtectionSet pset = null;
StringSetMap unManagedCGInformation = umpset.getCGInformation();
String rpProtectionId = PropertySetterUtil.extractValueFromStringSet(SupportedCGInformation.PROTECTION_ID.toString(), unManagedCGInformation);
// if this is a recover point ingestion context, check for an existing PSET in memory
RecoverPointVolumeIngestionContext rpContext = null;
if (requestContext instanceof RecoverPointVolumeIngestionContext) {
rpContext = (RecoverPointVolumeIngestionContext) requestContext;
} else if (requestContext.getVolumeContext(unManagedVolume.getNativeGuid()) instanceof RecoverPointVolumeIngestionContext) {
rpContext = (RecoverPointVolumeIngestionContext) requestContext.getVolumeContext(unManagedVolume.getNativeGuid());
}
if (rpContext != null) {
pset = rpContext.findExistingProtectionSet(umpset.getCgName(), rpProtectionId, umpset.getProtectionSystemUri(), umpset.getNativeGuid());
}
if (pset == null) {
pset = new ProtectionSet();
pset.setId(URIUtil.createId(ProtectionSet.class));
pset.setLabel(umpset.getCgName());
pset.setProtectionId(rpProtectionId);
pset.setProtectionStatus(ProtectionStatus.ENABLED.toString());
pset.setProtectionSystem(umpset.getProtectionSystemUri());
pset.setNativeGuid(umpset.getNativeGuid());
}
if (umpset.getManagedVolumeIds() != null) {
for (String volumeID : umpset.getManagedVolumeIds()) {
// Add all volumes (managed only) to the new protection set
if (pset.getVolumes() == null) {
pset.setVolumes(new StringSet());
}
pset.getVolumes().add(volumeID);
Volume volume = null;
BlockObject bo = requestContext.getRootIngestionRequestContext().findCreatedBlockObject(URI.create(volumeID));
if (bo != null && bo instanceof Volume) {
volume = (Volume) bo;
}
if (volume == null) {
_logger.error("Unable to retrieve volume : " + volumeID + " from database or created volumes. Ignoring in protection set ingestion.");
// so we make sure to add the volume in RecoverPointVolumeIngestionContext.commitBackend
continue;
}
// Set the project value
if (pset.getProject() == null) {
pset.setProject(volume.getProject().getURI());
}
}
}
_logger.info("Created new protection set: " + pset.getId().toString());
return pset;
}
Aggregations