use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume in project coprhd-controller by CoprHD.
the class VolumeIngestionUtil method findOrCreateRPBlockConsistencyGroup.
/**
* Creates a block consistency group for the given 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 pset the ProtectionSet
* @param dbClient a reference to the database client
* @return a BlockConsistencyGroup for the volume context and ProtectionSet
*/
public static BlockConsistencyGroup findOrCreateRPBlockConsistencyGroup(IngestionRequestContext requestContext, UnManagedVolume unManagedVolume, ProtectionSet pset, DbClient dbClient) {
BlockConsistencyGroup cg = null;
Project project = dbClient.queryObject(Project.class, pset.getProject());
NamedURI projectNamedUri = new NamedURI(pset.getProject(), project.getLabel());
// if this is a recover point ingestion context, check for an existing CG 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) {
cg = rpContext.findExistingBlockConsistencyGroup(pset.getLabel(), projectNamedUri, project.getTenantOrg());
}
// Find the source volume in the protection set so we can set the virtual array in the consistency group
URI varrayId = null;
URI storageSystemId = null;
if (pset.getVolumes() != null) {
for (String volumeIdStr : pset.getVolumes()) {
Volume volume = requestContext.findDataObjectByType(Volume.class, URI.create(volumeIdStr), true);
if (volume != null) {
if (PersonalityTypes.SOURCE.name().equalsIgnoreCase(volume.getPersonality())) {
varrayId = volume.getVirtualArray();
if (volume.isVPlexVolume(dbClient)) {
storageSystemId = volume.getStorageController();
}
}
}
}
}
if (cg == null) {
cg = new BlockConsistencyGroup();
cg.setId(URIUtil.createId(BlockConsistencyGroup.class));
cg.setLabel(pset.getLabel());
cg.setProject(projectNamedUri);
cg.addConsistencyGroupTypes(Types.RP.name());
// By default, the array consistency is false. However later when we iterate over volumes in the BCG and we
// see any replicationGroupInstance information, we'll flip this bit to true. (See decorateRPVolumesCGInfo())
cg.setArrayConsistency(false);
cg.setTenant(project.getTenantOrg());
cg.setVirtualArray(varrayId);
cg.setStorageController(storageSystemId);
_logger.info("Created new block consistency group: " + cg.getId().toString());
}
cg.addSystemConsistencyGroup(pset.getProtectionSystem().toString(), pset.getLabel());
return cg;
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume in project coprhd-controller by CoprHD.
the class ExternalDeviceUnManagedVolumeDiscoverer method updateUnManagedVolumesWithExportData.
/**
* Update unmanaged volumes from export masks with export data.
*
* @param unManagedVolumeNativeIdToUriMap [IN] helper map
* @param unManagedExportMasksToCreate [IN] list of masks with volumes
* @param unManagedExportMasksToUpdate [IN] list of masks with volumes
* @param dbClient reference to db client [IN]
* @param partitionManager partition manager [IN]
*/
private void updateUnManagedVolumesWithExportData(Map<String, URI> unManagedVolumeNativeIdToUriMap, List<UnManagedExportMask> unManagedExportMasksToCreate, List<UnManagedExportMask> unManagedExportMasksToUpdate, DbClient dbClient, PartitionManager partitionManager) {
// update unmanaged volumes with export data
// helper map:
Map<String, List<UnManagedExportMask>> volumeToMasksMap = new HashMap<>();
// key --- volume uri, value: unmanaged masks for this volume.
List<UnManagedVolume> unManagedVolumesToUpdate = new ArrayList<UnManagedVolume>();
// build volume to mask map
for (UnManagedExportMask mask : unManagedExportMasksToUpdate) {
StringSet volumes = mask.getUnmanagedVolumeUris();
for (String volumeUri : volumes) {
List<UnManagedExportMask> volumeMasks = volumeToMasksMap.get(volumeUri);
if (volumeMasks == null) {
volumeMasks = new ArrayList<>();
volumeToMasksMap.put(volumeUri, volumeMasks);
}
volumeMasks.add(mask);
}
}
for (UnManagedExportMask mask : unManagedExportMasksToCreate) {
StringSet volumes = mask.getUnmanagedVolumeUris();
for (String volumeUri : volumes) {
List<UnManagedExportMask> volumeMasks = volumeToMasksMap.get(volumeUri);
if (volumeMasks == null) {
volumeMasks = new ArrayList<>();
volumeToMasksMap.put(volumeUri, volumeMasks);
}
volumeMasks.add(mask);
}
}
for (URI volumeUri : unManagedVolumeNativeIdToUriMap.values()) {
UnManagedVolume volume = dbClient.queryObject(UnManagedVolume.class, volumeUri);
// Clean old export data
volume.getInitiatorNetworkIds().clear();
volume.getInitiatorUris().clear();
volume.getUnmanagedExportMasks().clear();
volume.getVolumeCharacterstics().put(UnManagedVolume.SupportedVolumeCharacterstics.IS_VOLUME_EXPORTED.toString(), FALSE);
volume.getVolumeCharacterstics().put(UnManagedVolume.SupportedVolumeCharacterstics.IS_NONRP_EXPORTED.toString(), FALSE);
List<UnManagedExportMask> volumeMasks = volumeToMasksMap.get(volumeUri.toString());
if (volumeMasks != null && !volumeMasks.isEmpty()) {
// update unmanaged volume with export data
log.info("Updating volume {} with export data: {} .", volume.getNativeGuid(), volumeMasks);
// set to new data
for (UnManagedExportMask mask : volumeMasks) {
volume.getInitiatorNetworkIds().addAll(mask.getKnownInitiatorNetworkIds());
volume.getInitiatorUris().addAll(mask.getKnownInitiatorUris());
volume.getUnmanagedExportMasks().add(mask.getId().toString());
}
volume.getVolumeCharacterstics().put(UnManagedVolume.SupportedVolumeCharacterstics.IS_VOLUME_EXPORTED.toString(), TRUE);
volume.getVolumeCharacterstics().put(UnManagedVolume.SupportedVolumeCharacterstics.IS_NONRP_EXPORTED.toString(), TRUE);
unManagedVolumesToUpdate.add(volume);
} else {
log.info("Volume {} does not have export masks.", volume.getNativeGuid());
}
}
if (!unManagedVolumesToUpdate.isEmpty()) {
partitionManager.updateAndReIndexInBatches(unManagedVolumesToUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_VOLUME);
unManagedVolumesToUpdate.clear();
}
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume in project coprhd-controller by CoprHD.
the class ExternalDeviceUnManagedVolumeDiscoverer method processUnManagedSnapshots.
/**
* Process snapshots of unManaged volume.
* Check if unManaged snapshot should be created and create unManaged volume instance for a snapshot in such a case.
* Add unManaged snapshot to parent volume CG if needed and update the snap with parent volume CG information.
* Gets export information for snapshots and stores it in the provided map.
*
* @param driverVolume driver volume for snap parent volume. [IN]
* @param unManagedParentVolume unManaged parent volume [IN/OUT]
* @param storageSystem storage system [IN]
* @param storagePool storage pool [IN]
* @param unManagedVolumesToCreate list of unmanaged volumes to create [OUT]
* @param unManagedVolumesToUpdate list of unmanaged volumes to update [OUT]
* @param allCurrentUnManagedCgURIs set of unManaged CG uris found in the current discovery [OUT]
* @param unManagedCGToUpdateMap map of unManaged CG GUID to unManaged CG instance [IN/OUT]
* @param unManagedVolumeNativeIdToUriMap map of unmanaged volumes nativeId to their uri [OUT]
* @param hostToUnManagedVolumeExportInfoMap map with export data for unmanaged volumes (including snaps and clones)
* @param driver storage driver [IN]
* @param dbClient reference to db client [IN]
* @return set of URIs for unmanaged snapshots
* @throws Exception
*/
private Set<URI> processUnManagedSnapshots(StorageVolume driverVolume, UnManagedVolume unManagedParentVolume, com.emc.storageos.db.client.model.StorageSystem storageSystem, com.emc.storageos.db.client.model.StoragePool storagePool, List<UnManagedVolume> unManagedVolumesToCreate, List<UnManagedVolume> unManagedVolumesToUpdate, Set<URI> allCurrentUnManagedCgURIs, Map<String, UnManagedConsistencyGroup> unManagedCGToUpdateMap, Map<String, URI> unManagedVolumeNativeIdToUriMap, Map<String, List<HostExportInfo>> hostToUnManagedVolumeExportInfoMap, BlockStorageDriver driver, DbClient dbClient) throws Exception {
log.info("Processing snapshots for volume {} ", unManagedParentVolume.getNativeGuid());
Set<URI> snapshotUris = new HashSet<>();
List<VolumeSnapshot> driverSnapshots = driver.getVolumeSnapshots(driverVolume);
if (driverSnapshots == null || driverSnapshots.isEmpty()) {
log.info("There are no snapshots for volume {} ", unManagedParentVolume.getNativeGuid());
} else {
log.info("Snapshots for unManaged volume {}:" + Joiner.on("\t").join(driverSnapshots), unManagedParentVolume.getNativeGuid());
StringSet unManagedSnaps = new StringSet();
for (VolumeSnapshot driverSnapshot : driverSnapshots) {
String managedSnapNativeGuid = NativeGUIDGenerator.generateNativeGuidForVolumeOrBlockSnapShot(storageSystem.getNativeGuid(), driverSnapshot.getNativeId());
BlockSnapshot systemSnap = DiscoveryUtils.checkBlockSnapshotExistsInDB(dbClient, managedSnapNativeGuid);
if (null != systemSnap) {
log.info("Skipping snapshot {} as it is already managed by the system.", managedSnapNativeGuid);
continue;
}
String unManagedSnapNatvieGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingVolume(storageSystem.getNativeGuid(), driverSnapshot.getNativeId());
UnManagedVolume unManagedSnap = createUnManagedSnapshot(driverSnapshot, unManagedParentVolume, storageSystem, storagePool, unManagedVolumesToCreate, unManagedVolumesToUpdate, dbClient);
snapshotUris.add(unManagedSnap.getId());
unManagedSnaps.add(unManagedSnapNatvieGuid);
// Check if this snap is for a volume in consistency group on device.
String isParentVolumeInCG = unManagedParentVolume.getVolumeCharacterstics().get(UnManagedVolume.SupportedVolumeCharacterstics.IS_VOLUME_ADDED_TO_CONSISTENCYGROUP.toString());
if (isParentVolumeInCG.equals(Boolean.TRUE.toString())) {
// add snapshot to parent volume unManaged consistency group, update snapshot with parent volume CG information.
addObjectToUnManagedConsistencyGroup(storageSystem, driverVolume.getConsistencyGroup(), unManagedSnap, allCurrentUnManagedCgURIs, unManagedCGToUpdateMap, driver, dbClient);
}
// get export data for the snapshot
unManagedVolumeNativeIdToUriMap.put(driverSnapshot.getNativeId(), unManagedSnap.getId());
getSnapshotExportInfo(driver, driverSnapshot, hostToUnManagedVolumeExportInfoMap);
}
if (!unManagedSnaps.isEmpty()) {
// set the HAS_REPLICAS property
unManagedParentVolume.getVolumeCharacterstics().put(UnManagedVolume.SupportedVolumeCharacterstics.HAS_REPLICAS.toString(), TRUE);
StringSetMap unManagedVolumeInformation = unManagedParentVolume.getVolumeInformation();
log.info("New unManaged snaps for unManaged volume {}:" + Joiner.on("\t").join(unManagedSnaps), unManagedParentVolume.getNativeGuid());
if (unManagedVolumeInformation.containsKey(UnManagedVolume.SupportedVolumeInformation.SNAPSHOTS.toString())) {
log.info("Old unManaged snaps for unManaged volume {}:" + Joiner.on("\t").join(unManagedVolumeInformation.get(UnManagedVolume.SupportedVolumeInformation.SNAPSHOTS.toString())), unManagedParentVolume.getNativeGuid());
// replace with new StringSet
unManagedParentVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.SNAPSHOTS.toString(), unManagedSnaps);
log.info("Replaced snaps :" + Joiner.on("\t").join(unManagedVolumeInformation.get(UnManagedVolume.SupportedVolumeInformation.SNAPSHOTS.toString())));
} else {
unManagedParentVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.SNAPSHOTS.toString(), unManagedSnaps);
}
} else {
log.info("All snapshots for volume {} are already managed.", unManagedParentVolume.getNativeGuid());
}
}
return snapshotUris;
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume in project coprhd-controller by CoprHD.
the class ExternalDeviceUnManagedVolumeDiscoverer method createUnManagedClone.
/**
* Create new or update existing unManaged clone with driver clone discovery data.
*
* @param driverClone device clone [IN]
* @param parentUnManagedVolume unmanaged parent volume [IN]
* @param storageSystem storage system [IN]
* @param storagePool storage pool [IN]
* @param unManagedVolumesToCreate list of unmanaged volumes to create [OUT]
* @param unManagedVolumesToUpdate list of unmanaged volumes to update [OUT]
* @param dbClient reference to db client [IN]
* @return unmanaged volume for device clone
*/
private UnManagedVolume createUnManagedClone(VolumeClone driverClone, UnManagedVolume parentUnManagedVolume, com.emc.storageos.db.client.model.StorageSystem storageSystem, com.emc.storageos.db.client.model.StoragePool storagePool, List<UnManagedVolume> unManagedVolumesToCreate, List<UnManagedVolume> unManagedVolumesToUpdate, DbClient dbClient) {
// We process unManaged clone as unManaged volume
boolean newVolume = false;
String unManagedVolumeNatvieGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingVolume(storageSystem.getNativeGuid(), driverClone.getNativeId());
UnManagedVolume unManagedVolume = DiscoveryUtils.checkUnManagedVolumeExistsInDB(dbClient, unManagedVolumeNatvieGuid);
if (null == unManagedVolume) {
unManagedVolume = new UnManagedVolume();
unManagedVolume.setId(URIUtil.createId(UnManagedVolume.class));
unManagedVolume.setNativeGuid(unManagedVolumeNatvieGuid);
unManagedVolume.setStorageSystemUri(storageSystem.getId());
if (driverClone.getWwn() == null) {
unManagedVolume.setWwn(String.format("%s:%s", driverClone.getStorageSystemId(), driverClone.getNativeId()));
} else {
unManagedVolume.setWwn(driverClone.getWwn());
}
newVolume = true;
} else {
// cleanup relationships from previous discoveries, we will set them according to this discovery
// Make sure the unManagedVolume clone object does not contain parent CG information from previous discovery
unManagedVolume.putVolumeCharacterstics(UnManagedVolume.SupportedVolumeCharacterstics.IS_VOLUME_ADDED_TO_CONSISTENCYGROUP.toString(), Boolean.FALSE.toString());
// remove uri of the unManaged CG in the unManaged volume object
unManagedVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.UNMANAGED_CONSISTENCY_GROUP_URI.toString(), new StringSet());
// Clean old data for replication group name
unManagedVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.FULL_COPY_CONSISTENCY_GROUP_NAME.toString(), new StringSet());
// Clear old export mask information
unManagedVolume.getUnmanagedExportMasks().clear();
}
unManagedVolume.setLabel(driverClone.getDeviceLabel());
unManagedVolume.putVolumeCharacterstics(UnManagedVolume.SupportedVolumeCharacterstics.IS_VOLUME_EXPORTED.toString(), FALSE);
// Set these default to false. The individual storage discovery will change them if needed.
unManagedVolume.putVolumeCharacterstics(UnManagedVolume.SupportedVolumeCharacterstics.IS_NONRP_EXPORTED.toString(), FALSE);
unManagedVolume.putVolumeCharacterstics(UnManagedVolume.SupportedVolumeCharacterstics.IS_RECOVERPOINT_ENABLED.toString(), FALSE);
StringSet deviceLabel = new StringSet();
deviceLabel.add(driverClone.getDeviceLabel());
unManagedVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.DEVICE_LABEL.toString(), deviceLabel);
if (driverClone.getAccessStatus() != null) {
StringSet accessState = new StringSet();
accessState.add(driverClone.getAccessStatus().toString());
unManagedVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.ACCESS.toString(), accessState);
}
StringSet systemTypes = new StringSet();
systemTypes.add(storageSystem.getSystemType());
unManagedVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.SYSTEM_TYPE.toString(), systemTypes);
StringSet nativeId = new StringSet();
nativeId.add(driverClone.getNativeId());
unManagedVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.NATIVE_ID.toString(), nativeId);
unManagedVolume.putVolumeCharacterstics(UnManagedVolume.SupportedVolumeCharacterstics.IS_INGESTABLE.toString(), TRUE);
unManagedVolume.putVolumeCharacterstics(UnManagedVolume.SupportedVolumeCharacterstics.IS_THINLY_PROVISIONED.toString(), driverClone.getThinlyProvisioned().toString());
unManagedVolume.putVolumeCharacterstics(UnManagedVolume.SupportedVolumeCharacterstics.IS_FULL_COPY.toString(), TRUE);
StringSet parentVol = new StringSet();
parentVol.add(parentUnManagedVolume.getNativeGuid());
unManagedVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.LOCAL_REPLICA_SOURCE_VOLUME.toString(), parentVol);
StringSet isSyncActive = new StringSet();
isSyncActive.add(TRUE);
unManagedVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.IS_SYNC_ACTIVE.toString(), isSyncActive);
StringSet isReadOnly = new StringSet();
Boolean readOnly = Boolean.FALSE;
if (driverClone.getAccessStatus() != null) {
readOnly = (driverClone.getAccessStatus().toString()).equals(StorageObject.AccessStatus.READ_ONLY.toString()) ? Boolean.TRUE : Boolean.FALSE;
}
isReadOnly.add(readOnly.toString());
unManagedVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.IS_READ_ONLY.toString(), isReadOnly);
StringSet techType = new StringSet();
techType.add(BlockSnapshot.TechnologyType.NATIVE.toString());
unManagedVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.TECHNOLOGY_TYPE.toString(), techType);
// set clone consistency group information in the unmanged clone object
String isParentVolumeInCG = parentUnManagedVolume.getVolumeCharacterstics().get(UnManagedVolume.SupportedVolumeCharacterstics.IS_VOLUME_ADDED_TO_CONSISTENCYGROUP.toString());
if (isParentVolumeInCG.equals(Boolean.TRUE.toString())) {
// set clone consistency group name
if (driverClone.getConsistencyGroup() != null && !driverClone.getConsistencyGroup().isEmpty()) {
StringSet cloneCgName = new StringSet();
cloneCgName.add(driverClone.getConsistencyGroup());
unManagedVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.FULL_COPY_CONSISTENCY_GROUP_NAME.toString(), cloneCgName);
}
}
unManagedVolume.setStoragePoolUri(storagePool.getId());
StringSet pools = new StringSet();
pools.add(storagePool.getId().toString());
unManagedVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.STORAGE_POOL.toString(), pools);
StringSet driveTypes = storagePool.getSupportedDriveTypes();
if (null != driveTypes) {
unManagedVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.DISK_TECHNOLOGY.toString(), driveTypes);
}
StringSet provCapacity = new StringSet();
provCapacity.add(String.valueOf(driverClone.getProvisionedCapacity()));
unManagedVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.PROVISIONED_CAPACITY.toString(), provCapacity);
StringSet allocatedCapacity = new StringSet();
allocatedCapacity.add(String.valueOf(driverClone.getAllocatedCapacity()));
unManagedVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.ALLOCATED_CAPACITY.toString(), allocatedCapacity);
StringSet replicaState = new StringSet();
replicaState.add(driverClone.getReplicationState().toString());
unManagedVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.REPLICA_STATE.toString(), replicaState);
StringSet accessStatus = new StringSet();
accessStatus.add(driverClone.getAccessStatus().toString());
unManagedVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.ACCESS.toString(), accessStatus);
// Set matched vpools the same as parent.
StringSet parentMatchedVPools = parentUnManagedVolume.getSupportedVpoolUris();
if (null != parentMatchedVPools) {
log.info("Parent Matched Virtual Pools : {}", Joiner.on("\t").join(parentMatchedVPools));
}
if (null == parentMatchedVPools || parentMatchedVPools.isEmpty()) {
// Clean all vpools as no matching vpools found.
unManagedVolume.getSupportedVpoolUris().clear();
} else {
// replace with new StringSet
unManagedVolume.getSupportedVpoolUris().replace(parentMatchedVPools);
log.info("Replaced Virtual Pools :{}", Joiner.on("\t").join(unManagedVolume.getSupportedVpoolUris()));
}
if (newVolume) {
unManagedVolumesToCreate.add(unManagedVolume);
} else {
unManagedVolumesToUpdate.add(unManagedVolume);
}
return unManagedVolume;
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume in project coprhd-controller by CoprHD.
the class ExternalDeviceUnManagedVolumeDiscoverer method createUnManagedSnapshot.
/**
* Create new or update existing unManaged snapshot with driver snapshot discovery data.
*
* @param driverSnapshot device snap [IN]
* @param parentUnManagedVolume unmanaged parent volume [IN]
* @param storageSystem storage system [IN]
* @param storagePool storage pool [IN]
* @param unManagedVolumesToCreate list of unmanaged volumes to create [OUT]
* @param unManagedVolumesToUpdate list of unmanaged volumes to update [OUT]
* @param dbClient reference to db client [IN]
* @return unmanaged volume for device snapshot
*/
private UnManagedVolume createUnManagedSnapshot(VolumeSnapshot driverSnapshot, UnManagedVolume parentUnManagedVolume, com.emc.storageos.db.client.model.StorageSystem storageSystem, com.emc.storageos.db.client.model.StoragePool storagePool, List<UnManagedVolume> unManagedVolumesToCreate, List<UnManagedVolume> unManagedVolumesToUpdate, DbClient dbClient) {
// We process unManaged snapshot as unManaged volume
boolean newVolume = false;
String unManagedVolumeNatvieGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingVolume(storageSystem.getNativeGuid(), driverSnapshot.getNativeId());
UnManagedVolume unManagedVolume = DiscoveryUtils.checkUnManagedVolumeExistsInDB(dbClient, unManagedVolumeNatvieGuid);
if (null == unManagedVolume) {
unManagedVolume = new UnManagedVolume();
unManagedVolume.setId(URIUtil.createId(UnManagedVolume.class));
unManagedVolume.setNativeGuid(unManagedVolumeNatvieGuid);
unManagedVolume.setStorageSystemUri(storageSystem.getId());
if (driverSnapshot.getWwn() == null) {
unManagedVolume.setWwn(String.format("%s:%s", driverSnapshot.getStorageSystemId(), driverSnapshot.getNativeId()));
} else {
unManagedVolume.setWwn(driverSnapshot.getWwn());
}
newVolume = true;
} else {
// cleanup relationships from previous discoveries, we will set them according to this discovery
// Make sure the unManagedVolume snapshot object does not contain parent CG information from previous discovery
unManagedVolume.putVolumeCharacterstics(UnManagedVolume.SupportedVolumeCharacterstics.IS_VOLUME_ADDED_TO_CONSISTENCYGROUP.toString(), Boolean.FALSE.toString());
// remove uri of the unManaged CG in the unManaged volume object
unManagedVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.UNMANAGED_CONSISTENCY_GROUP_URI.toString(), new StringSet());
// Clean old data for replication group name
unManagedVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.SNAPSHOT_CONSISTENCY_GROUP_NAME.toString(), new StringSet());
// Clear old export mask information
unManagedVolume.getUnmanagedExportMasks().clear();
}
unManagedVolume.setLabel(driverSnapshot.getDeviceLabel());
Boolean isVolumeExported = false;
unManagedVolume.putVolumeCharacterstics(UnManagedVolume.SupportedVolumeCharacterstics.IS_VOLUME_EXPORTED.toString(), isVolumeExported.toString());
// Set these default to false. The individual storage discovery will change them if needed.
unManagedVolume.putVolumeCharacterstics(UnManagedVolume.SupportedVolumeCharacterstics.IS_NONRP_EXPORTED.toString(), FALSE);
unManagedVolume.putVolumeCharacterstics(UnManagedVolume.SupportedVolumeCharacterstics.IS_RECOVERPOINT_ENABLED.toString(), FALSE);
StringSet deviceLabel = new StringSet();
deviceLabel.add(driverSnapshot.getDeviceLabel());
unManagedVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.DEVICE_LABEL.toString(), deviceLabel);
if (driverSnapshot.getAccessStatus() != null) {
StringSet accessState = new StringSet();
accessState.add(driverSnapshot.getAccessStatus().toString());
unManagedVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.ACCESS.toString(), accessState);
}
StringSet systemTypes = new StringSet();
systemTypes.add(storageSystem.getSystemType());
unManagedVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.SYSTEM_TYPE.toString(), systemTypes);
StringSet nativeId = new StringSet();
nativeId.add(driverSnapshot.getNativeId());
unManagedVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.NATIVE_ID.toString(), nativeId);
unManagedVolume.putVolumeCharacterstics(UnManagedVolume.SupportedVolumeCharacterstics.IS_INGESTABLE.toString(), TRUE);
unManagedVolume.putVolumeCharacterstics(UnManagedVolume.SupportedVolumeCharacterstics.IS_SNAP_SHOT.toString(), TRUE);
StringSet parentVol = new StringSet();
parentVol.add(parentUnManagedVolume.getNativeGuid());
unManagedVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.LOCAL_REPLICA_SOURCE_VOLUME.toString(), parentVol);
StringSet isSyncActive = new StringSet();
isSyncActive.add(TRUE);
unManagedVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.IS_SYNC_ACTIVE.toString(), isSyncActive);
StringSet isReadOnly = new StringSet();
Boolean readOnly = Boolean.FALSE;
if (driverSnapshot.getAccessStatus() != null) {
readOnly = (driverSnapshot.getAccessStatus().toString()).equals(StorageObject.AccessStatus.READ_ONLY.toString()) ? Boolean.TRUE : Boolean.FALSE;
}
isReadOnly.add(readOnly.toString());
unManagedVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.IS_READ_ONLY.toString(), isReadOnly);
StringSet techType = new StringSet();
techType.add(BlockSnapshot.TechnologyType.NATIVE.toString());
unManagedVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.TECHNOLOGY_TYPE.toString(), techType);
// set snapshot consistency group information in the unmanged snapshot object
String isParentVolumeInCG = parentUnManagedVolume.getVolumeCharacterstics().get(UnManagedVolume.SupportedVolumeCharacterstics.IS_VOLUME_ADDED_TO_CONSISTENCYGROUP.toString());
if (isParentVolumeInCG.equals(Boolean.TRUE.toString())) {
// set snapshot consistency group name
if (driverSnapshot.getConsistencyGroup() != null && !driverSnapshot.getConsistencyGroup().isEmpty()) {
StringSet snapCgName = new StringSet();
snapCgName.add(driverSnapshot.getConsistencyGroup());
unManagedVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.SNAPSHOT_CONSISTENCY_GROUP_NAME.toString(), snapCgName);
}
}
// set from parent volume (required for snaps by ingest framework)
unManagedVolume.putVolumeCharacterstics(UnManagedVolume.SupportedVolumeCharacterstics.IS_THINLY_PROVISIONED.toString(), parentUnManagedVolume.getVolumeCharacterstics().get(UnManagedVolume.SupportedVolumeCharacterstics.IS_THINLY_PROVISIONED.toString()));
unManagedVolume.setStoragePoolUri(storagePool.getId());
StringSet pools = new StringSet();
pools.add(storagePool.getId().toString());
unManagedVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.STORAGE_POOL.toString(), pools);
StringSet driveTypes = storagePool.getSupportedDriveTypes();
if (null != driveTypes) {
unManagedVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.DISK_TECHNOLOGY.toString(), driveTypes);
}
StringSet provCapacity = new StringSet();
provCapacity.add(String.valueOf(driverSnapshot.getProvisionedCapacity()));
unManagedVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.PROVISIONED_CAPACITY.toString(), provCapacity);
StringSet allocatedCapacity = new StringSet();
allocatedCapacity.add(String.valueOf(driverSnapshot.getAllocatedCapacity()));
unManagedVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.ALLOCATED_CAPACITY.toString(), allocatedCapacity);
// Set matched vpools the same as parent.
StringSet parentMatchedVPools = parentUnManagedVolume.getSupportedVpoolUris();
if (null != parentMatchedVPools) {
log.info("Parent Matched Virtual Pools : {}", Joiner.on("\t").join(parentMatchedVPools));
}
if (null == parentMatchedVPools || parentMatchedVPools.isEmpty()) {
// Clean all vpools as no matching vpools found.
unManagedVolume.getSupportedVpoolUris().clear();
} else {
// replace with new StringSet
unManagedVolume.getSupportedVpoolUris().replace(parentMatchedVPools);
log.info("Replaced Virtual Pools :{}", Joiner.on("\t").join(unManagedVolume.getSupportedVpoolUris()));
}
if (newVolume) {
unManagedVolumesToCreate.add(unManagedVolume);
} else {
unManagedVolumesToUpdate.add(unManagedVolume);
}
return unManagedVolume;
}
Aggregations