use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume in project coprhd-controller by CoprHD.
the class BaseIngestionRequestContext method findDataObjectByType.
/*
* (non-Javadoc)
*
* @see
* com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.IngestionRequestContext#findObjectAnywhere(java.lang.
* Class, java.net.URI)
*/
@Override
public <T extends DataObject> T findDataObjectByType(Class<T> clazz, URI id, boolean fallbackToDatabase) {
_logger.info("looking for {} object with id {}", clazz.toString(), id);
// check for DataObjects in already-loaded Updated Objects first
DataObject dob = this.findInUpdatedObjects(id);
if (clazz.isInstance(dob)) {
_logger.info("\tfound in updated objects: " + dob.forDisplay());
return clazz.cast(dob);
}
// check for Mirrors/Snapshots/Volumes that have been created
if (clazz.equals(BlockMirror.class) || clazz.equals(Volume.class) || clazz.equals(BlockSnapshot.class)) {
BlockObject bo = this.findCreatedBlockObject(id);
if (clazz.isInstance(bo)) {
_logger.info("\tfound in created objects: " + bo.forDisplay());
return clazz.cast(bo);
}
}
// search for any already-loaded UnManagedVolume instances
if (clazz.equals(UnManagedVolume.class)) {
for (UnManagedVolume umv : this.findAllUnManagedVolumesToBeDeleted()) {
if (umv != null && umv.getId().equals(id)) {
_logger.info("\tfound in volumes to be deleted: " + umv.forDisplay());
return clazz.cast(umv);
}
}
VolumeIngestionContext currentVolumeContext = getVolumeContext();
if (currentVolumeContext != null && currentVolumeContext instanceof IngestionRequestContext) {
UnManagedVolume umv = currentVolumeContext.getUnmanagedVolume();
if (umv != null && umv.getId().equals(id)) {
_logger.info("\tfound in current volume context: " + umv.forDisplay());
return clazz.cast(umv);
}
}
for (VolumeIngestionContext volumeContext : this.getProcessedUnManagedVolumeMap().values()) {
if (volumeContext instanceof IngestionRequestContext) {
UnManagedVolume umv = volumeContext.getUnmanagedVolume();
if (umv != null && umv.getId().equals(id)) {
_logger.info("\tfound in already-processed volume context: " + umv.forDisplay());
return clazz.cast(umv);
}
}
}
}
// search for any already-loaded UnManagedProtectionSet instances
if (clazz.equals(UnManagedProtectionSet.class)) {
VolumeIngestionContext currentVolumeContext = getVolumeContext();
if (currentVolumeContext != null && currentVolumeContext instanceof RecoverPointVolumeIngestionContext) {
UnManagedProtectionSet umpset = ((RecoverPointVolumeIngestionContext) currentVolumeContext).getUnManagedProtectionSetLocal();
if (umpset != null && umpset.getId().equals(id)) {
_logger.info("\tfound in current volume context: " + umpset.forDisplay());
return clazz.cast(umpset);
}
}
for (VolumeIngestionContext volumeContext : this.getProcessedUnManagedVolumeMap().values()) {
if (volumeContext != null && volumeContext instanceof RecoverPointVolumeIngestionContext) {
UnManagedProtectionSet umpset = ((RecoverPointVolumeIngestionContext) volumeContext).getUnManagedProtectionSetLocal();
if (umpset != null && umpset.getId().equals(id)) {
_logger.info("\tfound in already-processed volume context: " + umpset.forDisplay());
return clazz.cast(umpset);
}
}
}
}
if (fallbackToDatabase) {
// if we still haven't found it, load it from the database
T dataObject = _dbClient.queryObject(clazz, id);
if (dataObject != null) {
_logger.info("\tloaded object from database: " + dataObject.forDisplay());
return clazz.cast(dataObject);
}
}
return null;
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume in project coprhd-controller by CoprHD.
the class BaseIngestionRequestContext method findAllUnManagedVolumesToBeDeleted.
/*
* (non-Javadoc)
*
* @see
* com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.IngestionRequestContext#findAllProcessedUnManagedVolumes
* ()
*/
@Override
public List<UnManagedVolume> findAllUnManagedVolumesToBeDeleted() {
_logger.info("assembling a List of all unmanaged volumes to be deleted");
List<UnManagedVolume> allUnManagedVolumesToBeDeleted = new ArrayList<UnManagedVolume>();
_logger.info("\tadding local unmanaged volumes to be deleted: " + this.getUnManagedVolumesToBeDeleted());
allUnManagedVolumesToBeDeleted.addAll(this.getUnManagedVolumesToBeDeleted());
VolumeIngestionContext currentVolumeContext = getVolumeContext();
if (currentVolumeContext != null && currentVolumeContext instanceof IngestionRequestContext) {
for (UnManagedVolume unmanagedSubVolume : ((IngestionRequestContext) currentVolumeContext).getUnManagedVolumesToBeDeleted()) {
_logger.info("\t\tadding current volume context UnManagedVolume {}", unmanagedSubVolume.forDisplay());
allUnManagedVolumesToBeDeleted.add(unmanagedSubVolume);
}
}
for (VolumeIngestionContext volumeContext : this.getProcessedUnManagedVolumeMap().values()) {
if (volumeContext instanceof IngestionRequestContext) {
for (UnManagedVolume unmanagedSubVolume : ((IngestionRequestContext) volumeContext).getUnManagedVolumesToBeDeleted()) {
_logger.info("\t\tadding sub context UnManagedVolume {}", unmanagedSubVolume.forDisplay());
allUnManagedVolumesToBeDeleted.add(unmanagedSubVolume);
}
}
}
return allUnManagedVolumesToBeDeleted;
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume in project coprhd-controller by CoprHD.
the class RecoverPointVolumeIngestionContext method commit.
/*
* (non-Javadoc)
*
* @see com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.VolumeIngestionContext#commit()
*/
@Override
public void commit() {
_logger.info("persisting RecoverPoint backend for volume " + getUnmanagedVolume().forDisplay());
// commit the basic IngestionRequestContext collections
for (BlockObject bo : getObjectsIngestedByExportProcessing()) {
_logger.info("Creating BlockObject {} (hash {})", bo.forDisplay(), bo.hashCode());
_dbClient.createObject(bo);
}
for (BlockObject bo : getBlockObjectsToBeCreatedMap().values()) {
_logger.info("Creating BlockObject {} (hash {})", bo.forDisplay(), bo.hashCode());
_dbClient.createObject(bo);
}
for (Set<DataObject> createdObjects : getDataObjectsToBeCreatedMap().values()) {
if (createdObjects != null && !createdObjects.isEmpty()) {
for (DataObject dob : createdObjects) {
_logger.info("Creating DataObject {} (hash {})", dob.forDisplay(), dob.hashCode());
_dbClient.createObject(dob);
}
}
}
for (Set<DataObject> updatedObjects : getDataObjectsToBeUpdatedMap().values()) {
if (updatedObjects != null && !updatedObjects.isEmpty()) {
for (DataObject dob : updatedObjects) {
if (dob.getInactive()) {
_logger.info("Deleting DataObject {} (hash {})", dob.forDisplay(), dob.hashCode());
} else {
_logger.info("Updating DataObject {} (hash {})", dob.forDisplay(), dob.hashCode());
}
_dbClient.updateObject(dob);
}
}
}
for (UnManagedVolume umv : getUnManagedVolumesToBeDeleted()) {
_logger.info("Deleting UnManagedVolume {} (hash {})", umv.forDisplay(), umv.hashCode());
_dbClient.updateObject(umv);
}
// now commit the RecoverPoint specific data
if (_managedSourceVolumesToUpdate != null) {
_logger.info("Updating RP Source Volumes: " + _managedSourceVolumesToUpdate);
_dbClient.updateObject(_managedSourceVolumesToUpdate);
}
if (_unmanagedSourceVolumesToUpdate != null) {
_logger.info("Updating RP Source UnManagedVolumes: " + _unmanagedSourceVolumesToUpdate);
_dbClient.updateObject(_unmanagedSourceVolumesToUpdate);
}
if (_unmanagedTargetVolumesToUpdate != null) {
_logger.info("Updating RP Target UnManagedVolumes: " + _unmanagedTargetVolumesToUpdate);
_dbClient.updateObject(_unmanagedTargetVolumesToUpdate);
}
// commit the ProtectionSet, if created, and remove the UnManagedProtectionSet
ProtectionSet managedProtectionSet = getManagedProtectionSet();
if (null != managedProtectionSet) {
if (getManagedBlockObject() != null) {
managedProtectionSet.getVolumes().add(_managedBlockObject.getId().toString());
}
_logger.info("Creating ProtectionSet {} (hash {})", managedProtectionSet.forDisplay(), managedProtectionSet.hashCode());
_dbClient.createObject(managedProtectionSet);
// the protection set was created, so delete the unmanaged one
_logger.info("Deleting UnManagedProtectionSet {} (hash {})", _unManagedProtectionSet.forDisplay(), _unManagedProtectionSet.hashCode());
_dbClient.removeObject(_unManagedProtectionSet);
}
// commit the BlockConsistencyGroup, if created
if (null != getManagedBlockConsistencyGroup()) {
_logger.info("Creating BlockConsistencyGroup {} (hash {})", _managedBlockConsistencyGroup.forDisplay(), _managedBlockConsistencyGroup.hashCode());
_dbClient.createObject(_managedBlockConsistencyGroup);
}
for (Entry<ExportGroup, Boolean> entry : getRpExportGroupMap().entrySet()) {
ExportGroup exportGroup = entry.getKey();
boolean exportGroupIsCreated = entry.getValue();
if (exportGroupIsCreated) {
_logger.info("Creating ExportGroup {} (hash {})", exportGroup.forDisplay(), exportGroup.hashCode());
_dbClient.createObject(exportGroup);
} else {
_logger.info("Updating ExportGroup {} (hash {})", exportGroup.forDisplay(), exportGroup.hashCode());
_dbClient.updateObject(exportGroup);
}
}
super.commit();
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume in project coprhd-controller by CoprHD.
the class VplexVolumeIngestionContext method createVplexMirrorObjects.
/**
* Create a VplexMirror database object if a VPLEX native mirror is present.
* This should be called after the parent virtual volume has already been ingested.
*
* @param context the VplexBackendIngestionContext
* @param virtualVolume the ingested virtual volume's Volume object.
*/
private void createVplexMirrorObjects() {
if (!getUnmanagedVplexMirrors().isEmpty()) {
Volume virtualVolume = (Volume) _parentRequestContext.getProcessedBlockObject(getUnmanagedVirtualVolume().getNativeGuid());
_logger.info("creating VplexMirror object for virtual volume " + virtualVolume.getLabel());
for (Entry<UnManagedVolume, String> entry : getUnmanagedVplexMirrors().entrySet()) {
// find mirror and create a VplexMirror object
BlockObject mirror = getBlockObjectsToBeCreatedMap().get(entry.getKey().getNativeGuid().replace(VolumeIngestionUtil.UNMANAGEDVOLUME, VolumeIngestionUtil.VOLUME));
if (null != mirror) {
_logger.info("processing mirror " + mirror.getLabel());
if (mirror instanceof Volume) {
Volume mirrorVolume = (Volume) mirror;
// create VplexMirror set all the basic properties
VplexMirror vplexMirror = new VplexMirror();
vplexMirror.setId(URIUtil.createId(VplexMirror.class));
vplexMirror.setCapacity(mirrorVolume.getCapacity());
vplexMirror.setLabel(mirrorVolume.getLabel());
vplexMirror.setNativeId(entry.getValue());
// For Vplex virtual volumes set allocated capacity to 0 (cop-18608)
vplexMirror.setAllocatedCapacity(0L);
vplexMirror.setProvisionedCapacity(mirrorVolume.getProvisionedCapacity());
vplexMirror.setSource(new NamedURI(virtualVolume.getId(), virtualVolume.getLabel()));
vplexMirror.setStorageController(virtualVolume.getStorageController());
vplexMirror.setTenant(mirrorVolume.getTenant());
vplexMirror.setThinPreAllocationSize(mirrorVolume.getThinVolumePreAllocationSize());
vplexMirror.setThinlyProvisioned(mirrorVolume.getThinlyProvisioned());
vplexMirror.setVirtualArray(mirrorVolume.getVirtualArray());
vplexMirror.setVirtualPool(mirrorVolume.getVirtualPool());
// set the associated volume for this VplexMirror
StringSet associatedVolumes = new StringSet();
associatedVolumes.add(mirrorVolume.getId().toString());
vplexMirror.setAssociatedVolumes(associatedVolumes);
// VplexMirror will have the same project
// as the virtual volume (i.e., the front-end project)
// but the mirror backend will have the backend project
vplexMirror.setProject(new NamedURI(getFrontendProject().getId(), mirrorVolume.getLabel()));
mirrorVolume.setProject(new NamedURI(getBackendProject().getId(), mirrorVolume.getLabel()));
// update flags on mirror volume
Set<DataObject> updatedObjects = getDataObjectsToBeUpdatedMap().get(mirrorVolume.getNativeGuid());
if (updatedObjects == null) {
updatedObjects = new HashSet<DataObject>();
getDataObjectsToBeUpdatedMap().put(mirrorVolume.getNativeGuid(), updatedObjects);
}
VolumeIngestionUtil.clearInternalFlags(this, mirrorVolume, updatedObjects, _dbClient);
// VPLEX backend volumes should still have the INTERNAL_OBJECT flag
mirrorVolume.addInternalFlags(Flag.INTERNAL_OBJECT);
// deviceLabel will be the very last part of the native guid
String[] devicePathParts = entry.getValue().split("/");
String deviceName = devicePathParts[devicePathParts.length - 1];
vplexMirror.setDeviceLabel(deviceName);
// save the new VplexMirror & persist backend & updated objects
getCreatedVplexMirrors().add(vplexMirror);
// set mirrors property on the parent virtual volume
StringSet mirrors = virtualVolume.getMirrors();
if (mirrors == null) {
mirrors = new StringSet();
}
mirrors.add(vplexMirror.getId().toString());
virtualVolume.setMirrors(mirrors);
}
}
}
}
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume in project coprhd-controller by CoprHD.
the class RemoteReplicationIngestor method runRemoteReplicationStepsOnTarget.
/**
* If unmanaged volume is a Target Volume, then 1. Find if source is ingested 2. If yes, then
* find whether expected targets of this source had been ingested already excluding the current
* target. 3. If yes, establish links between source and targets. 4. If not,then make sure
* unmanaged volume hasn't been deleted.
*
* @param unManagedVolume
* @param volume
* @param unManagedVolumes
* @param type
* @return
*/
@SuppressWarnings("deprecation")
private static boolean runRemoteReplicationStepsOnTarget(UnManagedVolume unManagedVolume, Volume volume, List<UnManagedVolume> unManagedVolumes, String type, DbClient dbClient) {
boolean removeUnManagedVolume = false;
StringSetMap unManagedVolumeInformation = unManagedVolume.getVolumeInformation();
String sourceUnManagedVolumeId = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.REMOTE_MIRROR_SOURCE_VOLUME.toString(), unManagedVolumeInformation);
_logger.info("Type {} Source Native Guid {}", type, sourceUnManagedVolumeId);
String sourceVolumeId = sourceUnManagedVolumeId.replace(VolumeIngestionUtil.UNMANAGEDVOLUME, VolumeIngestionUtil.VOLUME);
List<URI> sourceUris = dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVolumeNativeGuidConstraint(sourceVolumeId));
String copyMode = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.REMOTE_COPY_MODE.toString(), unManagedVolumeInformation);
String raGroup = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.REMOTE_MIRROR_RDF_GROUP.toString(), unManagedVolumeInformation);
volume.setSrdfCopyMode(copyMode);
volume.setSrdfGroup(URI.create(raGroup));
if (sourceUris.isEmpty()) {
_logger.info("Source {} Not found for target {}", sourceVolumeId, volume.getId());
} else {
// check whether all targets of the source are ingested
List<URI> sourceUnmanagedUris = dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVolumeInfoNativeIdConstraint(sourceUnManagedVolumeId));
if (!sourceUnmanagedUris.isEmpty()) {
UnManagedVolume sourceUnManagedVolume = dbClient.queryObject(UnManagedVolume.class, sourceUnmanagedUris.get(0));
if (null != sourceUnManagedVolume) {
StringSet targetUnManagedVolumeGuids = sourceUnManagedVolume.getVolumeInformation().get(SupportedVolumeInformation.REMOTE_MIRRORS.toString());
if (null != targetUnManagedVolumeGuids && !targetUnManagedVolumeGuids.isEmpty()) {
StringSet targetVolumeNativeGuids = VolumeIngestionUtil.getListofVolumeIds(targetUnManagedVolumeGuids);
List<URI> targetUris = VolumeIngestionUtil.getVolumeUris(targetVolumeNativeGuids, dbClient);
targetUris.add(volume.getId());
_logger.info("Expected targets Size {} , found {} ", targetUnManagedVolumeGuids.size(), targetUris.size());
_logger.debug("Expected Targets {} : Found {}", Joiner.on("\t").join(targetVolumeNativeGuids), Joiner.on("\t").join(targetUris));
List<Volume> modifiedVolumes = new ArrayList<Volume>();
if (targetUris.size() == targetUnManagedVolumeGuids.size()) {
// if all other targets are ingested, then
Volume sourceVolume = dbClient.queryObject(Volume.class, sourceUris.get(0));
// check whether the source Volume's VPool is actually having this target Volume's varray
// specified as remote
VirtualPool sourceVPool = dbClient.queryObject(VirtualPool.class, sourceVolume.getVirtualPool());
Map<URI, VpoolRemoteCopyProtectionSettings> settings = sourceVPool.getRemoteProtectionSettings(sourceVPool, dbClient);
if (null == settings || settings.size() == 0 || !settings.containsKey(volume.getVirtualArray())) {
_logger.info("Target Volume's VArray {} is not matching already ingested source volume virtual pool's remote VArray ", volume.getVirtualArray());
return false;
}
sourceVolume.setSrdfTargets(VolumeIngestionUtil.convertUrisToStrings(targetUris));
_logger.info("Clearing internal flag for source volume {} found", sourceVolume.getNativeGuid());
sourceVolume.clearInternalFlags(INTERNAL_VOLUME_FLAGS);
_logger.debug("Set srdf target for source volume {} found", sourceVolume.getId());
modifiedVolumes.add(sourceVolume);
// source unmanagedVolume
sourceUnManagedVolume.setInactive(true);
unManagedVolumes.add(sourceUnManagedVolume);
// this target unmanaged volume
volume.setSrdfParent(new NamedURI(sourceVolume.getId(), sourceVolume.getLabel()));
_logger.debug("target volume set parent", volume.getId());
removeUnManagedVolume = true;
// handle other target volumes
List<Volume> targetVolumes = dbClient.queryObject(Volume.class, targetUris);
for (Volume targetVolume : targetVolumes) {
_logger.debug("Set parent for remaining target volume {}", targetVolume.getId());
targetVolume.setSrdfParent(new NamedURI(sourceVolume.getId(), sourceVolume.getLabel()));
targetVolume.clearInternalFlags(INTERNAL_VOLUME_FLAGS);
}
modifiedVolumes.addAll(targetVolumes);
// target unmanaged volumes
List<UnManagedVolume> targetUnManagedVolumes = dbClient.queryObject(UnManagedVolume.class, VolumeIngestionUtil.getUnManagedVolumeUris(targetUnManagedVolumeGuids, dbClient));
for (UnManagedVolume targetUnManagedVol : targetUnManagedVolumes) {
_logger.debug("Set Target unmanaged volume inactive {}", targetUnManagedVol.getId());
targetUnManagedVol.setInactive(true);
unManagedVolumes.add(targetUnManagedVol);
}
dbClient.persistObject(modifiedVolumes);
_logger.info("Target Volume successfully ingested with remote replication links", volume.getNativeGuid());
} else {
// set volume flag to false
_logger.info("Expected Targets not found for source Volume {}", sourceUnManagedVolumeId);
}
} else {
_logger.info("Targets information not found on source volume {}." + "This could happen when parallel ingests are tried or the actual volume got deleted on array.", sourceUnManagedVolumeId);
}
}
}
}
return removeUnManagedVolume;
}
Aggregations