Search in sources :

Example 86 with UnManagedVolume

use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume in project coprhd-controller by CoprHD.

the class XtremIOUnManagedVolumeDiscoverer method createUnManagedVolume.

/**
 * Creates a new UnManagedVolume with the given arguments.
 *
 * @param unManagedVolumeNativeGuid
 * @param volume
 * @param system
 * @param pool
 * @param dbClient
 * @return
 */
private UnManagedVolume createUnManagedVolume(UnManagedVolume unManagedVolume, String unManagedVolumeNativeGuid, XtremIOVolume volume, Map<String, List<UnManagedVolume>> igVolumesMap, StorageSystem system, StoragePool pool, DbClient dbClient) {
    boolean created = false;
    StringSetMap unManagedVolumeInformation = null;
    Map<String, String> unManagedVolumeCharacteristics = null;
    if (null == unManagedVolume) {
        unManagedVolume = new UnManagedVolume();
        unManagedVolume.setId(URIUtil.createId(UnManagedVolume.class));
        unManagedVolume.setNativeGuid(unManagedVolumeNativeGuid);
        unManagedVolume.setStorageSystemUri(system.getId());
        if (pool != null) {
            unManagedVolume.setStoragePoolUri(pool.getId());
        }
        created = true;
        unManagedVolumeInformation = new StringSetMap();
        unManagedVolumeCharacteristics = new HashMap<String, String>();
    } else {
        unManagedVolumeInformation = unManagedVolume.getVolumeInformation();
        unManagedVolumeCharacteristics = unManagedVolume.getVolumeCharacterstics();
    }
    unManagedVolume.setLabel(volume.getVolInfo().get(1));
    Boolean isVolumeExported = false;
    if (!volume.getLunMaps().isEmpty()) {
        // clear the previous unmanaged export masks, initiators if any. The latest export masks will be updated later.
        unManagedVolume.getUnmanagedExportMasks().clear();
        unManagedVolume.getInitiatorNetworkIds().clear();
        unManagedVolume.getInitiatorUris().clear();
        isVolumeExported = true;
        for (List<Object> lunMapEntries : volume.getLunMaps()) {
            @SuppressWarnings("unchecked") List<Object> // This can't be null
            igDetails = (List<Object>) lunMapEntries.get(0);
            if (null == igDetails.get(1) || null == lunMapEntries.get(2)) {
                log.warn("IG Name is null in returned lun map response for volume {}", volume.toString());
                continue;
            }
            String igNameToProcess = (String) igDetails.get(1);
            List<UnManagedVolume> igVolumes = igVolumesMap.get(igNameToProcess);
            if (igVolumes == null) {
                igVolumes = new ArrayList<UnManagedVolume>();
                igVolumesMap.put(igNameToProcess, igVolumes);
            }
            igVolumes.add(unManagedVolume);
        }
    }
    unManagedVolumeCharacteristics.put(SupportedVolumeCharacterstics.IS_VOLUME_EXPORTED.toString(), isVolumeExported.toString());
    // Set these default to false. The individual storage discovery will change them if needed.
    unManagedVolumeCharacteristics.put(SupportedVolumeCharacterstics.IS_NONRP_EXPORTED.toString(), FALSE);
    unManagedVolumeCharacteristics.put(SupportedVolumeCharacterstics.IS_RECOVERPOINT_ENABLED.toString(), FALSE);
    StringSet deviceLabel = new StringSet();
    deviceLabel.add(volume.getVolInfo().get(1));
    unManagedVolumeInformation.put(SupportedVolumeInformation.DEVICE_LABEL.toString(), deviceLabel);
    String volumeWWN = volume.getWwn().isEmpty() ? volume.getVolInfo().get(0) : volume.getWwn();
    unManagedVolume.setWwn(volumeWWN);
    StringSet systemTypes = new StringSet();
    systemTypes.add(system.getSystemType());
    StringSet accessState = new StringSet();
    accessState.add(Volume.VolumeAccessState.READWRITE.getState());
    unManagedVolumeInformation.put(SupportedVolumeInformation.ACCESS.toString(), accessState);
    StringSet provCapacity = new StringSet();
    provCapacity.add(String.valueOf(Long.parseLong(volume.getAllocatedCapacity()) * 1024));
    unManagedVolumeInformation.put(SupportedVolumeInformation.PROVISIONED_CAPACITY.toString(), provCapacity);
    StringSet allocatedCapacity = new StringSet();
    allocatedCapacity.add(String.valueOf(Long.parseLong(volume.getAllocatedCapacity()) * 1024));
    unManagedVolumeInformation.put(SupportedVolumeInformation.ALLOCATED_CAPACITY.toString(), allocatedCapacity);
    unManagedVolumeInformation.put(SupportedVolumeInformation.SYSTEM_TYPE.toString(), systemTypes);
    StringSet nativeId = new StringSet();
    nativeId.add(volume.getVolInfo().get(0));
    unManagedVolumeInformation.put(SupportedVolumeInformation.NATIVE_ID.toString(), nativeId);
    unManagedVolumeCharacteristics.put(SupportedVolumeCharacterstics.IS_INGESTABLE.toString(), TRUE);
    unManagedVolumeCharacteristics.put(SupportedVolumeCharacterstics.IS_THINLY_PROVISIONED.toString(), TRUE);
    // Set up default MAXIMUM_IO_BANDWIDTH and MAXIMUM_IOPS
    StringSet bwValues = new StringSet();
    bwValues.add("0");
    if (unManagedVolumeInformation.get(SupportedVolumeInformation.EMC_MAXIMUM_IO_BANDWIDTH.toString()) == null) {
        unManagedVolumeInformation.put(SupportedVolumeInformation.EMC_MAXIMUM_IO_BANDWIDTH.toString(), bwValues);
    } else {
        unManagedVolumeInformation.get(SupportedVolumeInformation.EMC_MAXIMUM_IO_BANDWIDTH.toString()).replace(bwValues);
    }
    StringSet iopsVal = new StringSet();
    iopsVal.add("0");
    if (unManagedVolumeInformation.get(SupportedVolumeInformation.EMC_MAXIMUM_IOPS.toString()) == null) {
        unManagedVolumeInformation.put(SupportedVolumeInformation.EMC_MAXIMUM_IOPS.toString(), iopsVal);
    } else {
        unManagedVolumeInformation.get(SupportedVolumeInformation.EMC_MAXIMUM_IOPS.toString()).replace(iopsVal);
    }
    if (null != pool) {
        unManagedVolume.setStoragePoolUri(pool.getId());
        StringSet pools = new StringSet();
        pools.add(pool.getId().toString());
        unManagedVolumeInformation.put(SupportedVolumeInformation.STORAGE_POOL.toString(), pools);
        StringSet driveTypes = pool.getSupportedDriveTypes();
        if (null != driveTypes) {
            unManagedVolumeInformation.put(SupportedVolumeInformation.DISK_TECHNOLOGY.toString(), driveTypes);
        }
        StringSet matchedVPools = DiscoveryUtils.getMatchedVirtualPoolsForPool(dbClient, pool.getId(), unManagedVolumeCharacteristics.get(SupportedVolumeCharacterstics.IS_THINLY_PROVISIONED.toString()), unManagedVolume);
        log.debug("Matched Pools : {}", Joiner.on("\t").join(matchedVPools));
        if (null == matchedVPools || matchedVPools.isEmpty()) {
            // clear all existing supported vpools.
            unManagedVolume.getSupportedVpoolUris().clear();
        } else {
            // replace with new StringSet
            unManagedVolume.getSupportedVpoolUris().replace(matchedVPools);
            log.info("Replaced Pools : {}", Joiner.on("\t").join(unManagedVolume.getSupportedVpoolUris()));
        }
    }
    unManagedVolume.setVolumeInformation(unManagedVolumeInformation);
    if (unManagedVolume.getVolumeCharacterstics() == null) {
        unManagedVolume.setVolumeCharacterstics(new StringMap());
    }
    unManagedVolume.getVolumeCharacterstics().replace(unManagedVolumeCharacteristics);
    if (created) {
        unManagedVolumesToCreate.add(unManagedVolume);
    } else {
        unManagedVolumesToUpdate.add(unManagedVolume);
    }
    return unManagedVolume;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringMap(com.emc.storageos.db.client.model.StringMap) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) StringSet(com.emc.storageos.db.client.model.StringSet) BlockObject(com.emc.storageos.db.client.model.BlockObject) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 87 with UnManagedVolume

use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume in project coprhd-controller by CoprHD.

the class XtremIOUnManagedVolumeDiscoverer method discoverUnManagedObjects.

public void discoverUnManagedObjects(AccessProfile accessProfile, DbClient dbClient, PartitionManager partitionManager) throws Exception {
    log.info("Started discovery of UnManagedVolumes for system {}", accessProfile.getSystemId());
    StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
    XtremIOClient xtremIOClient = XtremIOProvUtils.getXtremIOClient(dbClient, storageSystem, xtremioRestClientFactory);
    unManagedVolumesToCreate = new ArrayList<UnManagedVolume>();
    unManagedVolumesToUpdate = new ArrayList<UnManagedVolume>();
    unManagedCGToUpdateMap = new HashMap<String, UnManagedConsistencyGroup>();
    // get the storage pool associated with the xtremio system
    StoragePool storagePool = XtremIOProvUtils.getXtremIOStoragePool(storageSystem.getId(), dbClient);
    if (storagePool == null) {
        log.error("Skipping unmanaged volume discovery as the volume storage pool doesn't exist in ViPR");
        return;
    }
    Map<String, List<UnManagedVolume>> igUnmanagedVolumesMap = new HashMap<String, List<UnManagedVolume>>();
    Map<String, StringSet> igKnownVolumesMap = new HashMap<String, StringSet>();
    Map<String, Map<String, Integer>> volumeIGHLUMap = new HashMap<String, Map<String, Integer>>();
    String xioClusterName = xtremIOClient.getClusterDetails(storageSystem.getSerialNumber()).getName();
    // get the xtremio volume links and process them in batches
    List<XtremIOObjectInfo> volLinks = xtremIOClient.getXtremIOVolumeLinks(xioClusterName);
    // Get the volume details
    List<List<XtremIOObjectInfo>> volume_partitions = Lists.partition(volLinks, Constants.DEFAULT_PARTITION_SIZE);
    // Set containing cgs that cannot be ingested, for now that
    // means they contain volumes which belong to more than one cg
    unSupportedCG = new HashSet<String>();
    for (List<XtremIOObjectInfo> partition : volume_partitions) {
        List<XtremIOVolume> volumes = xtremIOClient.getXtremIOVolumesForLinks(partition, xioClusterName);
        for (XtremIOVolume volume : volumes) {
            try {
                // volumes later
                if (volume.getAncestoVolInfo() != null && !volume.getAncestoVolInfo().isEmpty()) {
                    log.debug("Skipping volume {} as it is a snap", volume.getVolInfo().get(0));
                    continue;
                }
                // check if cgs are null before trying to access, older versions of
                // the XtremIO REST client do not return cgs as part of volume response
                // flag indicating the volume is part of a cg
                boolean hasCGs = false;
                if (volume.getConsistencyGroups() != null && !volume.getConsistencyGroups().isEmpty()) {
                    hasCGs = true;
                    if (volume.getConsistencyGroups().size() > 1) {
                        // volumes that belong to multiple CGs are not supported in ViPR
                        log.warn("Skipping volume {} as it belongs to multiple CGs and this is not supported", volume.getVolInfo().get(0));
                        // add all the CGs that this volume belongs to to the list that are unsupported for ingestion
                        for (List<Object> cg : volume.getConsistencyGroups()) {
                            Object cgNameToProcess = cg.get(1);
                            unSupportedCG.add(cgNameToProcess.toString());
                            log.warn("Skipping CG {} as it contains volumes belonging to multiple CGs and this is not supported", cgNameToProcess.toString());
                        }
                        continue;
                    }
                }
                UnManagedVolume unManagedVolume = null;
                boolean isExported = !volume.getLunMaps().isEmpty();
                boolean hasSnaps = !volume.getSnaps().isEmpty();
                String managedVolumeNativeGuid = NativeGUIDGenerator.generateNativeGuidForVolumeOrBlockSnapShot(storageSystem.getNativeGuid(), volume.getVolInfo().get(0));
                Volume viprVolume = DiscoveryUtils.checkStorageVolumeExistsInDB(dbClient, managedVolumeNativeGuid);
                if (null != viprVolume) {
                    log.info("Skipping volume {} as it is already managed by ViPR", managedVolumeNativeGuid);
                    // export masks.
                    if (isExported) {
                        populateKnownVolsMap(volume, viprVolume, igKnownVolumesMap);
                    }
                    // retrieve snap info to be processed later
                    if (hasSnaps) {
                        StringSet vpoolUriSet = new StringSet();
                        vpoolUriSet.add(viprVolume.getVirtualPool().toString());
                        discoverVolumeSnaps(storageSystem, volume.getSnaps(), viprVolume.getNativeGuid(), vpoolUriSet, xtremIOClient, xioClusterName, dbClient, igUnmanagedVolumesMap, igKnownVolumesMap);
                    }
                    continue;
                }
                String unManagedVolumeNatvieGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingVolume(storageSystem.getNativeGuid(), volume.getVolInfo().get(0));
                // retrieve snap info to be processed later
                unManagedVolume = DiscoveryUtils.checkUnManagedVolumeExistsInDB(dbClient, unManagedVolumeNatvieGuid);
                unManagedVolume = createUnManagedVolume(unManagedVolume, unManagedVolumeNatvieGuid, volume, igUnmanagedVolumesMap, storageSystem, storagePool, dbClient);
                // if the volume is associated with a CG, set up the unmanaged CG
                if (hasCGs) {
                    for (List<Object> cg : volume.getConsistencyGroups()) {
                        // retrieve what should be the first and only consistency group from the list
                        // volumes belonging to multiple cgs are not supported and were excluded above
                        Object cgNameToProcess = cg.get(1);
                        addObjectToUnManagedConsistencyGroup(xtremIOClient, unManagedVolume, cgNameToProcess.toString(), storageSystem, xioClusterName, dbClient);
                    }
                } else {
                    // Make sure the unManagedVolume object does not contain CG information from previous discovery
                    unManagedVolume.getVolumeCharacterstics().put(SupportedVolumeCharacterstics.IS_VOLUME_ADDED_TO_CONSISTENCYGROUP.toString(), Boolean.FALSE.toString());
                    // set the uri of the unmanaged CG in the unmanaged volume object to empty
                    unManagedVolume.getVolumeInformation().put(SupportedVolumeInformation.UNMANAGED_CONSISTENCY_GROUP_URI.toString(), "");
                }
                if (isExported) {
                    Map<String, Integer> igHLUMap = new HashMap<String, Integer>();
                    for (List<Object> lunMapEntries : volume.getLunMaps()) {
                        Double hlu = (Double) lunMapEntries.get(2);
                        log.info("Found HLU {}", hlu);
                        List<Object> igDetails = (List<Object>) lunMapEntries.get(0);
                        // key value IG-HLU
                        igHLUMap.put(igDetails.get(1).toString(), Integer.valueOf(hlu.intValue()));
                    }
                    if (!igHLUMap.isEmpty()) {
                        volumeIGHLUMap.put(unManagedVolumeNatvieGuid, igHLUMap);
                    }
                }
                boolean hasReplicas = false;
                if (hasSnaps) {
                    StringSet parentMatchedVPools = unManagedVolume.getSupportedVpoolUris();
                    StringSet discoveredSnaps = discoverVolumeSnaps(storageSystem, volume.getSnaps(), unManagedVolumeNatvieGuid, parentMatchedVPools, xtremIOClient, xioClusterName, dbClient, igUnmanagedVolumesMap, igKnownVolumesMap);
                    if (!discoveredSnaps.isEmpty()) {
                        hasReplicas = true;
                        // set the HAS_REPLICAS property
                        unManagedVolume.getVolumeCharacterstics().put(SupportedVolumeCharacterstics.HAS_REPLICAS.toString(), TRUE);
                        StringSetMap unManagedVolumeInformation = unManagedVolume.getVolumeInformation();
                        if (unManagedVolumeInformation.containsKey(SupportedVolumeInformation.SNAPSHOTS.toString())) {
                            log.debug("Snaps :" + Joiner.on("\t").join(discoveredSnaps));
                            if (null != discoveredSnaps && discoveredSnaps.isEmpty()) {
                                // replace with empty string set doesn't work, hence added explicit code to remove all
                                unManagedVolumeInformation.get(SupportedVolumeInformation.SNAPSHOTS.toString()).clear();
                            } else {
                                // replace with new StringSet
                                unManagedVolumeInformation.get(SupportedVolumeInformation.SNAPSHOTS.toString()).replace(discoveredSnaps);
                                log.info("Replaced snaps :" + Joiner.on("\t").join(unManagedVolumeInformation.get(SupportedVolumeInformation.SNAPSHOTS.toString())));
                            }
                        } else {
                            unManagedVolumeInformation.put(SupportedVolumeInformation.SNAPSHOTS.toString(), discoveredSnaps);
                        }
                    }
                }
                if (!hasReplicas) {
                    unManagedVolume.getVolumeCharacterstics().put(SupportedVolumeCharacterstics.HAS_REPLICAS.toString(), FALSE);
                    StringSet snapshots = unManagedVolume.getVolumeInformation().get(SupportedVolumeInformation.SNAPSHOTS.toString());
                    if (snapshots != null && !snapshots.isEmpty()) {
                        unManagedVolume.getVolumeInformation().get(SupportedVolumeInformation.SNAPSHOTS.toString()).clear();
                    }
                }
                allCurrentUnManagedVolumeUris.add(unManagedVolume.getId());
            } catch (Exception ex) {
                log.error("Error processing XIO volume {}", volume, ex);
            }
        }
    }
    if (!unManagedCGToUpdateMap.isEmpty()) {
        unManagedCGToUpdate = new ArrayList<UnManagedConsistencyGroup>(unManagedCGToUpdateMap.values());
        partitionManager.updateAndReIndexInBatches(unManagedCGToUpdate, unManagedCGToUpdate.size(), dbClient, UNMANAGED_CONSISTENCY_GROUP);
        unManagedCGToUpdate.clear();
    }
    if (!unManagedVolumesToCreate.isEmpty()) {
        partitionManager.insertInBatches(unManagedVolumesToCreate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_VOLUME);
        unManagedVolumesToCreate.clear();
    }
    if (!unManagedVolumesToUpdate.isEmpty()) {
        partitionManager.updateAndReIndexInBatches(unManagedVolumesToUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_VOLUME);
        unManagedVolumesToUpdate.clear();
    }
    // Process those active unmanaged volume objects available in database but not in newly discovered items, to mark them inactive.
    DiscoveryUtils.markInActiveUnManagedVolumes(storageSystem, allCurrentUnManagedVolumeUris, dbClient, partitionManager);
    // Process those active unmanaged consistency group objects available in database but not in newly discovered items, to mark them
    // inactive.
    DiscoveryUtils.performUnManagedConsistencyGroupsBookKeeping(storageSystem, allCurrentUnManagedCgURIs, dbClient, partitionManager);
    // Next discover the unmanaged export masks
    discoverUnmanagedExportMasks(storageSystem.getId(), igUnmanagedVolumesMap, igKnownVolumesMap, xtremIOClient, xioClusterName, dbClient, partitionManager, volumeIGHLUMap);
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) UnManagedConsistencyGroup(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedConsistencyGroup) HashMap(java.util.HashMap) XtremIOObjectInfo(com.emc.storageos.xtremio.restapi.model.response.XtremIOObjectInfo) XtremIOVolume(com.emc.storageos.xtremio.restapi.model.response.XtremIOVolume) StringSet(com.emc.storageos.db.client.model.StringSet) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) XtremIOVolume(com.emc.storageos.xtremio.restapi.model.response.XtremIOVolume) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) XtremIOClient(com.emc.storageos.xtremio.restapi.XtremIOClient) BlockObject(com.emc.storageos.db.client.model.BlockObject) ZoneInfoMap(com.emc.storageos.db.client.model.ZoneInfoMap) Map(java.util.Map) HashMap(java.util.HashMap) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringMap(com.emc.storageos.db.client.model.StringMap)

Example 88 with UnManagedVolume

use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume in project coprhd-controller by CoprHD.

the class ImplicitUnManagedObjectsMatcher method matchVirtualPoolsWithUnManagedVolumes.

public static void matchVirtualPoolsWithUnManagedVolumes(VirtualPool virtualPool, Set<URI> srdfEnabledTargetVPools, Set<URI> rpEnabledTargetVPools, DbClient dbClient, boolean recalcVplexVolumes) {
    List<UnManagedVolume> modifiedUnManagedVolumes = new ArrayList<UnManagedVolume>();
    Map<String, StringSet> poolMapping = new HashMap<String, StringSet>();
    StringSet invalidPools = null;
    // Otherwise use matched pools
    if (virtualPool.getUseMatchedPools() && null != virtualPool.getMatchedStoragePools()) {
        poolMapping.put(MATCHED, virtualPool.getMatchedStoragePools());
    } else if (null != virtualPool.getAssignedStoragePools()) {
        poolMapping.put(MATCHED, virtualPool.getAssignedStoragePools());
        if (null != virtualPool.getMatchedStoragePools()) {
            // Find out the storage pools which are in matched pools but not in assigned pools.
            // These pools should not be in the supported vpool list
            invalidPools = (StringSet) virtualPool.getMatchedStoragePools().clone();
            invalidPools.removeAll(virtualPool.getAssignedStoragePools());
        }
    }
    if (null != virtualPool.getInvalidMatchedPools()) {
        if (invalidPools == null) {
            invalidPools = virtualPool.getInvalidMatchedPools();
        } else {
            invalidPools.addAll(virtualPool.getInvalidMatchedPools());
        }
    }
    if (invalidPools != null) {
        poolMapping.put(INVALID, invalidPools);
    }
    // matched pools within the same logic.T
    for (Entry<String, StringSet> entry : poolMapping.entrySet()) {
        String key = entry.getKey();
        // loop through matchedPools and later on invalid pools
        for (String pool : entry.getValue()) {
            StorageSystem system = null;
            @SuppressWarnings("deprecation") List<URI> unManagedVolumeUris = dbClient.queryByConstraint(ContainmentConstraint.Factory.getPoolUnManagedVolumeConstraint(URI.create(pool)));
            Iterator<UnManagedVolume> unManagedVolumes = dbClient.queryIterativeObjects(UnManagedVolume.class, unManagedVolumeUris);
            while (unManagedVolumes.hasNext()) {
                UnManagedVolume unManagedVolume = unManagedVolumes.next();
                StringSetMap unManagedVolumeInfo = unManagedVolume.getVolumeInformation();
                if (null == unManagedVolumeInfo) {
                    continue;
                }
                if (system == null) {
                    system = dbClient.queryObject(StorageSystem.class, unManagedVolume.getStorageSystemUri());
                }
                String unManagedVolumeProvisioningType = UnManagedVolume.SupportedProvisioningType.getProvisioningType(unManagedVolume.getVolumeCharacterstics().get(SupportedVolumeCharacterstics.IS_THINLY_PROVISIONED.toString()));
                // remove the vpool from supported Vpool List if present
                if (INVALID.equalsIgnoreCase(key) || !unManagedVolumeProvisioningType.equalsIgnoreCase(virtualPool.getSupportedProvisioningType())) {
                    if (removeVPoolFromUnManagedVolumeObjectVPools(virtualPool, unManagedVolume)) {
                        modifiedUnManagedVolumes.add(unManagedVolume);
                    }
                } else if (addVPoolToUnManagedObjectSupportedVPools(virtualPool, unManagedVolumeInfo, unManagedVolume, system, srdfEnabledTargetVPools, rpEnabledTargetVPools)) {
                    modifiedUnManagedVolumes.add(unManagedVolume);
                }
                if (modifiedUnManagedVolumes.size() > VOLUME_BATCH_SIZE) {
                    insertInBatches(modifiedUnManagedVolumes, dbClient, "UnManagedVolumes");
                    modifiedUnManagedVolumes.clear();
                }
            }
        }
    }
    if (recalcVplexVolumes) {
        // VPLEX unmanaged volumes need to be matched by different rules.
        matchVirtualPoolWithUnManagedVolumeVPLEX(modifiedUnManagedVolumes, virtualPool, dbClient);
    }
    insertInBatches(modifiedUnManagedVolumes, dbClient, "UnManagedVolumes");
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) URI(java.net.URI) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) StringSet(com.emc.storageos.db.client.model.StringSet) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 89 with UnManagedVolume

use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume in project coprhd-controller by CoprHD.

the class ImplicitUnManagedObjectsMatcher method matchVirtualPoolWithUnManagedVolumeVPLEX.

/**
 * Match virtual pool with unmanaged VPLEX volumes.  Uses a different criteria than straight block matchers.
 * Currently this method will only add virtual pools to an unmanaged volume.  It will not remove them.
 * This code is loosely based on VPlexCommunicationInterface.updateUnmanagedVolume() content, but is changed
 * to suit this specific case where a single virtual pool is getting added/updated.
 *
 * @param modifiedUnManagedVolumes list of volumes to add to
 * @param vpool virtual pool (new or updated)
 * @param dbClient dbclient
 */
private static void matchVirtualPoolWithUnManagedVolumeVPLEX(List<UnManagedVolume> modifiedUnManagedVolumes, VirtualPool vpool, DbClient dbClient) {
    // This method only applies to VPLEX vpools
    if (!VirtualPool.vPoolSpecifiesHighAvailability(vpool)) {
        return;
    }
    _log.info("START: matching virtual pool with unmanaged volume for VPLEX");
    // Get all UnManagedVolumes where storageDevice is a StorageSystem where type = VPLEX
    Joiner j = new Joiner(dbClient).join(StorageSystem.class, "ss").match("systemType", "vplex").join("ss", UnManagedVolume.class, "umv", "storageDevice").go();
    // From the joiner, get the StorageSystems (which is a small amount of objects) and the UMVs (which is large, so get URIs and use iter)
    Map<StorageSystem, List<URI>> ssToUmvMap = j.pushList("ss").pushUris("umv").map();
    for (Entry<StorageSystem, List<URI>> ssToUmvEntry : ssToUmvMap.entrySet()) {
        StorageSystem vplex = ssToUmvEntry.getKey();
        // fetch the current mapping of VPLEX cluster ids to cluster names (e.g., "1"=>"cluster-1";"2"=>"cluster-2")
        // the cluster names can be changed by the VPLEX admin, so we cannot rely on the default cluster-1 or cluster-2
        Map<String, String> clusterIdToNameMap = null;
        try {
            VPlexApiClient client = VPlexControllerUtils.getVPlexAPIClient(VPlexApiFactory.getInstance(), vplex, dbClient);
            clusterIdToNameMap = client.getClusterIdToNameMap();
        } catch (Exception ex) {
            _log.warn("Exception caught while getting cluster name info from VPLEX {}", vplex.forDisplay());
        }
        if (null == clusterIdToNameMap || clusterIdToNameMap.isEmpty()) {
            _log.warn("Could not update virtual pool matches for VPLEX {} because cluster name info couldn't be retrieved", vplex.forDisplay());
            continue;
        }
        // Create a map of virtual arrays to their respective VPLEX cluster (a varray is not allowed to have both VPLEX clusters)
        Map<String, String> varrayToClusterIdMap = new HashMap<String, String>();
        // Since there may be a lot of unmanaged volumes to process, we use the iterative query
        Iterator<UnManagedVolume> volumeIter = dbClient.queryIterativeObjects(UnManagedVolume.class, ssToUmvEntry.getValue());
        while (volumeIter.hasNext()) {
            UnManagedVolume volume = volumeIter.next();
            String highAvailability = null;
            if (volume.getVolumeInformation().get(SupportedVolumeInformation.VPLEX_LOCALITY.toString()) != null) {
                String haFound = volume.getVolumeInformation().get(SupportedVolumeInformation.VPLEX_LOCALITY.toString()).iterator().next();
                if (haFound.equalsIgnoreCase(LOCAL)) {
                    highAvailability = VirtualPool.HighAvailabilityType.vplex_local.name();
                } else {
                    highAvailability = VirtualPool.HighAvailabilityType.vplex_distributed.name();
                }
            }
            _log.debug("finding valid virtual pools for UnManagedVolume {}", volume.getLabel());
            // - The vpool is RPVPLEX and this is a VPLEX local volume (likely a journal)
            if (!vpool.getHighAvailability().equals(highAvailability) && !(VirtualPool.vPoolSpecifiesRPVPlex(vpool) && highAvailability.equals(VirtualPool.HighAvailabilityType.vplex_local.name()))) {
                _log.info(String.format("   virtual pool %s is not valid because " + "its high availability setting does not match the unmanaged volume %s", vpool.getLabel(), volume.forDisplay()));
                continue;
            }
            // If the volume is in a CG, the vpool must specify multi-volume consistency.
            Boolean mvConsistency = vpool.getMultivolumeConsistency();
            if ((TRUE.equals(volume.getVolumeCharacterstics().get(SupportedVolumeCharacterstics.IS_VOLUME_ADDED_TO_CONSISTENCYGROUP.toString()))) && ((mvConsistency == null) || (mvConsistency == Boolean.FALSE))) {
                _log.info(String.format("   virtual pool %s is not valid because it does not have the " + "multi-volume consistency flag set, and the unmanaged volume %s is in a consistency group", vpool.getLabel(), volume.forDisplay()));
                continue;
            }
            StringSet volumeClusters = new StringSet();
            if (volume.getVolumeInformation().get(SupportedVolumeInformation.VPLEX_CLUSTER_IDS.toString()) != null) {
                volumeClusters.addAll(volume.getVolumeInformation().get(SupportedVolumeInformation.VPLEX_CLUSTER_IDS.toString()));
            }
            // VPool must be assigned to a varray corresponding to volume's clusters.
            StringSet varraysForVpool = vpool.getVirtualArrays();
            for (String varrayId : varraysForVpool) {
                String varrayClusterId = varrayToClusterIdMap.get(varrayId);
                if (null == varrayClusterId) {
                    varrayClusterId = ConnectivityUtil.getVplexClusterForVarray(URI.create(varrayId), vplex.getId(), dbClient);
                    varrayToClusterIdMap.put(varrayId, varrayClusterId);
                }
                if (!ConnectivityUtil.CLUSTER_UNKNOWN.equals(varrayClusterId)) {
                    String varrayClusterName = clusterIdToNameMap.get(varrayClusterId);
                    if (volumeClusters.contains(varrayClusterName)) {
                        if (volume.getSupportedVpoolUris() == null) {
                            volume.setSupportedVpoolUris(new StringSet());
                        }
                        volume.getSupportedVpoolUris().add(vpool.getId().toString());
                        List<UnManagedVolume> backendVols = VplexBackendIngestionContext.findBackendUnManagedVolumes(volume, dbClient);
                        if (backendVols != null) {
                            for (UnManagedVolume backendVol : backendVols) {
                                if (backendVol.getSupportedVpoolUris() == null) {
                                    backendVol.setSupportedVpoolUris(new StringSet());
                                }
                                backendVol.getSupportedVpoolUris().add(vpool.getId().toString());
                                modifiedUnManagedVolumes.add(backendVol);
                            }
                        }
                        modifiedUnManagedVolumes.add(volume);
                        break;
                    }
                }
            }
            if (!modifiedUnManagedVolumes.contains(volume)) {
                _log.info(String.format("   virtual pool %s is not valid because " + "volume %s resides on a cluster that does not match the varray(s) associated with the vpool", vpool.getLabel(), volume.forDisplay()));
            }
        }
    }
    _log.info("END: matching virtual pool with unmanaged volume for VPLEX");
}
Also used : Joiner(com.emc.storageos.db.joiner.Joiner) HashMap(java.util.HashMap) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) VPlexApiClient(com.emc.storageos.vplex.api.VPlexApiClient) StringSet(com.emc.storageos.db.client.model.StringSet) ArrayList(java.util.ArrayList) List(java.util.List) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 90 with UnManagedVolume

use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume in project coprhd-controller by CoprHD.

the class VNXeUnManagedObjectDiscoverer method discoverUnManagedVolumes.

public void discoverUnManagedVolumes(AccessProfile accessProfile, DbClient dbClient, CoordinatorClient coordinator, PartitionManager partitionManager) throws Exception {
    log.info("Started discovery of UnManagedVolumes for system {}", accessProfile.getSystemId());
    VNXeApiClient apiClient = getVnxeClient(accessProfile);
    unManagedVolumesInsert = new ArrayList<UnManagedVolume>();
    unManagedVolumesUpdate = new ArrayList<UnManagedVolume>();
    StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
    List<VNXeLun> luns = apiClient.getAllLuns();
    if (luns != null && !luns.isEmpty()) {
        Map<String, StoragePool> pools = getStoragePoolMap(storageSystem, dbClient);
        for (VNXeLun lun : luns) {
            UnManagedVolume unManagedVolume = null;
            String managedVolumeNativeGuid = NativeGUIDGenerator.generateNativeGuidForVolumeOrBlockSnapShot(storageSystem.getNativeGuid(), lun.getId());
            if (null != DiscoveryUtils.checkStorageVolumeExistsInDB(dbClient, managedVolumeNativeGuid)) {
                log.info("Skipping volume {} as it is already managed by ViPR", managedVolumeNativeGuid);
            }
            StoragePool storagePool = getStoragePoolOfUnManagedObject(lun.getPool().getId(), storageSystem, pools);
            if (null == storagePool) {
                log.error("Skipping unmanaged volume discovery as the volume {} storage pool doesn't exist in ViPR", lun.getId());
                continue;
            }
            String unManagedVolumeNatvieGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingVolume(storageSystem.getNativeGuid(), lun.getId());
            unManagedVolume = DiscoveryUtils.checkUnManagedVolumeExistsInDB(dbClient, unManagedVolumeNatvieGuid);
            unManagedVolume = createUnManagedVolume(unManagedVolume, unManagedVolumeNatvieGuid, lun, storageSystem, storagePool, dbClient);
            unManagedVolumesReturnedFromProvider.add(unManagedVolume.getId());
        }
        if (!unManagedVolumesInsert.isEmpty()) {
            partitionManager.insertInBatches(unManagedVolumesInsert, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_VOLUME);
        }
        if (!unManagedVolumesUpdate.isEmpty()) {
            partitionManager.updateAndReIndexInBatches(unManagedVolumesUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_VOLUME);
        }
        // Process those active unmanaged volume objects available in database but not in newly discovered items, to mark them inactive.
        DiscoveryUtils.markInActiveUnManagedVolumes(storageSystem, unManagedVolumesReturnedFromProvider, dbClient, partitionManager);
    } else {
        log.info("There are no luns found on the system: {}", storageSystem.getId());
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) VNXeLun(com.emc.storageos.vnxe.models.VNXeLun) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)146 StringSet (com.emc.storageos.db.client.model.StringSet)66 URI (java.net.URI)53 Volume (com.emc.storageos.db.client.model.Volume)48 ArrayList (java.util.ArrayList)48 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)33 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)31 BlockObject (com.emc.storageos.db.client.model.BlockObject)30 HashMap (java.util.HashMap)29 HashSet (java.util.HashSet)24 NamedURI (com.emc.storageos.db.client.model.NamedURI)19 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)19 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)18 DataObject (com.emc.storageos.db.client.model.DataObject)13 UnManagedExportMask (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask)13 CIMObjectPath (javax.cim.CIMObjectPath)13 UnManagedProtectionSet (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet)12 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)11 Map (java.util.Map)11 StringMap (com.emc.storageos.db.client.model.StringMap)10