use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume in project coprhd-controller by CoprHD.
the class VPlexCommunicationInterface method processBackendClones.
/**
* This method iterates through all the front-end virtual volumes
* checking for the presence of HAS_REPLICAS or IS_FULL_COPY which were
* found earlier in discovery. If found, it will swap the backend
* volume GUID with the front-end volume GUID using the
* backendVolumeGuidToVvolGuidMap.
*
* In so doing, the vvols will be relative to each other for FULL_COPIES
* and LOCAL_REPLICA_SOURCE_VOLUME, just like the backend volumes are,
* which will enable us to link them up like this:
*
* source vvol
* fullCopies: target vvol
* source bvol
* fullCopies: target bvol
* target vvol
* associatedSourceVolume: source vvol
* target bvol
* associatedSourceVolume: source bvol
*
* @param vplexUri the VPLEX whose unmanaged volumes should be processed
* @param backendVolumeGuidToVvolGuidMap a map of backend volume GUIDs
* to the GUID of the front volume containing it
*/
private void processBackendClones(URI vplexUri, Map<String, String> backendVolumeGuidToVvolGuidMap) {
URIQueryResultList results = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageSystemUnManagedVolumeConstraint(vplexUri), results);
List<UnManagedVolume> changedVolumes = new ArrayList<UnManagedVolume>();
Iterator<UnManagedVolume> allUnmanagedVolumes = _dbClient.queryIterativeObjects(UnManagedVolume.class, results, true);
while (allUnmanagedVolumes.hasNext()) {
UnManagedVolume unManagedVolume = allUnmanagedVolumes.next();
String isFullCopyStr = unManagedVolume.getVolumeCharacterstics().get(SupportedVolumeCharacterstics.IS_FULL_COPY.toString());
boolean isFullCopy = (null != isFullCopyStr && Boolean.parseBoolean(isFullCopyStr));
if (isFullCopy) {
String backendFullCopySource = VplexBackendIngestionContext.extractValueFromStringSet(SupportedVolumeInformation.LOCAL_REPLICA_SOURCE_VOLUME.name(), unManagedVolume.getVolumeInformation());
if (backendFullCopySource != null && !backendFullCopySource.isEmpty()) {
// we're going to swap the backend volume guid for the
// front-end virtual volume guid
String frontendFullCopySource = backendVolumeGuidToVvolGuidMap.get(backendFullCopySource);
StringSet replacementSet = new StringSet();
replacementSet.add(frontendFullCopySource);
unManagedVolume.putVolumeInfo(SupportedVolumeInformation.LOCAL_REPLICA_SOURCE_VOLUME.name(), replacementSet);
changedVolumes.add(unManagedVolume);
}
}
String hasReplicasStr = unManagedVolume.getVolumeCharacterstics().get(SupportedVolumeCharacterstics.HAS_REPLICAS.toString());
boolean hasReplicas = (null != hasReplicasStr && Boolean.parseBoolean(hasReplicasStr));
if (hasReplicas) {
// HAS_REPLICAS was set during backend volume discovery a little earlier
StringSet backendfullCopyTargets = unManagedVolume.getVolumeInformation().get(SupportedVolumeInformation.FULL_COPIES.name());
if (backendfullCopyTargets != null && !backendfullCopyTargets.isEmpty()) {
// we're going to swap the backend volume guids for the
// front-end virtual volume guids
StringSet replacementSet = new StringSet();
for (String backendfullCopyTarget : backendfullCopyTargets) {
String frontendfullCopyTarget = backendVolumeGuidToVvolGuidMap.get(backendfullCopyTarget);
replacementSet.add(frontendfullCopyTarget);
}
unManagedVolume.putVolumeInfo(SupportedVolumeInformation.FULL_COPIES.name(), replacementSet);
changedVolumes.add(unManagedVolume);
}
}
// persist any changed volumes if batch limit has been reached
persistUnManagedVolumes(null, changedVolumes, false);
}
// flush any remaining changed volumes
persistUnManagedVolumes(null, changedVolumes, true);
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume in project coprhd-controller by CoprHD.
the class VPlexCommunicationInterface method createUnmanagedVolume.
/**
* Creates a new UnManagedVolume with the info from
* the VPLEX virtual volume.
*
* @param info a VPlexVirtualVolumeInfo descriptor
* @param vplex the VPLEX storage system managing the volume
* @param volumesToCgs a Map of volume labels to consistency group names
* @param allVpools cache of virtual pools to filter
*/
private UnManagedVolume createUnmanagedVolume(VPlexVirtualVolumeInfo info, StorageSystem vplex, Map<String, String> volumesToCgs, Map<String, String> clusterIdToNameMap, Map<String, String> varrayToClusterIdMap, Map<String, String> distributedDevicePathToClusterMap, Map<String, String> backendVolumeGuidToVvolGuidMap, Map<String, Set<VPlexStorageViewInfo>> volumeToStorageViewMap, Collection<VirtualPool> allVpools) {
s_logger.info("Creating new UnManagedVolume from VPLEX volume {}", info.getName());
UnManagedVolume volume = new UnManagedVolume();
volume.setId(URIUtil.createId(UnManagedVolume.class));
updateUnmanagedVolume(info, vplex, volume, volumesToCgs, clusterIdToNameMap, varrayToClusterIdMap, distributedDevicePathToClusterMap, backendVolumeGuidToVvolGuidMap, volumeToStorageViewMap, allVpools);
return volume;
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume in project coprhd-controller by CoprHD.
the class VPlexCommunicationInterface method discoverUnmanagedStorageViews.
/**
* Discovers storage views on the VPLEX and creates UnManagedExportMasks for any
* that are not managed by ViPR.
*
* @param accessProfile providing context for this discovery session
* @param client a reference to the VPLEX API client
* @param vvolMap map of virtual volume names to virtual volume info objects
* @param volumeToExportMasksMap map of volumes to a set of associated UnManagedExportMasks
* @param volumeToStorageViewMap map of volumes to a set of associated VPlexStorageViewInfos
* @param recoverpointExportMasks recoverpoint export mask uris
* @throws BaseCollectionException
*/
private void discoverUnmanagedStorageViews(AccessProfile accessProfile, VPlexApiClient client, Map<String, VPlexVirtualVolumeInfo> vvolMap, Map<String, Set<UnManagedExportMask>> volumeToExportMasksMap, Map<String, Set<VPlexStorageViewInfo>> volumeToStorageViewMap, Set<String> recoverPointExportMasks) throws BaseCollectionException {
String statusMessage = "Starting discovery of Unmanaged VPLEX Storage Views.";
s_logger.info(statusMessage + " Access Profile Details : IpAddress : " + "PortNumber : {}, namespace : {}", accessProfile.getIpAddress() + accessProfile.getPortNumber(), accessProfile.getnamespace());
URI vplexUri = accessProfile.getSystemId();
StorageSystem vplex = _dbClient.queryObject(StorageSystem.class, vplexUri);
if (null == vplex) {
s_logger.error("No VPLEX Device was found in ViPR for URI: " + vplexUri);
s_logger.error("Unmanaged VPLEX StorageView discovery cannot continue.");
return;
}
try {
// this is a map of cluster id (1 or 2) to the actual cluster name
Map<String, String> clusterIdToNameMap = client.getClusterIdToNameMap();
// this is a map of the cluster names to a map of its target port names to wwpns
Map<String, Map<String, String>> clusterPortMap = new HashMap<String, Map<String, String>>();
for (String clusterName : clusterIdToNameMap.values()) {
Map<String, String> targetPortToPwwnMap = VPlexControllerUtils.getTargetPortToPwwnMap(client, clusterName);
clusterPortMap.put(clusterName, targetPortToPwwnMap);
}
Set<URI> allCurrentUnManagedExportMaskUris = new HashSet<URI>();
List<UnManagedExportMask> unManagedExportMasksToCreate = new ArrayList<UnManagedExportMask>();
List<UnManagedExportMask> unManagedExportMasksToUpdate = new ArrayList<UnManagedExportMask>();
Set<URI> rpPortInitiators = RPHelper.getBackendPortInitiators(_dbClient);
for (String clusterName : clusterIdToNameMap.values()) {
List<VPlexStorageViewInfo> storageViews = client.getStorageViewsForCluster(clusterName);
for (VPlexStorageViewInfo storageView : storageViews) {
s_logger.info("discovering storage view: " + storageView.toString());
List<Initiator> knownInitiators = new ArrayList<Initiator>();
List<StoragePort> knownPorts = new ArrayList<StoragePort>();
UnManagedExportMask uem = getUnManagedExportMaskFromDb(storageView);
if (uem != null) {
s_logger.info("found an existing unmanaged export mask for storage view " + storageView.getName());
unManagedExportMasksToUpdate.add(uem);
// clean up collections (we'll be refreshing them)
uem.getKnownInitiatorUris().clear();
uem.getKnownInitiatorNetworkIds().clear();
uem.getKnownStoragePortUris().clear();
uem.getKnownVolumeUris().clear();
uem.getUnmanagedInitiatorNetworkIds().clear();
uem.getUnmanagedStoragePortNetworkIds().clear();
uem.getUnmanagedVolumeUris().clear();
} else {
s_logger.info("creating a new unmanaged export mask for storage view " + storageView.getName());
uem = new UnManagedExportMask();
unManagedExportMasksToCreate.add(uem);
}
// set basic info
uem.setNativeId(storageView.getPath());
uem.setMaskingViewPath(storageView.getPath());
uem.setMaskName(storageView.getName());
uem.setStorageSystemUri(accessProfile.getSystemId());
s_logger.info("now discovering host initiators in storage view " + storageView.getName());
for (String initiatorNetworkId : storageView.getInitiatorPwwns()) {
s_logger.info("looking at initiator network id " + initiatorNetworkId);
if (initiatorNetworkId != null && initiatorNetworkId.matches(ISCSI_PATTERN) && (iSCSIUtility.isValidIQNPortName(initiatorNetworkId) || iSCSIUtility.isValidEUIPortName(initiatorNetworkId))) {
s_logger.info("\tiSCSI network id normalized to " + initiatorNetworkId);
} else if (initiatorNetworkId != null && initiatorNetworkId.matches(REGISTERED_PATTERN)) {
initiatorNetworkId = initiatorNetworkId.substring(REGISTERED_PORT_PREFIX.length());
initiatorNetworkId = WWNUtility.getWWNWithColons(initiatorNetworkId);
s_logger.info("\tRegistered network id normalized to " + initiatorNetworkId);
} else if (WWNUtility.isValidWWNAlias(initiatorNetworkId)) {
initiatorNetworkId = WWNUtility.getWWNWithColons(initiatorNetworkId);
s_logger.info("\twwn normalized to " + initiatorNetworkId);
} else {
s_logger.warn("\tthis is not a valid network id format, skipping");
continue;
}
// check if a host initiator exists for this id
// if so, add to _knownInitiators
// otherwise, add to _unmanagedInitiators
Initiator knownInitiator = NetworkUtil.getInitiator(initiatorNetworkId, _dbClient);
if (knownInitiator != null) {
s_logger.info(" found an initiator in ViPR on host " + knownInitiator.getHostName());
uem.getKnownInitiatorUris().add(knownInitiator.getId().toString());
uem.getKnownInitiatorNetworkIds().add(knownInitiator.getInitiatorPort());
knownInitiators.add(knownInitiator);
} else {
s_logger.info(" no hosts in ViPR found configured for initiator " + initiatorNetworkId);
uem.getUnmanagedInitiatorNetworkIds().add(initiatorNetworkId);
}
}
s_logger.info("now discovering storage ports in storage view " + storageView.getName());
List<String> targetPortNames = storageView.getPorts();
if (targetPortNames.isEmpty()) {
s_logger.info("no storage ports found in storage view " + storageView.getName());
// continue; ?
}
// target port has value like - P0000000046E01E80-A0-FC02
// PortWwn has value like - 0x50001442601e8002
List<String> portWwns = new ArrayList<String>();
for (String targetPortName : targetPortNames) {
Map<String, String> portToWwpnMap = clusterPortMap.get(clusterName);
if (portToWwpnMap.keySet().contains(targetPortName)) {
portWwns.add(WwnUtils.convertWWN(portToWwpnMap.get(targetPortName), WwnUtils.FORMAT.COLON));
}
}
for (String portNetworkId : portWwns) {
s_logger.info("looking at storage port network id " + portNetworkId);
// check if a storage port exists for this id in ViPR
// if so, add to _storagePorts
StoragePort knownStoragePort = NetworkUtil.getStoragePort(portNetworkId, _dbClient);
if (knownStoragePort != null) {
s_logger.info(" found a matching storage port in ViPR " + knownStoragePort.getLabel());
uem.getKnownStoragePortUris().add(knownStoragePort.getId().toString());
knownPorts.add(knownStoragePort);
} else {
s_logger.info(" no storage port in ViPR found matching portNetworkId " + portNetworkId);
uem.getUnmanagedStoragePortNetworkIds().add(portNetworkId);
}
}
s_logger.info("now discovering storage volumes in storage view " + storageView.getName());
for (String volumeNameStr : storageView.getVirtualVolumes()) {
s_logger.info("found volume " + volumeNameStr);
// volumeNameStr contains value like
// (161,dd_V000195701573-00D57_VAPM00140801303-00614_vol,VPD83T3:6000144000000010f07dc46a0717e61d,2G)
String[] tokens = volumeNameStr.split(",");
String volumeName = tokens[1];
VPlexVirtualVolumeInfo vvol = vvolMap.get(volumeName);
Volume volume = findVirtualVolumeManagedByVipr(vvol);
if (volume != null) {
s_logger.info("this is a volume already managed by ViPR: " + volume.getLabel());
uem.getKnownVolumeUris().add(volume.getId().toString());
}
// add to map of volume paths to export masks
if (vvol != null) {
String nativeGuid = vvol.getPath();
s_logger.info("nativeGuid UnManagedVolume key for locating UnManagedExportMasks is " + nativeGuid);
Set<UnManagedExportMask> maskSet = volumeToExportMasksMap.get(nativeGuid);
if (maskSet == null) {
maskSet = new HashSet<UnManagedExportMask>();
s_logger.info(" creating new maskSet for nativeGuid " + nativeGuid);
volumeToExportMasksMap.put(nativeGuid, maskSet);
}
maskSet.add(uem);
}
// add this storage view to the volume to storage view map for this volume
Set<VPlexStorageViewInfo> storageViewSet = volumeToStorageViewMap.get(volumeName);
if (storageViewSet == null) {
storageViewSet = new HashSet<VPlexStorageViewInfo>();
}
storageViewSet.add(storageView);
volumeToStorageViewMap.put(volumeName, storageViewSet);
}
if (uem.getId() == null) {
uem.setId(URIUtil.createId(UnManagedExportMask.class));
}
if (checkRecoverPointExportMask(uem, knownInitiators, rpPortInitiators)) {
recoverPointExportMasks.add(uem.getId().toString());
}
updateZoningMap(uem, knownInitiators, knownPorts);
persistUnManagedExportMasks(unManagedExportMasksToCreate, unManagedExportMasksToUpdate, false);
allCurrentUnManagedExportMaskUris.add(uem.getId());
}
}
persistUnManagedExportMasks(unManagedExportMasksToCreate, unManagedExportMasksToUpdate, true);
cleanUpOrphanedExportMasks(vplexUri, allCurrentUnManagedExportMaskUris);
} catch (Exception ex) {
s_logger.error(ex.getLocalizedMessage(), ex);
String vplexLabel = vplexUri.toString();
if (null != vplex) {
vplexLabel = vplex.getLabel();
}
throw VPlexCollectionException.exceptions.vplexUnmanagedExportMaskDiscoveryFailed(vplexLabel, ex.getLocalizedMessage());
} finally {
if (null != vplex) {
try {
vplex.setLastDiscoveryStatusMessage(statusMessage);
_dbClient.updateObject(vplex);
} catch (Exception ex) {
s_logger.error("Error while saving VPLEX discovery status message: {} - Exception: {}", statusMessage, ex.getLocalizedMessage());
}
}
}
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume in project coprhd-controller by CoprHD.
the class VPlexCommunicationInterface method discoverUnmanagedVolumes.
/**
* Implementation for discovering unmanaged virtual volumes in a VPLEX storage system.
*
* @param accessProfile providing context for this discovery session
* @param client a reference to the VPLEX API client
* @param vvolMap map of virtual volume names to virtual volume info objects
* @param volumeToExportMasksMap map of volumes to a set of associated UnManagedExportMasks
* @param volumeToStorageViewMap map of volumes to a set of associated VPlexStorageViewInfos
* @param recoverpointExportMasks recoverpoint export mask uris
* @param tracker the performance report tracking object for this discovery process
* @throws BaseCollectionException
*/
private void discoverUnmanagedVolumes(AccessProfile accessProfile, VPlexApiClient client, Map<String, VPlexVirtualVolumeInfo> allVirtualVolumes, Map<String, Set<UnManagedExportMask>> volumeToExportMasksMap, Map<String, Set<VPlexStorageViewInfo>> volumeToStorageViewMap, Set<String> recoverPointExportMasks, UnmanagedDiscoveryPerformanceTracker tracker) throws BaseCollectionException {
String statusMessage = "Starting discovery of Unmanaged VPLEX Volumes.";
s_logger.info(statusMessage + " Access Profile Details : IpAddress : " + "PortNumber : {}, namespace : {}", accessProfile.getIpAddress() + accessProfile.getPortNumber(), accessProfile.getnamespace());
URI vplexUri = accessProfile.getSystemId();
StorageSystem vplex = _dbClient.queryObject(StorageSystem.class, vplexUri);
if (null == vplex) {
s_logger.error("No VPLEX Device was found in ViPR for URI: " + vplexUri);
s_logger.error("Unmanaged VPLEX Volume discovery cannot continue.");
return;
}
Set<URI> allUnmanagedVolumes = new HashSet<URI>();
List<UnManagedVolume> newUnmanagedVolumes = new ArrayList<UnManagedVolume>();
List<UnManagedVolume> knownUnmanagedVolumes = new ArrayList<UnManagedVolume>();
List<UnManagedExportMask> unmanagedExportMasksToUpdate = new ArrayList<UnManagedExportMask>();
Map<String, String> backendVolumeGuidToVvolGuidMap = new HashMap<String, String>();
try {
long timer = System.currentTimeMillis();
Map<String, String> volumesToCgs = new HashMap<String, String>();
List<VPlexConsistencyGroupInfo> cgs = client.getConsistencyGroups();
s_logger.info("Found {} Consistency Groups.", cgs.size());
for (VPlexConsistencyGroupInfo cg : cgs) {
for (String volumeName : cg.getVirtualVolumes()) {
volumesToCgs.put(volumeName, cg.getName());
}
}
s_logger.info("Volume to Consistency Group Map is: " + volumesToCgs.toString());
tracker.consistencyGroupFetch = System.currentTimeMillis() - timer;
Map<String, String> clusterIdToNameMap = client.getClusterIdToNameMap();
Map<String, String> varrayToClusterIdMap = new HashMap<String, String>();
Map<String, String> distributedDevicePathToClusterMap = VPlexControllerUtils.getDistributedDevicePathToClusterMap(vplexUri, _dbClient);
if (null != allVirtualVolumes) {
// Pre-populate the virtual pools
List<URI> allVpoolUris = _dbClient.queryByType(VirtualPool.class, true);
Iterator<VirtualPool> vpoolIter = _dbClient.queryIterativeObjects(VirtualPool.class, allVpoolUris);
List<VirtualPool> allVpools = new ArrayList<VirtualPool>();
while (vpoolIter.hasNext()) {
VirtualPool vpool = vpoolIter.next();
// Only cache vplex virtual pools for vpool filtering
if (VirtualPool.vPoolSpecifiesHighAvailability(vpool)) {
allVpools.add(vpool);
}
}
for (String name : allVirtualVolumes.keySet()) {
timer = System.currentTimeMillis();
s_logger.info("Discovering Virtual Volume {}", name);
// UnManagedVolume discover does a pretty expensive
// iterative call into the VPLEX API to get extended details
String discoveryKillSwitch = ControllerUtils.getPropertyValueFromCoordinator(_coordinator, VplexBackendIngestionContext.DISCOVERY_KILL_SWITCH);
if ("stop".equals(discoveryKillSwitch)) {
s_logger.warn("discovery kill switch was set to stop, " + "so discontinuing unmanaged volume discovery");
return;
}
// on every volume in each cluster. First it gets all the
// volume names/paths (the inexpensive "lite" call), then
// iterates through them getting the details to populate the
String discoveryFilter = ControllerUtils.getPropertyValueFromCoordinator(_coordinator, VplexBackendIngestionContext.DISCOVERY_FILTER);
if ((discoveryFilter != null && !discoveryFilter.isEmpty()) && !(name.matches(discoveryFilter))) {
s_logger.warn("name {} doesn't match discovery filter {}", name, discoveryFilter);
continue;
}
// VPlexVirtualVolumeInfo objects with extended details
VPlexVirtualVolumeInfo info = allVirtualVolumes.get(name);
// to here null, it would mean a 404 happened earlier.
if (null == info) {
continue;
}
Volume managedVolume = findVirtualVolumeManagedByVipr(info);
UnManagedVolume unmanagedVolume = findUnmanagedVolumeKnownToVipr(info);
if (null == managedVolume) {
s_logger.info("Virtual Volume {} is not managed by ViPR", name);
if (null != unmanagedVolume) {
// just refresh / update the existing unmanaged volume
s_logger.info("Unmanaged Volume {} is already known to ViPR", name);
updateUnmanagedVolume(info, vplex, unmanagedVolume, volumesToCgs, clusterIdToNameMap, varrayToClusterIdMap, distributedDevicePathToClusterMap, backendVolumeGuidToVvolGuidMap, volumeToStorageViewMap, allVpools);
knownUnmanagedVolumes.add(unmanagedVolume);
} else {
// set up new unmanaged vplex volume
s_logger.info("Unmanaged Volume {} is not known to ViPR", name);
unmanagedVolume = createUnmanagedVolume(info, vplex, volumesToCgs, clusterIdToNameMap, varrayToClusterIdMap, distributedDevicePathToClusterMap, backendVolumeGuidToVvolGuidMap, volumeToStorageViewMap, allVpools);
newUnmanagedVolumes.add(unmanagedVolume);
}
boolean nonRpExported = false;
Set<UnManagedExportMask> uems = volumeToExportMasksMap.get(unmanagedVolume.getNativeGuid());
if (uems != null) {
s_logger.info("{} UnManagedExportMasks found in the map for volume {}", uems.size(), unmanagedVolume.getNativeGuid());
for (UnManagedExportMask uem : uems) {
s_logger.info(" adding UnManagedExportMask {} to UnManagedVolume", uem.getMaskingViewPath());
unmanagedVolume.getUnmanagedExportMasks().add(uem.getId().toString());
uem.getUnmanagedVolumeUris().add(unmanagedVolume.getId().toString());
unmanagedExportMasksToUpdate.add(uem);
// add the known initiators, too
for (String initUri : uem.getKnownInitiatorUris()) {
s_logger.info(" adding known Initiator URI {} to UnManagedVolume", initUri);
unmanagedVolume.getInitiatorUris().add(initUri);
Initiator init = _dbClient.queryObject(Initiator.class, URI.create(initUri));
unmanagedVolume.getInitiatorNetworkIds().add(init.getInitiatorPort());
}
// log this info for debugging
for (String path : uem.getUnmanagedInitiatorNetworkIds()) {
s_logger.info(" UnManagedExportMask has this initiator unknown to ViPR: {}", path);
}
// volume if it is
if (!recoverPointExportMasks.isEmpty() && recoverPointExportMasks.contains(uem.getId().toString())) {
s_logger.info("unmanaged volume {} is an RP volume", unmanagedVolume.getLabel());
unmanagedVolume.putVolumeCharacterstics(SupportedVolumeCharacterstics.IS_RECOVERPOINT_ENABLED.toString(), TRUE);
} else {
// this volume is contained in at least one export mask that is non-RP
nonRpExported = true;
}
}
}
persistUnManagedExportMasks(null, unmanagedExportMasksToUpdate, false);
// this as a convenience to ingest features.
if (nonRpExported) {
s_logger.info("unmanaged volume {} is exported to something other than RP. Marking IS_NONRP_EXPORTED.", unmanagedVolume.getLabel());
unmanagedVolume.putVolumeCharacterstics(SupportedVolumeCharacterstics.IS_NONRP_EXPORTED.toString(), TRUE);
unmanagedVolume.putVolumeCharacterstics(SupportedVolumeCharacterstics.IS_VOLUME_EXPORTED.toString(), TRUE);
} else {
s_logger.info("unmanaged volume {} is not exported OR not exported to something other than RP. Not marking IS_NONRP_EXPORTED.", unmanagedVolume.getLabel());
unmanagedVolume.putVolumeCharacterstics(SupportedVolumeCharacterstics.IS_NONRP_EXPORTED.toString(), FALSE);
unmanagedVolume.putVolumeCharacterstics(SupportedVolumeCharacterstics.IS_VOLUME_EXPORTED.toString(), FALSE);
}
persistUnManagedVolumes(newUnmanagedVolumes, knownUnmanagedVolumes, false);
} else {
s_logger.info("Virtual Volume {} is already managed by ViPR", managedVolume.forDisplay());
Long currentCapacity = info.getCapacityBytes();
if (currentCapacity != null && currentCapacity > managedVolume.getCapacity()) {
// update the managed volume's capacity if it changed. this could possibly happen
// if the volume were expanded and the final status was not processed successfully by ViPR due to timeout
s_logger.info("Virtual Volume {} capacity on VPLEX is different ({}) than in database ({}), updating...", managedVolume.forDisplay(), info.getCapacityBytes(), managedVolume.getCapacity());
managedVolume.setAllocatedCapacity(Long.parseLong(String.valueOf(0)));
managedVolume.setProvisionedCapacity(currentCapacity);
managedVolume.setCapacity(currentCapacity);
_dbClient.updateObject(managedVolume);
}
}
if (null != unmanagedVolume && !unmanagedVolume.getInactive()) {
allUnmanagedVolumes.add(unmanagedVolume.getId());
}
tracker.volumeTimeResults.put(name, System.currentTimeMillis() - timer);
tracker.totalVolumesDiscovered++;
s_logger.info("estimated discovery time remaining: " + tracker.getDiscoveryTimeRemaining());
}
} else {
s_logger.warn("No virtual volumes were found on VPLEX.");
}
persistUnManagedVolumes(newUnmanagedVolumes, knownUnmanagedVolumes, true);
persistUnManagedExportMasks(null, unmanagedExportMasksToUpdate, true);
cleanUpOrphanedVolumes(vplex.getId(), allUnmanagedVolumes);
// this has to happen at the very end so that the map is complete,
// and by supplying the vplex id, we'll re-fetch all the volumes
// now that everything has been persisted and orphans cleared out
processBackendClones(vplex.getId(), backendVolumeGuidToVvolGuidMap);
} catch (Exception ex) {
s_logger.error("An error occurred during VPLEX unmanaged volume discovery", ex);
String vplexLabel = vplexUri.toString();
if (null != vplex) {
vplexLabel = vplex.getLabel();
}
throw VPlexCollectionException.exceptions.vplexUnmanagedVolumeDiscoveryFailed(vplexLabel, ex.toString());
} finally {
if (null != vplex) {
try {
vplex.setLastDiscoveryStatusMessage(statusMessage);
_dbClient.updateObject(vplex);
} catch (Exception ex) {
s_logger.error("Error while saving VPLEX discovery status message: {} - Exception: {}", statusMessage, ex.getLocalizedMessage());
}
}
}
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume in project coprhd-controller by CoprHD.
the class VPlexCommunicationInterface method cleanUpOrphanedVolumes.
/**
* This method cleans up UnManaged Volumes in DB, which had been deleted manually from the Array
*
* 1. Get All UnManagedVolumes from DB for the given VPLEX device
* 2. Store URIs of unmanaged volumes returned from the Provider
* 3. If unmanaged volume is found only in DB, then set unmanaged volume to inactive.
*
* @param vplexUri the URI for loading the VPLEX device
* @param allUnmanagedVolumes a list of URI for all the newly discovered unmanaged volumes
* @throws IOException
*/
private void cleanUpOrphanedVolumes(URI vplexUri, Set<URI> allUnmanagedVolumes) {
URIQueryResultList results = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageSystemUnManagedVolumeConstraint(vplexUri), results);
Set<URI> unManagedVolumesInDBSet = new HashSet<URI>();
while (results.iterator().hasNext()) {
// why does getting stuff from the database have to be so painful?
unManagedVolumesInDBSet.add(results.iterator().next());
}
SetView<URI> onlyAvailableinDB = Sets.difference(unManagedVolumesInDBSet, allUnmanagedVolumes);
if (onlyAvailableinDB != null && !onlyAvailableinDB.isEmpty()) {
s_logger.info("UnManagedVolumes to be Removed : " + Joiner.on("\t").join(onlyAvailableinDB));
List<UnManagedVolume> volumesToBeDeleted = new ArrayList<UnManagedVolume>();
Iterator<UnManagedVolume> unManagedVolumes = _dbClient.queryIterativeObjects(UnManagedVolume.class, new ArrayList<URI>(onlyAvailableinDB));
while (unManagedVolumes.hasNext()) {
UnManagedVolume volume = unManagedVolumes.next();
if (null == volume || volume.getInactive()) {
continue;
}
s_logger.info("Setting UnManagedVolume {} inactive", volume.getId());
volume.setStorageSystemUri(NullColumnValueGetter.getNullURI());
volume.setInactive(true);
volumesToBeDeleted.add(volume);
}
if (!volumesToBeDeleted.isEmpty()) {
_partitionManager.updateAndReIndexInBatches(volumesToBeDeleted, BATCH_SIZE, _dbClient, UNMANAGED_VOLUME);
}
}
}
Aggregations