Search in sources :

Example 81 with UnManagedVolume

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

the class XtremIOUnManagedVolumeDiscoverer method discoverUnmanagedExportMasks.

/**
 * Group existing known initiators by Host.
 * For each HostName in HostGroup
 * 1. Get List of IGs associated with Host
 * 2. For each IG, get unmanaged and managed volumes
 * 3. create/update mask with volumes/initiators/ports
 *
 * @param systemId
 * @param igUnmanagedVolumesMap IgName--Unmanaged volume list
 * @param igKnownVolumesMap IgName -- managed volume list
 * @param xtremIOClient
 * @param dbClient
 * @param partitionManager
 * @param volumeIGHLUMap
 * @throws Exception
 */
private void discoverUnmanagedExportMasks(URI systemId, Map<String, List<UnManagedVolume>> igUnmanagedVolumesMap, Map<String, StringSet> igKnownVolumesMap, XtremIOClient xtremIOClient, String xioClusterName, DbClient dbClient, PartitionManager partitionManager, Map<String, Map<String, Integer>> volumeIGHLUMap) throws Exception {
    unManagedExportMasksToCreate = new ArrayList<UnManagedExportMask>();
    unManagedExportMasksToUpdate = new ArrayList<UnManagedExportMask>();
    List<UnManagedVolume> unManagedExportVolumesToUpdate = new ArrayList<UnManagedVolume>();
    // In XtremIO, the volumes are exposed through all the storage ports.
    // Get all the storage ports of xtremIO to be added as known ports in the unmanaged export mask
    // If the host ports are FC, then all add all FC storage ports to the mask
    // else add all IP ports
    StringSet knownFCStoragePortUris = new StringSet();
    StringSet knownIPStoragePortUris = new StringSet();
    List<StoragePort> matchedFCPorts = new ArrayList<StoragePort>();
    URIQueryResultList storagePortURIs = new URIQueryResultList();
    dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePortConstraint(systemId), storagePortURIs);
    Iterator<URI> portsItr = storagePortURIs.iterator();
    while (portsItr.hasNext()) {
        URI storagePortURI = portsItr.next();
        StoragePort port = dbClient.queryObject(StoragePort.class, storagePortURI);
        if (TransportType.FC.toString().equals(port.getTransportType())) {
            knownFCStoragePortUris.add(storagePortURI.toString());
            matchedFCPorts.add(port);
        } else if (TransportType.IP.toString().equals(port.getTransportType())) {
            knownIPStoragePortUris.add(storagePortURI.toString());
        }
    }
    // Group all the initiators and their initiator groups based on ViPR host.
    // To be used for constructing unmanaged export masks
    Map<String, List<Initiator>> hostInitiatorsMap = new HashMap<String, List<Initiator>>();
    Map<String, Set<String>> hostIGNamesMap = new HashMap<String, Set<String>>();
    List<XtremIOInitiator> initiators = xtremIOClient.getXtremIOInitiatorsInfo(xioClusterName);
    for (XtremIOInitiator initiator : initiators) {
        String initiatorNetworkId = initiator.getPortAddress();
        // check if a host initiator exists for this id
        Initiator knownInitiator = NetworkUtil.getInitiator(initiatorNetworkId, dbClient);
        if (knownInitiator == null) {
            // TODO need to think of ways to handle unknown initiators
            continue;
        }
        // Special case for RP: group masks by cluster.
        String hostName = knownInitiator.checkInternalFlags(Flag.RECOVERPOINT) ? knownInitiator.getClusterName() : knownInitiator.getHostName();
        if (hostName != null && !hostName.isEmpty()) {
            log.info("   found an initiator in ViPR on host " + hostName);
            String igName = initiator.getInitiatorGroup().get(1);
            List<Initiator> hostInitiators = hostInitiatorsMap.get(hostName);
            Set<String> hostIGNames = hostIGNamesMap.get(hostName);
            if (hostInitiators == null) {
                hostInitiators = new ArrayList<Initiator>();
                hostInitiatorsMap.put(hostName, hostInitiators);
            }
            if (hostIGNames == null) {
                hostIGNames = new HashSet<String>();
                hostIGNamesMap.put(hostName, hostIGNames);
            }
            hostInitiators.add(knownInitiator);
            hostIGNames.add(igName);
        }
    }
    // create export mask per vipr host
    for (String hostname : hostInitiatorsMap.keySet()) {
        StringSet knownIniSet = new StringSet();
        StringSet knownNetworkIdSet = new StringSet();
        StringSet knownVolumeSet = new StringSet();
        List<Initiator> matchedFCInitiators = new ArrayList<Initiator>();
        List<Initiator> hostInitiators = hostInitiatorsMap.get(hostname);
        Set<String> hostIGs = hostIGNamesMap.get(hostname);
        Map<String, List<String>> rpVolumeSnapMap = new HashMap<String, List<String>>();
        Map<String, UnManagedVolume> rpVolumeMap = new HashMap<String, UnManagedVolume>();
        boolean isRpBackendMask = false;
        if (ExportUtils.checkIfInitiatorsForRP(hostInitiators)) {
            log.info("host {} contains RP initiators, " + "so this mask contains RP protected volumes", hostname);
            isRpBackendMask = true;
        }
        boolean isVplexBackendMask = false;
        for (Initiator hostInitiator : hostInitiators) {
            if (!isVplexBackendMask && VPlexControllerUtils.isVplexInitiator(hostInitiator, dbClient)) {
                log.info("host {} contains VPLEX backend ports, " + "so this mask contains VPLEX backend volumes", hostname);
                isVplexBackendMask = true;
            }
            knownIniSet.add(hostInitiator.getId().toString());
            knownNetworkIdSet.add(hostInitiator.getInitiatorPort());
            if (HostInterface.Protocol.FC.toString().equals(hostInitiator.getProtocol())) {
                matchedFCInitiators.add(hostInitiator);
            }
        }
        UnManagedExportMask mask = getUnManagedExportMask(hostInitiators.get(0).getInitiatorPort(), dbClient, systemId);
        mask.setStorageSystemUri(systemId);
        // set the host name as the mask name
        mask.setMaskName(hostname);
        allCurrentUnManagedExportMaskUris.add(mask.getId());
        for (String igName : hostIGs) {
            StringSet knownVols = igKnownVolumesMap.get(igName);
            if (knownVols != null) {
                knownVolumeSet.addAll(knownVols);
            }
            List<UnManagedVolume> hostUnManagedVols = igUnmanagedVolumesMap.get(igName);
            if (hostUnManagedVols != null) {
                for (UnManagedVolume hostUnManagedVol : hostUnManagedVols) {
                    hostUnManagedVol.getInitiatorNetworkIds().addAll(knownNetworkIdSet);
                    hostUnManagedVol.getInitiatorUris().addAll(knownIniSet);
                    hostUnManagedVol.getUnmanagedExportMasks().add(mask.getId().toString());
                    String nativeGuid = hostUnManagedVol.getNativeGuid();
                    Map<String, Integer> igHLUMap = volumeIGHLUMap.get(nativeGuid);
                    if (igHLUMap != null) {
                        Integer hlu = igHLUMap.get(igName);
                        if (hlu != null) {
                            StringSet hostHlu = new StringSet();
                            hostHlu.add(hostname + "=" + hlu);
                            StringSet existingHostHlu = (StringSet) hostUnManagedVol.getVolumeInformation().get(SupportedVolumeInformation.HLU_TO_EXPORT_MASK_NAME_MAP.toString());
                            if (existingHostHlu != null) {
                                hostHlu.addAll(existingHostHlu);
                            }
                            hostUnManagedVol.getVolumeInformation().put(SupportedVolumeInformation.HLU_TO_EXPORT_MASK_NAME_MAP.toString(), hostHlu);
                        }
                    }
                    if (isVplexBackendMask) {
                        log.info("marking unmanaged Xtremio volume {} as a VPLEX backend volume", hostUnManagedVol.getLabel());
                        hostUnManagedVol.putVolumeCharacterstics(SupportedVolumeCharacterstics.IS_VPLEX_BACKEND_VOLUME.toString(), TRUE);
                    }
                    // volume IS associated with RP, we want to mark that volume as RP enabled.
                    if (!isRpBackendMask) {
                        log.info("unmanaged volume {} is exported to something other than RP.  Marking IS_NONRP_EXPORTED.", hostUnManagedVol.forDisplay());
                        hostUnManagedVol.putVolumeCharacterstics(SupportedVolumeCharacterstics.IS_NONRP_EXPORTED.toString(), TRUE);
                    } else {
                        log.info("unmanaged volume {} is an RP volume", hostUnManagedVol.getLabel());
                        hostUnManagedVol.putVolumeCharacterstics(SupportedVolumeCharacterstics.IS_RECOVERPOINT_ENABLED.toString(), TRUE);
                        rpVolumeMap.put(hostUnManagedVol.getNativeGuid(), hostUnManagedVol);
                    }
                    if (hostUnManagedVol != null) {
                        mask.getUnmanagedVolumeUris().add(hostUnManagedVol.getId().toString());
                        unManagedExportVolumesToUpdate.add(hostUnManagedVol);
                    }
                }
            }
        }
        mask.replaceNewWithOldResources(knownIniSet, knownNetworkIdSet, knownVolumeSet, !matchedFCInitiators.isEmpty() ? knownFCStoragePortUris : knownIPStoragePortUris);
        updateZoningMap(mask, matchedFCInitiators, matchedFCPorts);
        if (!unManagedExportMasksToCreate.isEmpty()) {
            partitionManager.insertInBatches(unManagedExportMasksToCreate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_EXPORT_MASK);
            unManagedExportMasksToCreate.clear();
        }
        if (!unManagedExportMasksToUpdate.isEmpty()) {
            partitionManager.updateInBatches(unManagedExportMasksToUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_EXPORT_MASK);
            unManagedExportMasksToUpdate.clear();
        }
        if (!unManagedExportVolumesToUpdate.isEmpty()) {
            partitionManager.updateAndReIndexInBatches(unManagedExportVolumesToUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_VOLUME);
            unManagedExportVolumesToUpdate.clear();
        }
        DiscoveryUtils.markInActiveUnManagedExportMask(systemId, allCurrentUnManagedExportMaskUris, dbClient, partitionManager);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) StringSet(com.emc.storageos.db.client.model.StringSet) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) XtremIOInitiator(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator) XtremIOInitiator(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator) Initiator(com.emc.storageos.db.client.model.Initiator) StringSet(com.emc.storageos.db.client.model.StringSet) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask) StoragePort(com.emc.storageos.db.client.model.StoragePort) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)

Example 82 with UnManagedVolume

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

the class ExternalDeviceUnManagedVolumeDiscoverer method processUnManagedClones.

/**
 * Process clones of unManaged volume.
 * Check if unManaged clone should be created and create unManaged volume instance for a clone in such a case.
 * Add unManaged clone to parent volume CG if needed and update the clone with parent volume CG information.
 * Gets export information for clones and stores it in the provided map.
 *
 * @param driverVolume              driver volume for clone parent volume. [IN]
 * @param unManagedParentVolume     unManaged parent volume [IN/OUT]
 * @param storageSystem             storage system [IN]
 * @param storagePool               storage pool [IN]
 * @param unManagedVolumesToCreate  list of unmanaged volumes to create [OUT]
 * @param unManagedVolumesToUpdate  list of unmanaged volumes to update [OUT]
 * @param allCurrentUnManagedCgURIs set of unManaged CG uris found in the current discovery [OUT]
 * @param unManagedCGToUpdateMap    map of unManaged CG GUID to unManaged CG instance [IN/OUT]
 * @param unManagedVolumeNativeIdToUriMap map of unmanaged volumes nativeId to their uri [OUT]
 * @param hostToUnManagedVolumeExportInfoMap map  with export data for unmanaged volumes (including snaps and clones)
 * @param driver                    storage driver [IN]
 * @param dbClient                  reference to db client [IN]
 * @return                          set of URIs for unmanaged clones
 * @throws Exception
 */
private Set<URI> processUnManagedClones(StorageVolume driverVolume, UnManagedVolume unManagedParentVolume, com.emc.storageos.db.client.model.StorageSystem storageSystem, com.emc.storageos.db.client.model.StoragePool storagePool, List<UnManagedVolume> unManagedVolumesToCreate, List<UnManagedVolume> unManagedVolumesToUpdate, Set<URI> allCurrentUnManagedCgURIs, Map<String, UnManagedConsistencyGroup> unManagedCGToUpdateMap, Map<String, URI> unManagedVolumeNativeIdToUriMap, Map<String, List<HostExportInfo>> hostToUnManagedVolumeExportInfoMap, BlockStorageDriver driver, DbClient dbClient) throws Exception {
    log.info("Processing clones for volume {} ", unManagedParentVolume.getNativeGuid());
    Set<URI> cloneUris = new HashSet<>();
    List<VolumeClone> driverClones = driver.getVolumeClones(driverVolume);
    if (driverClones == null || driverClones.isEmpty()) {
        log.info("There are no clones for volume {} ", unManagedParentVolume.getNativeGuid());
    } else {
        log.info("Clones for unManaged volume {}:" + Joiner.on("\t").join(driverClones), unManagedParentVolume.getNativeGuid());
        StringSet unManagedClones = new StringSet();
        for (VolumeClone driverClone : driverClones) {
            String managedCloneNativeGuid = NativeGUIDGenerator.generateNativeGuidForVolumeOrBlockSnapShot(storageSystem.getNativeGuid(), driverClone.getNativeId());
            Volume systemClone = DiscoveryUtils.checkStorageVolumeExistsInDB(dbClient, managedCloneNativeGuid);
            if (null != systemClone) {
                log.info("Skipping clone {} as it is already managed by the system.", managedCloneNativeGuid);
                continue;
            }
            String unManagedCloneNatvieGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingVolume(storageSystem.getNativeGuid(), driverClone.getNativeId());
            UnManagedVolume unManagedClone = createUnManagedClone(driverClone, unManagedParentVolume, storageSystem, storagePool, unManagedVolumesToCreate, unManagedVolumesToUpdate, dbClient);
            cloneUris.add(unManagedClone.getId());
            unManagedClones.add(unManagedCloneNatvieGuid);
            // Check if this clone is for a volume in consistency group on device.
            String isParentVolumeInCG = unManagedParentVolume.getVolumeCharacterstics().get(UnManagedVolume.SupportedVolumeCharacterstics.IS_VOLUME_ADDED_TO_CONSISTENCYGROUP.toString());
            if (isParentVolumeInCG.equals(Boolean.TRUE.toString())) {
                log.info("Clone {} is for volume in CG. ", managedCloneNativeGuid);
                // add clone to parent volume unManaged consistency group, update clone with parent volume CG information.
                addObjectToUnManagedConsistencyGroup(storageSystem, driverVolume.getConsistencyGroup(), unManagedClone, allCurrentUnManagedCgURIs, unManagedCGToUpdateMap, driver, dbClient);
            }
            // get export data for the clone
            unManagedVolumeNativeIdToUriMap.put(driverClone.getNativeId(), unManagedClone.getId());
            getCloneExportInfo(driver, driverClone, hostToUnManagedVolumeExportInfoMap);
        }
        if (!unManagedClones.isEmpty()) {
            // set the HAS_REPLICAS property
            unManagedParentVolume.getVolumeCharacterstics().put(UnManagedVolume.SupportedVolumeCharacterstics.HAS_REPLICAS.toString(), TRUE);
            StringSetMap unManagedVolumeInformation = unManagedParentVolume.getVolumeInformation();
            log.info("New unManaged clones for unManaged volume {}:" + Joiner.on("\t").join(unManagedClones), unManagedParentVolume.getNativeGuid());
            if (unManagedVolumeInformation.containsKey(UnManagedVolume.SupportedVolumeInformation.FULL_COPIES.toString())) {
                log.info("Old unManaged clones for unManaged volume {}:" + Joiner.on("\t").join(unManagedVolumeInformation.get(UnManagedVolume.SupportedVolumeInformation.FULL_COPIES.toString())), unManagedParentVolume.getNativeGuid());
                // replace with new StringSet
                unManagedVolumeInformation.get(UnManagedVolume.SupportedVolumeInformation.FULL_COPIES.toString()).replace(unManagedClones);
                log.info("Replaced clones :" + Joiner.on("\t").join(unManagedVolumeInformation.get(UnManagedVolume.SupportedVolumeInformation.FULL_COPIES.toString())));
            } else {
                unManagedVolumeInformation.put(UnManagedVolume.SupportedVolumeInformation.FULL_COPIES.toString(), unManagedClones);
            }
        } else {
            log.info("All clones for volume {} are already managed.", unManagedParentVolume.getNativeGuid());
        }
    }
    return cloneUris;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) 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) StringSet(com.emc.storageos.db.client.model.StringSet) VolumeClone(com.emc.storageos.storagedriver.model.VolumeClone) URI(java.net.URI) HashSet(java.util.HashSet)

Example 83 with UnManagedVolume

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

the class ExternalDeviceUnManagedVolumeDiscoverer method removeInvalidMaskDataFromVolumes.

/**
 * Removes id of invalid unmanaged export mask from unmanaged volumes in this mask.
 * Removes initiators for this mask from volumes and does other cleanup in the volumes properties
 * related to export as required.
 *
 * @param unManagedMask unmanaged mask [IN]
 * @param dbClient reference to db client [IN]
 */
void removeInvalidMaskDataFromVolumes(UnManagedExportMask unManagedMask, DbClient dbClient) {
    Set<UnManagedVolume> unManagedVolumesToUpdate = new HashSet<>();
    String unManagedMaskId = unManagedMask.getId().toString();
    StringSet knownInitiatorUris = unManagedMask.getKnownInitiatorUris();
    StringSet knownInitiatorNetworkIds = unManagedMask.getKnownInitiatorNetworkIds();
    StringSet volumeUris = unManagedMask.getUnmanagedVolumeUris();
    for (String volumeUriString : volumeUris) {
        URI volumeUri = URI.create(volumeUriString);
        UnManagedVolume volume = dbClient.queryObject(UnManagedVolume.class, volumeUri);
        if (volume != null) {
            StringSet unManagedMasks = volume.getUnmanagedExportMasks();
            unManagedMasks.remove(unManagedMaskId);
            volume.getInitiatorUris().removeAll(knownInitiatorUris);
            volume.getInitiatorNetworkIds().removeAll(knownInitiatorNetworkIds);
            if (unManagedMasks.isEmpty()) {
                volume.getVolumeCharacterstics().put(UnManagedVolume.SupportedVolumeCharacterstics.IS_VOLUME_EXPORTED.toString(), FALSE);
                volume.getVolumeCharacterstics().put(UnManagedVolume.SupportedVolumeCharacterstics.IS_NONRP_EXPORTED.toString(), FALSE);
            }
            unManagedVolumesToUpdate.add(volume);
        }
    }
    dbClient.updateObject(unManagedVolumesToUpdate);
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) StringSet(com.emc.storageos.db.client.model.StringSet) URI(java.net.URI) HashSet(java.util.HashSet)

Example 84 with UnManagedVolume

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

the class VNXUnityUnManagedObjectDiscoverer method createUnManagedVolumeForSnap.

/**
 * Creates a new UnManagedVolume with the given arguments for a snap.
 *
 * @param unManagedVolumeNativeGuid
 * @param lun
 * @param system
 * @param pool
 * @param dbClient
 * @param hostVolumeMap
 *            hosts and exported volumes map
 * @param snap
 *            detail of the snap
 * @return
 */
private UnManagedVolume createUnManagedVolumeForSnap(UnManagedVolume unManagedVolume, String unManagedVolumeNativeGuid, VNXeLun lun, StorageSystem system, DbClient dbClient, Map<String, List<UnManagedVolume>> hostVolumeMap, Snap snap) {
    boolean created = false;
    if (null == unManagedVolume) {
        unManagedVolume = new UnManagedVolume();
        unManagedVolume.setId(URIUtil.createId(UnManagedVolume.class));
        unManagedVolume.setNativeGuid(unManagedVolumeNativeGuid);
        unManagedVolume.setStorageSystemUri(system.getId());
        created = true;
    }
    unManagedVolume.setLabel(snap.getName());
    StringSetMap unManagedVolumeInformation = new StringSetMap();
    Map<String, String> unManagedVolumeCharacteristics = new HashMap<String, String>();
    Boolean isSnapExported = false;
    if (lun.getHostAccess() != null && !lun.getHostAccess().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();
        for (BlockHostAccess access : lun.getHostAccess()) {
            int accessMask = access.getAccessMask();
            if (accessMask == BlockHostAccess.HostLUNAccessEnum.BOTH.getValue() || accessMask == BlockHostAccess.HostLUNAccessEnum.SNAPSHOT.getValue()) {
                isSnapExported = true;
                String hostId = access.getHost().getId();
                List<UnManagedVolume> exportedSnaps = hostVolumeMap.get(hostId);
                if (exportedSnaps == null) {
                    exportedSnaps = new ArrayList<UnManagedVolume>();
                    hostVolumeMap.put(hostId, exportedSnaps);
                }
                exportedSnaps.add(unManagedVolume);
            }
        }
    }
    unManagedVolumeCharacteristics.put(SupportedVolumeCharacterstics.IS_VOLUME_EXPORTED.toString(), isSnapExported.toString());
    StringSet deviceLabel = new StringSet();
    deviceLabel.add(snap.getName());
    unManagedVolumeInformation.put(SupportedVolumeInformation.DEVICE_LABEL.toString(), deviceLabel);
    String snapWWN = snap.getAttachedWWN();
    if (snapWWN != null && !snapWWN.isEmpty()) {
        String volumeWWN = snapWWN.replaceAll(":", "");
        unManagedVolume.setWwn(volumeWWN);
    }
    StringSet systemTypes = new StringSet();
    systemTypes.add(system.getSystemType());
    StringSet provCapacity = new StringSet();
    provCapacity.add(String.valueOf(snap.getSize()));
    unManagedVolumeInformation.put(SupportedVolumeInformation.PROVISIONED_CAPACITY.toString(), provCapacity);
    StringSet allocatedCapacity = new StringSet();
    allocatedCapacity.add(String.valueOf(snap.getSize()));
    unManagedVolumeInformation.put(SupportedVolumeInformation.ALLOCATED_CAPACITY.toString(), allocatedCapacity);
    unManagedVolumeInformation.put(SupportedVolumeInformation.SYSTEM_TYPE.toString(), systemTypes);
    StringSet nativeId = new StringSet();
    nativeId.add(snap.getId());
    unManagedVolumeInformation.put(SupportedVolumeInformation.NATIVE_ID.toString(), nativeId);
    unManagedVolumeCharacteristics.put(SupportedVolumeCharacterstics.IS_INGESTABLE.toString(), Boolean.TRUE.toString());
    unManagedVolumeCharacteristics.put(SupportedVolumeCharacterstics.IS_THINLY_PROVISIONED.toString(), lun.getIsThinEnabled().toString());
    unManagedVolume.setVolumeInformation(unManagedVolumeInformation);
    if (unManagedVolume.getVolumeCharacterstics() == null) {
        unManagedVolume.setVolumeCharacterstics(new StringMap());
    }
    unManagedVolume.getVolumeCharacterstics().replace(unManagedVolumeCharacteristics);
    if (created) {
        unManagedVolumesInsert.add(unManagedVolume);
    } else {
        unManagedVolumesUpdate.add(unManagedVolume);
    }
    return unManagedVolume;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringMap(com.emc.storageos.db.client.model.StringMap) HashMap(java.util.HashMap) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) BlockHostAccess(com.emc.storageos.vnxe.models.BlockHostAccess) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) StringSet(com.emc.storageos.db.client.model.StringSet)

Example 85 with UnManagedVolume

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

the class VNXUnityUnManagedObjectDiscoverer method createUnManagedVolume.

/**
 * Creates a new UnManagedVolume with the given arguments.
 *
 * @param unManagedVolumeNativeGuid
 * @param lun
 * @param system
 * @param pool
 * @param dbClient
 * @param hostVolumeMap
 *            hosts and exported volumes map
 * @return
 */
private UnManagedVolume createUnManagedVolume(UnManagedVolume unManagedVolume, String unManagedVolumeNativeGuid, VNXeLun lun, StorageSystem system, StoragePool pool, DbClient dbClient, Map<String, List<UnManagedVolume>> hostVolumeMap) {
    boolean created = false;
    if (null == unManagedVolume) {
        unManagedVolume = new UnManagedVolume();
        unManagedVolume.setId(URIUtil.createId(UnManagedVolume.class));
        unManagedVolume.setNativeGuid(unManagedVolumeNativeGuid);
        unManagedVolume.setStorageSystemUri(system.getId());
        unManagedVolume.setStoragePoolUri(pool.getId());
        created = true;
    }
    unManagedVolume.setLabel(lun.getName());
    StringSetMap unManagedVolumeInformation = new StringSetMap();
    Map<String, String> unManagedVolumeCharacteristics = new HashMap<String, String>();
    Boolean isVolumeExported = false;
    if (lun.getHostAccess() != null && !lun.getHostAccess().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();
        for (BlockHostAccess access : lun.getHostAccess()) {
            int accessMask = access.getAccessMask();
            if (accessMask == BlockHostAccess.HostLUNAccessEnum.BOTH.getValue() || accessMask == BlockHostAccess.HostLUNAccessEnum.PRODUCTION.getValue()) {
                isVolumeExported = true;
                String hostId = access.getHost().getId();
                List<UnManagedVolume> exportedVolumes = hostVolumeMap.get(hostId);
                if (exportedVolumes == null) {
                    exportedVolumes = new ArrayList<UnManagedVolume>();
                    hostVolumeMap.put(hostId, exportedVolumes);
                }
                exportedVolumes.add(unManagedVolume);
            }
        }
    }
    unManagedVolumeCharacteristics.put(SupportedVolumeCharacterstics.IS_VOLUME_EXPORTED.toString(), isVolumeExported.toString());
    unManagedVolumeCharacteristics.put(SupportedVolumeCharacterstics.IS_NONRP_EXPORTED.toString(), Boolean.FALSE.toString());
    unManagedVolumeCharacteristics.put(SupportedVolumeCharacterstics.IS_RECOVERPOINT_ENABLED.toString(), Boolean.FALSE.toString());
    StringSet deviceLabel = new StringSet();
    deviceLabel.add(lun.getName());
    unManagedVolumeInformation.put(SupportedVolumeInformation.DEVICE_LABEL.toString(), deviceLabel);
    String volumeWWN = lun.getWwn().replaceAll(":", "");
    unManagedVolume.setWwn(volumeWWN);
    StringSet systemTypes = new StringSet();
    systemTypes.add(system.getSystemType());
    StringSet provCapacity = new StringSet();
    provCapacity.add(String.valueOf(lun.getSizeTotal()));
    unManagedVolumeInformation.put(SupportedVolumeInformation.PROVISIONED_CAPACITY.toString(), provCapacity);
    StringSet allocatedCapacity = new StringSet();
    allocatedCapacity.add(String.valueOf(lun.getSizeAllocated()));
    unManagedVolumeInformation.put(SupportedVolumeInformation.ALLOCATED_CAPACITY.toString(), allocatedCapacity);
    unManagedVolumeInformation.put(SupportedVolumeInformation.SYSTEM_TYPE.toString(), systemTypes);
    StringSet nativeId = new StringSet();
    nativeId.add(lun.getId());
    unManagedVolumeInformation.put(SupportedVolumeInformation.NATIVE_ID.toString(), nativeId);
    unManagedVolumeCharacteristics.put(SupportedVolumeCharacterstics.IS_INGESTABLE.toString(), Boolean.TRUE.toString());
    unManagedVolumeCharacteristics.put(SupportedVolumeCharacterstics.IS_THINLY_PROVISIONED.toString(), lun.getIsThinEnabled().toString());
    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);
    // clear the mask to HLU map. Fresh data gets persisted during UnManagedExportMask discovery
    if (unManagedVolume.getVolumeInformation().get(SupportedVolumeInformation.HLU_TO_EXPORT_MASK_NAME_MAP.name()) != null) {
        unManagedVolume.getVolumeInformation().get(SupportedVolumeInformation.HLU_TO_EXPORT_MASK_NAME_MAP.name()).clear();
    }
    if (created) {
        unManagedVolumesInsert.add(unManagedVolume);
    } else {
        unManagedVolumesUpdate.add(unManagedVolume);
    }
    return unManagedVolume;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringMap(com.emc.storageos.db.client.model.StringMap) HashMap(java.util.HashMap) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) BlockHostAccess(com.emc.storageos.vnxe.models.BlockHostAccess) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) StringSet(com.emc.storageos.db.client.model.StringSet)

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