use of com.emc.storageos.vplex.api.VPlexVirtualVolumeInfo in project coprhd-controller by CoprHD.
the class VPlexCommunicationInterface method discover.
/**
* Implementation for discovery of VPLEX storage systems.
*
* @param accessProfile providing context for this discovery session
*
* @throws BaseCollectionException
*/
@Override
public void discover(AccessProfile accessProfile) throws BaseCollectionException {
s_logger.info("initiating discovery of VPLEX system {}", accessProfile.getProfileName());
if ((null != accessProfile.getnamespace()) && (accessProfile.getnamespace().equals(StorageSystem.Discovery_Namespaces.UNMANAGED_VOLUMES.toString()))) {
try {
VPlexApiClient client = getVPlexAPIClient(accessProfile);
long timer = System.currentTimeMillis();
UnmanagedDiscoveryPerformanceTracker tracker = new UnmanagedDiscoveryPerformanceTracker();
tracker.discoveryMode = ControllerUtils.getPropertyValueFromCoordinator(_coordinator, VplexBackendIngestionContext.DISCOVERY_MODE);
// get all the detailed virtual volume info from the VPLEX API
Map<String, VPlexVirtualVolumeInfo> vvolMap = client.getVirtualVolumes(true);
tracker.virtualVolumeFetch = System.currentTimeMillis() - timer;
tracker.totalVolumesFetched = vvolMap.size();
// discover unmanaged storage views
timer = System.currentTimeMillis();
Map<String, Set<UnManagedExportMask>> volumeToExportMasksMap = new HashMap<String, Set<UnManagedExportMask>>();
Map<String, Set<VPlexStorageViewInfo>> volumeToStorageViewMap = new HashMap<String, Set<VPlexStorageViewInfo>>();
Set<String> recoverPointExportMasks = new HashSet<String>();
discoverUnmanagedStorageViews(accessProfile, client, vvolMap, volumeToExportMasksMap, volumeToStorageViewMap, recoverPointExportMasks);
tracker.storageViewFetch = System.currentTimeMillis() - timer;
// discover unmanaged volumes
timer = System.currentTimeMillis();
discoverUnmanagedVolumes(accessProfile, client, vvolMap, volumeToExportMasksMap, volumeToStorageViewMap, recoverPointExportMasks, tracker);
tracker.unmanagedVolumeProcessing = System.currentTimeMillis() - timer;
// re-run vpool matching for all vpools so that backend volumes will
// be updated after vvol discovery to match their parent's matched vpools
timer = System.currentTimeMillis();
List<URI> vpoolURIs = _dbClient.queryByType(VirtualPool.class, true);
List<VirtualPool> vpoolList = _dbClient.queryObject(VirtualPool.class, vpoolURIs);
Set<URI> srdfEnabledTargetVPools = SRDFUtils.fetchSRDFTargetVirtualPools(_dbClient);
Set<URI> rpEnabledTargetVPools = RPHelper.fetchRPTargetVirtualPools(_dbClient);
for (VirtualPool vpool : vpoolList) {
ImplicitUnManagedObjectsMatcher.matchVirtualPoolsWithUnManagedVolumes(vpool, srdfEnabledTargetVPools, rpEnabledTargetVPools, _dbClient, true);
}
tracker.vpoolMatching = System.currentTimeMillis() - timer;
s_logger.info(tracker.getPerformanceReport());
} catch (URISyntaxException ex) {
s_logger.error(ex.getLocalizedMessage());
throw VPlexCollectionException.exceptions.vplexUnmanagedVolumeDiscoveryFailed(accessProfile.getSystemId().toString(), ex.getLocalizedMessage());
}
} else {
discoverAll(accessProfile);
}
}
use of com.emc.storageos.vplex.api.VPlexVirtualVolumeInfo 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.vplex.api.VPlexVirtualVolumeInfo 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.vplex.api.VPlexVirtualVolumeInfo in project coprhd-controller by CoprHD.
the class VplexVolumeValidator method validateVolume.
/**
* Validates an individual volume.
*
* @param virtualVolume the Volume to validate
* @param delete boolean indicating if this validation is part of a delete operation
* @param remediate boolean indicating whether or not remediation should be attempted
* @param checks variable list of ValCks
*/
public void validateVolume(Volume virtualVolume, boolean delete, boolean remediate, ValCk... checks) {
List<ValCk> checkList = Arrays.asList(checks);
String volumeId = String.format("%s (%s)(%s)", virtualVolume.getLabel(), virtualVolume.getNativeGuid(), virtualVolume.getId());
log.info("Initiating Vplex Volume validation: " + volumeId);
VPlexVirtualVolumeInfo vvinfo = null;
try {
vvinfo = client.findVirtualVolume(virtualVolume.getDeviceLabel(), virtualVolume.getNativeId());
} catch (VPlexApiException ex) {
log.info(ex.getMessage());
}
if (vvinfo == null) {
try {
// Didn't find the virtual volume. Look at the storage volume, and from that determine
// the deviceName. Then lookup the Device or DistributedDevice and check to see if
// the device has been reassigned to a different virtual volume.
Volume storageVolume = VPlexUtil.getVPLEXBackendVolume(virtualVolume, true, getDbClient(), false);
if (storageVolume != null) {
StorageSystem system = getDbClient().queryObject(StorageSystem.class, storageVolume.getStorageController());
// Look up the corresponding device name to our Storage Volume
VolumeInfo volumeInfo = new VolumeInfo(system.getNativeGuid(), system.getSystemType(), storageVolume.getWWN().toUpperCase().replaceAll(":", ""), storageVolume.getNativeId(), storageVolume.getThinlyProvisioned().booleanValue(), VPlexControllerUtils.getVolumeITLs(storageVolume));
String deviceName = client.getDeviceForStorageVolume(volumeInfo);
log.info("device name is " + deviceName);
if (deviceName == null) {
if (!delete) {
// We didn't find a device name for the storage volume. Error if not deleting.
getValidatorLogger().logDiff(volumeId, "Vplex device-name", system.getSerialNumber() + "-" + storageVolume.getNativeId(), ValidatorLogger.NO_MATCHING_ENTRY);
return;
}
}
if (null != deviceName && !deviceName.trim().matches(VPlexApiConstants.STORAGE_VOLUME_NOT_IN_USE)) {
String volumeType = VPlexApiConstants.LOCAL_VIRTUAL_VOLUME;
if (virtualVolume.getAssociatedVolumes() != null && virtualVolume.getAssociatedVolumes().size() > 1) {
volumeType = VPlexApiConstants.DISTRIBUTED_VIRTUAL_VOLUME;
}
VPlexResourceInfo resourceInfo = client.getDeviceStructure(deviceName, volumeType);
if (resourceInfo instanceof VPlexDeviceInfo) {
// local device
VPlexDeviceInfo localDeviceInfo = (VPlexDeviceInfo) resourceInfo;
String virtualVolumeName = localDeviceInfo.getVirtualVolume();
if (virtualVolumeName != null && !virtualVolumeName.equals(virtualVolume.getDeviceLabel())) {
getValidatorLogger().logDiff(volumeId, "virtual-volume name changed", virtualVolume.getDeviceLabel(), virtualVolumeName);
}
} else if (resourceInfo instanceof VPlexDistributedDeviceInfo) {
VPlexDistributedDeviceInfo distDeviceInfo = (VPlexDistributedDeviceInfo) resourceInfo;
String virtualVolumeName = distDeviceInfo.getVirtualVolume();
if (virtualVolumeName != null && !virtualVolumeName.equals(virtualVolume.getDeviceLabel())) {
getValidatorLogger().logDiff(volumeId, "virtual-volume name changed", virtualVolume.getDeviceLabel(), virtualVolumeName);
}
}
}
}
} catch (VPlexApiException ex) {
log.error("Unable to determine if VPLEX device reused: " + volumeId, ex);
if (getValidatorConfig().isValidationEnabled()) {
throw ex;
}
}
if (!delete) {
// If we didn't log an error above indicating that the volume was reused,
// and we are not deleting, it is still an error.
// If we are deleting we won't error if it's just not there.
getValidatorLogger().logDiff(volumeId, "virtual-volume", virtualVolume.getDeviceLabel(), ValidatorLogger.NO_MATCHING_ENTRY);
}
log.info("Vplex Validation complete (no vvinfo found); " + volumeId);
return;
}
if (checkList.contains(ValCk.ID)) {
if (!virtualVolume.getDeviceLabel().equals(vvinfo.getName())) {
getValidatorLogger().logDiff(volumeId, "native-id", virtualVolume.getNativeId(), vvinfo.getName());
}
if (!NullColumnValueGetter.isNullValue(virtualVolume.getWWN()) && vvinfo.getWwn() != null && !virtualVolume.getWWN().equalsIgnoreCase(vvinfo.getWwn())) {
getValidatorLogger().logDiff(volumeId, "wwn", virtualVolume.getWWN(), vvinfo.getWwn());
}
if (virtualVolume.getAssociatedVolumes() != null && !virtualVolume.getAssociatedVolumes().isEmpty()) {
String locality = virtualVolume.getAssociatedVolumes().size() > 1 ? VPlexApiConstants.DISTRIBUTED_VIRTUAL_VOLUME : VPlexApiConstants.LOCAL_VIRTUAL_VOLUME;
if (!locality.equalsIgnoreCase(vvinfo.getLocality())) {
getValidatorLogger().logDiff(volumeId, "locality", locality, vvinfo.getLocality());
}
}
}
if (checkList.contains(ValCk.VPLEX) && !virtualVolume.isIngestedVolumeWithoutBackend(getDbClient())) {
try {
String drillDownInfo = client.getDrillDownInfoForDevice(vvinfo.getSupportingDevice());
VPlexDrillDownParser parser = new VPlexDrillDownParser(drillDownInfo);
VPlexDrillDownParser.Node root = parser.parse();
boolean distributed = (root.getType() == VPlexDrillDownParser.NodeType.DIST) ? true : false;
if (distributed) {
List<VPlexDrillDownParser.Node> svols = root.getNodesOfType(NodeType.SVOL);
boolean hasMirror = svols.size() > 2;
String clusterName = VPlexControllerUtils.getVPlexClusterName(getDbClient(), virtualVolume);
for (VPlexDrillDownParser.Node child : root.getChildren()) {
if (child.getArg2().equals(clusterName)) {
validateStorageVolumes(virtualVolume, volumeId, root.getArg1(), true, child.getArg2(), hasMirror);
}
}
} else {
List<VPlexDrillDownParser.Node> svols = root.getNodesOfType(NodeType.SVOL);
boolean hasMirror = svols.size() > 1;
validateStorageVolumes(virtualVolume, volumeId, root.getArg1(), false, root.getArg2(), hasMirror);
}
} catch (Exception ex) {
getValidatorLogger().logDiff(volumeId, "exception trying to validate storage volumes", virtualVolume.getDeviceLabel(), "N/A");
}
}
log.info("Vplex Validation complete; " + volumeId);
}
use of com.emc.storageos.vplex.api.VPlexVirtualVolumeInfo in project coprhd-controller by CoprHD.
the class VPlexDeviceController method commitMigration.
/**
* Invoked by the migration workflow to commit the migration after it has
* been completed.
*
* @param vplexURI
* The URI of the VPlex storage system.
* @param virtualVolumeURI
* The URI of the virtual volume.
* @param migrationURI
* The URI of the data migration.
* @param rename
* Indicates if the volume should be renamed after commit to
* conform to ViPR standard naming conventions.
* @param newVpoolURI - the new virtual pool for the virtual volume (or null if not changing)
* @param newVarrayURI - the new varray for the virtual volume (or null if not changing)
* @param stepId
* The workflow step identifier.
*
* @throws WorkflowException
*/
public void commitMigration(URI vplexURI, URI virtualVolumeURI, URI migrationURI, Boolean rename, URI newVpoolURI, URI newVarrayURI, String stepId) throws WorkflowException {
_log.info("Committing migration {}", migrationURI);
Migration migration = null;
VPlexApiClient client = null;
try {
// Update step state to executing.
WorkflowStepCompleter.stepExecuting(stepId);
// Get the migration.
migration = getDataObject(Migration.class, migrationURI, _dbClient);
// workflow, so check the status.
if (!VPlexMigrationInfo.MigrationStatus.COMMITTED.getStatusValue().equals(migration.getMigrationStatus())) {
// Get the VPlex API client.
StorageSystem vplexSystem = getDataObject(StorageSystem.class, vplexURI, _dbClient);
client = getVPlexAPIClient(_vplexApiFactory, vplexSystem, _dbClient);
_log.info("Got VPlex API client for system {}", vplexURI);
// Make a call to the VPlex API client to commit the migration.
// Note that for ingested VPLEX volumes created outside ViPR, we
// don't want to update the name.
List<VPlexMigrationInfo> migrationInfoList = new ArrayList<VPlexMigrationInfo>();
Volume virtualVolume = getDataObject(Volume.class, virtualVolumeURI, _dbClient);
try {
migrationInfoList = client.commitMigrations(virtualVolume.getDeviceLabel(), Arrays.asList(migration.getLabel()), true, true, rename.booleanValue());
_log.info("Committed migration {}", migration.getLabel());
} catch (VPlexApiException vae) {
_log.error("Exception committing VPlex migration: " + vae.getMessage(), vae);
boolean committed = false;
// Check the migration status. Maybe it committed even though we had an error.
VPlexMigrationInfo migrationInfo = client.getMigrationInfo(migration.getLabel());
if (migrationInfo.getStatus().equalsIgnoreCase(VPlexMigrationInfo.MigrationStatus.COMMITTED.name())) {
_log.info("Migration {} has committed despite exception", migration.getLabel());
migrationInfoList.clear();
migrationInfoList.add(migrationInfo);
committed = true;
} else {
_log.info("Migration {} status {}", migration.getLabel(), migrationInfo.getStatus());
}
if (!committed) {
// This was observed at customer site COP-21257
if (vae.getServiceCode() == ServiceCode.VPLEX_API_RESPONSE_TIMEOUT_ERROR) {
// We are going to throw an error, but we don't want to rollback completely
_workflowService.setWorkflowRollbackContOnError(stepId, false);
}
WorkflowStepCompleter.stepFailed(stepId, vae);
return;
}
}
// Below this point migration is committed, no turning back.
// Initialize the migration info in the database.
migration.setMigrationStatus(VPlexMigrationInfo.MigrationStatus.COMMITTED.getStatusValue());
_dbClient.updateObject(migration);
_log.info("Update migration status to committed");
// Update the virtual volume native id and associated
// volumes. Note that we don't update CoS until all
// commits are successful.
VPlexVirtualVolumeInfo updatedVirtualVolumeInfo = migrationInfoList.get(0).getVirtualVolumeInfo();
// update any properties that were changed after migration including deviceLabel, nativeGuid, and nativeId.
// also, if the updated volume isn't thin-enabled, it is thin-capable, and the target vpool supports thin
// provisioning, then a call should be made to the VPLEX to flip the thin-enabled flag on for this volume.
URI targetVolumeUri = migration.getTarget();
Volume targetVolume = getDataObject(Volume.class, targetVolumeUri, _dbClient);
if (updatedVirtualVolumeInfo != null) {
_log.info(String.format("New virtual volume is %s", updatedVirtualVolumeInfo.toString()));
// if the new virtual volume is thin-capable, but thin-enabled is not true,
// that means we need to ask the VPLEX to convert it to a thin-enabled volume.
// this doesn't happen automatically for thick-to-thin data migrations.
boolean isThinEnabled = updatedVirtualVolumeInfo.isThinEnabled();
if (!isThinEnabled && VPlexApiConstants.TRUE.equalsIgnoreCase(updatedVirtualVolumeInfo.getThinCapable())) {
if (verifyVplexSupportsThinProvisioning(vplexSystem)) {
if (null != targetVolume) {
_log.info(String.format("migration target Volume is %s", targetVolume.forDisplay()));
VirtualPool targetVirtualPool = getDataObject(VirtualPool.class, targetVolume.getVirtualPool(), _dbClient);
if (null != targetVirtualPool) {
_log.info(String.format("migration target VirtualPool is %s", targetVirtualPool.forDisplay()));
boolean doEnableThin = VirtualPool.ProvisioningType.Thin.toString().equalsIgnoreCase(targetVirtualPool.getSupportedProvisioningType());
if (doEnableThin) {
_log.info(String.format("the new VirtualPool is thin, requesting VPLEX to enable thin provisioning on %s", updatedVirtualVolumeInfo.getName()));
isThinEnabled = client.setVirtualVolumeThinEnabled(updatedVirtualVolumeInfo);
}
}
}
}
}
virtualVolume.setDeviceLabel(updatedVirtualVolumeInfo.getName());
virtualVolume.setNativeId(updatedVirtualVolumeInfo.getPath());
virtualVolume.setNativeGuid(updatedVirtualVolumeInfo.getPath());
virtualVolume.setThinlyProvisioned(isThinEnabled);
}
// Note that for ingested volumes, there will be no associated volumes
// at first.
StringSet assocVolumes = virtualVolume.getAssociatedVolumes();
if ((assocVolumes != null) && (!assocVolumes.isEmpty())) {
// For a distributed volume, there could be multiple
// migrations. When the first completes, there will
// be no associated volumes. However, when the second
// completes, there will be associated volumes. However,
// the migration source could be null.
URI sourceVolumeUri = migration.getSource();
if (sourceVolumeUri != null) {
assocVolumes.remove(sourceVolumeUri.toString());
// Retain any previous RP fields on the new target volume.
Volume sourceVolume = getDataObject(Volume.class, sourceVolumeUri, _dbClient);
if (sourceVolume != null) {
boolean targetUpdated = false;
if (NullColumnValueGetter.isNotNullValue(sourceVolume.getRpCopyName())) {
targetVolume.setRpCopyName(sourceVolume.getRpCopyName());
targetUpdated = true;
}
if (NullColumnValueGetter.isNotNullValue(sourceVolume.getInternalSiteName())) {
targetVolume.setInternalSiteName(sourceVolume.getInternalSiteName());
targetUpdated = true;
}
if (targetUpdated) {
_dbClient.updateObject(targetVolume);
}
}
}
assocVolumes.add(migration.getTarget().toString());
} else {
// NOTE: Now an ingested volume will have associated volumes.
// It will no longer be considered an ingested volume.
assocVolumes = new StringSet();
assocVolumes.add(migration.getTarget().toString());
virtualVolume.setAssociatedVolumes(assocVolumes);
}
updateMigratedVirtualVolumeVpoolAndVarray(virtualVolume, newVpoolURI, newVarrayURI);
_dbClient.updateObject(virtualVolume);
_log.info("Updated virtual volume.");
} else {
_log.info("The migration is already committed.");
// Note that we don't set the device label and native id. If the
// migration was committed outside of Bourne, the virtual volume
// will still have the old name. If it was committed through
// Bourne, these values would already have been update.
// Regardless, we have to update the vpool, and we update the
// associated volumes in case it was committed outside of
// Bourne.
associateVplexVolumeWithMigratedTarget(migration, virtualVolumeURI);
_log.info("Updated virtual volume.");
}
// Update the workflow step status.
StringBuilder successMsgBuilder = new StringBuilder();
successMsgBuilder.append("VPlex System: ");
successMsgBuilder.append(vplexURI);
successMsgBuilder.append(" migration: ");
successMsgBuilder.append(migrationURI);
successMsgBuilder.append(" was committed");
_log.info(successMsgBuilder.toString());
WorkflowStepCompleter.stepSucceded(stepId);
_log.info("Updated workflow step state to success");
} catch (VPlexApiException vae) {
_log.error("Exception committing VPlex migration: " + vae.getMessage(), vae);
WorkflowStepCompleter.stepFailed(stepId, vae);
} catch (Exception ex) {
_log.error("Exception committing VPlex migration: " + ex.getMessage(), ex);
String opName = ResourceOperationTypeEnum.COMMIT_VOLUME_MIGRATION.getName();
ServiceError serviceError = VPlexApiException.errors.commitMigrationFailed(opName, ex);
WorkflowStepCompleter.stepFailed(stepId, serviceError);
}
}
Aggregations