Search in sources :

Example 1 with StorageGroupPolicyLimitsParam

use of com.emc.storageos.volumecontroller.impl.StorageGroupPolicyLimitsParam in project coprhd-controller by CoprHD.

the class SmisCommandHelper method findPhantomStorageGroupAssociatedWithFastPolicy.

/**
 * Find a phantom (not belonging to any masking view) with matches the FAST (auto-tiering) policy name and limits
 * setting
 *
 * @param storage
 *            storage device
 * @param storageGroupPolicyLimitsParam
 *            policy name and limits setting
 * @return name of storage group that is a phantom SG with that policy, otherwise null
 * @throws Exception
 */
public List<String> findPhantomStorageGroupAssociatedWithFastPolicy(StorageSystem storage, StorageGroupPolicyLimitsParam storageGroupPolicyLimitsParam) throws Exception {
    CloseableIterator<CIMObjectPath> cimPathItr = null;
    List<String> sgNames = new ArrayList<String>();
    try {
        // Get all storage groups
        _log.info("findPhantomStorageGroupAssociatedWithFastPolicy START: " + storageGroupPolicyLimitsParam);
        Map<StorageGroupPolicyLimitsParam, Set<String>> allStorageGroups = getExistingSGNamesFromArray(storage);
        Set<String> storageGroupsOfPolicy = allStorageGroups.get(storageGroupPolicyLimitsParam);
        if (storageGroupsOfPolicy == null || storageGroupsOfPolicy.isEmpty()) {
            return null;
        }
        for (String storageGroupName : storageGroupsOfPolicy) {
            StringSet policyNames = findTierPoliciesForStorageGroup(storage, storageGroupName);
            CIMObjectPath storageGroupPath = _cimPath.getStorageGroupObjectPath(storageGroupName, storage);
            if (this.isCascadedSG(storage, storageGroupPath)) {
                _log.info("findPhantomStorageGroupAssociatedWithFastPolicy avoiding storage group: " + storageGroupName + " because it is a parent storage group.");
                continue;
            }
            _log.debug("findPhantomStorageGroupAssociatedWithFastPolicy found policies: " + Joiner.on("\t").join(policyNames) + " on storage group: " + storageGroupName);
            // See if this storage group is associated with the policy we sent in.
            if (policyNames != null && policyNames.contains(storageGroupPolicyLimitsParam.getAutoTierPolicyName())) {
                _log.info("findPhantomStorageGroupAssociatedWithFastPolicy found policy on storage group: " + storageGroupName);
                // Now check to see if this storage group is associated with any masking views
                if (!checkStorageGroupInAnyMaskingView(storage, storageGroupPath)) {
                    // Make sure this isn't a child storage group and its the parent(s) are not in masking views
                    // to qualify as phantom storage group
                    boolean inMaskView = false;
                    cimPathItr = getAssociatorNames(storage, storageGroupPath, null, SmisCommandHelper.MASKING_GROUP_TYPE.SE_DeviceMaskingGroup.name(), null, null);
                    if (cimPathItr != null) {
                        while (cimPathItr.hasNext() && !inMaskView) {
                            CIMObjectPath parentObjectPath = cimPathItr.next();
                            if (checkStorageGroupInAnyMaskingView(storage, parentObjectPath)) {
                                inMaskView = true;
                            }
                        }
                    }
                    if (!inMaskView) {
                        _log.info("findPhantomStorageGroupAssociatedWithFastPolicy found policy on storage group: " + storageGroupName + " and it's not associated with a masking view, so it's a container for FAST volumes");
                        _log.info("findPhantomStorageGroupAssociatedWithFastPolicy END: " + storageGroupPolicyLimitsParam);
                        sgNames.add(storageGroupName);
                    } else {
                        _log.info("findPhantomStorageGroupAssociatedWithFastPolicy found policy on storage group: " + storageGroupName + ", but it's associated indirectly with a masking view");
                    }
                } else {
                    _log.info("findPhantomStorageGroupAssociatedWithFastPolicy found policy on storage group: " + storageGroupName + ", but it's associated with a masking view");
                }
                closeCIMIterator(cimPathItr);
            }
        }
    } catch (Exception e) {
        _log.error("Failed trying to find existing Storage Groups with policy name", storageGroupPolicyLimitsParam, e);
        throw e;
    } finally {
        closeCIMIterator(cimPathItr);
    }
    _log.info("findPhantomStorageGroupAssociatedWithFastPolicy END: " + storageGroupPolicyLimitsParam);
    return sgNames;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) StringSet(com.emc.storageos.db.client.model.StringSet) CIMObjectPath(javax.cim.CIMObjectPath) ArrayList(java.util.ArrayList) StringSet(com.emc.storageos.db.client.model.StringSet) StorageGroupPolicyLimitsParam(com.emc.storageos.volumecontroller.impl.StorageGroupPolicyLimitsParam) IOException(java.io.IOException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) ServiceCodeException(com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException)

Example 2 with StorageGroupPolicyLimitsParam

use of com.emc.storageos.volumecontroller.impl.StorageGroupPolicyLimitsParam in project coprhd-controller by CoprHD.

the class SmisCommandHelper method groupStorageGroupsByAssociation.

public Map<StorageGroupPolicyLimitsParam, List<String>> groupStorageGroupsByAssociation(StorageSystem storage, String groupName) throws Exception {
    Map<StorageGroupPolicyLimitsParam, List<String>> groupNames = new HashMap<StorageGroupPolicyLimitsParam, List<String>>();
    CIMObjectPath maskingGroupPath = _cimPath.getMaskingGroupPath(storage, groupName, SmisCommandHelper.MASKING_GROUP_TYPE.SE_DeviceMaskingGroup);
    CloseableIterator<CIMInstance> cimInstanceItr = null;
    try {
        _log.info("Trying to find child Storage Groups for given Parent Group {}", groupName);
        if (storage.checkIfVmax3()) {
            cimInstanceItr = getAssociatorInstances(storage, maskingGroupPath, null, SmisCommandHelper.MASKING_GROUP_TYPE.SE_DeviceMaskingGroup.name(), null, null, PS_V3_STORAGE_GROUP_PROPERTIES);
            if (!cimInstanceItr.hasNext()) {
                _log.info("Non-Cascaded Storage Group found {}", groupName);
                CIMInstance maskingGroupInstance = getInstance(storage, maskingGroupPath, false, false, PS_V3_STORAGE_GROUP_PROPERTIES);
                String policyName = CIMPropertyFactory.getPropertyValue(maskingGroupInstance, CP_FAST_SETTING);
                if (policyName == null || policyName.isEmpty()) {
                    policyName = Constants.NONE;
                }
                StorageGroupPolicyLimitsParam storageGroupPolicyLimitsParam = new StorageGroupPolicyLimitsParam(policyName);
                groupNames.put(storageGroupPolicyLimitsParam, new ArrayList<String>());
                groupNames.get(storageGroupPolicyLimitsParam).add(groupName);
            } else {
                StorageGroupPolicyLimitsParam storageGroupNonePolicyLimitsParam = new StorageGroupPolicyLimitsParam(Constants.NONE);
                // add cascaded parent Group as well, for deletion
                groupNames.put(storageGroupNonePolicyLimitsParam, new ArrayList<String>());
                groupNames.get(storageGroupNonePolicyLimitsParam).add(groupName);
            }
            while (cimInstanceItr.hasNext()) {
                CIMInstance groupInstance = cimInstanceItr.next();
                groupName = CIMPropertyFactory.getPropertyValue(groupInstance, CP_ELEMENT_NAME);
                String policyName = CIMPropertyFactory.getPropertyValue(groupInstance, CP_FAST_SETTING);
                StorageGroupPolicyLimitsParam storageGroupPolicyLimitsParam = createStorageGroupPolicyLimitsParam(storage, groupInstance);
                if (null == groupNames.get(storageGroupPolicyLimitsParam)) {
                    groupNames.put(storageGroupPolicyLimitsParam, new ArrayList<String>());
                }
                groupNames.get(storageGroupPolicyLimitsParam).add(groupName);
            }
        } else {
            cimInstanceItr = getAssociatorInstances(storage, maskingGroupPath, null, SmisCommandHelper.MASKING_GROUP_TYPE.SE_DeviceMaskingGroup.name(), null, null, PS_HOST_IO);
            if (!cimInstanceItr.hasNext()) {
                _log.info("Non-Cascaded Storage Group found {}", groupName);
                CIMInstance groupInstance = getInstance(storage, maskingGroupPath, false, false, PS_HOST_IO);
                StorageGroupPolicyLimitsParam storageGroupPolicyLimitsParam = createStorageGroupPolicyLimitsParam(storage, groupInstance);
                groupNames.put(storageGroupPolicyLimitsParam, new ArrayList<String>());
                groupNames.get(storageGroupPolicyLimitsParam).add(groupName);
            } else {
                StorageGroupPolicyLimitsParam storageGroupNonePolicyLimitsParam = new StorageGroupPolicyLimitsParam(Constants.NONE);
                // add cascaded parent Group as well, for deletion
                groupNames.put(storageGroupNonePolicyLimitsParam, new ArrayList<String>());
            // No need to include CSG, as its already handled
            }
            while (cimInstanceItr.hasNext()) {
                CIMInstance groupInstance = cimInstanceItr.next();
                String storageGroupName = CIMPropertyFactory.getPropertyValue(groupInstance, CP_ELEMENT_NAME);
                StorageGroupPolicyLimitsParam storageGroupPolicyLimitsParam = createStorageGroupPolicyLimitsParam(storage, groupInstance);
                if (null == groupNames.get(storageGroupPolicyLimitsParam)) {
                    groupNames.put(storageGroupPolicyLimitsParam, new ArrayList<String>());
                }
                groupNames.get(storageGroupPolicyLimitsParam).add(storageGroupName);
            }
        }
    } finally {
        closeCIMIterator(cimInstanceItr);
    }
    _log.info("Constructed Groups : {}", Joiner.on('\n').withKeyValueSeparator(" -> ").join(groupNames));
    return groupNames;
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) CIMObjectPath(javax.cim.CIMObjectPath) Arrays.asList(java.util.Arrays.asList) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) StorageGroupPolicyLimitsParam(com.emc.storageos.volumecontroller.impl.StorageGroupPolicyLimitsParam) CIMInstance(javax.cim.CIMInstance)

Example 3 with StorageGroupPolicyLimitsParam

use of com.emc.storageos.volumecontroller.impl.StorageGroupPolicyLimitsParam in project coprhd-controller by CoprHD.

the class SmisCommandHelper method getExistingSGNamesFromArray.

/**
 * get SGs from Array. I hit a failure in this query off and on during my testing,
 * so I am using this method for a small retry method.
 *
 * @param storage
 *            storage system
 * @return set of storage group names
 */
public Map<StorageGroupPolicyLimitsParam, Set<String>> getExistingSGNamesFromArray(StorageSystem storage) {
    CloseableIterator<CIMInstance> groupInstanceItr = null;
    Map<StorageGroupPolicyLimitsParam, Set<String>> storageGroups = new HashMap<StorageGroupPolicyLimitsParam, Set<String>>();
    final int RETRY_COUNT = 5;
    final int RETRY_SLEEP_MS = 5000;
    int retry = 0;
    while (retry < RETRY_COUNT) {
        try {
            CIMObjectPath deviceMaskingGroupPath = CimObjectPathCreator.createInstance(SmisCommandHelper.MASKING_GROUP_TYPE.SE_DeviceMaskingGroup.name(), ROOT_EMC_NAMESPACE);
            groupInstanceItr = getEnumerateInstances(storage, deviceMaskingGroupPath, new String[] { CP_ELEMENT_NAME, EMC_MAX_BANDWIDTH, EMC_MAX_IO });
            while (groupInstanceItr.hasNext()) {
                CIMInstance groupInstance = groupInstanceItr.next();
                CIMObjectPath groupPath = groupInstance.getObjectPath();
                // storage system
                if (!groupPath.toString().contains(storage.getSerialNumber())) {
                    continue;
                }
                String policyName = getAutoTieringPolicyNameAssociatedWithVolumeGroup(storage, groupPath);
                String groupName = CIMPropertyFactory.getPropertyValue(groupInstance, CP_ELEMENT_NAME);
                String hostIOLimitBandwidth = CIMPropertyFactory.getPropertyValue(groupInstance, EMC_MAX_BANDWIDTH);
                String hostIOLimitIOPs = CIMPropertyFactory.getPropertyValue(groupInstance, EMC_MAX_IO);
                StorageGroupPolicyLimitsParam storageGroupPolicyLimitsParam = new StorageGroupPolicyLimitsParam(policyName, hostIOLimitBandwidth, hostIOLimitIOPs, storage);
                Set<String> storageGroupNames = storageGroups.get(storageGroupPolicyLimitsParam);
                if (storageGroupNames == null) {
                    storageGroupNames = new HashSet<String>();
                    storageGroups.put(storageGroupPolicyLimitsParam, storageGroupNames);
                }
                storageGroupNames.add(groupName);
            }
            _log.debug("Existing Group Names on Array : {}", Joiner.on("\t").join(storageGroups.values()));
            return storageGroups;
        } catch (Exception e) {
            _log.warn("Get Existing SG Names failed", e);
            if (retry <= RETRY_COUNT) {
                _log.warn(String.format("Going to retry (%d out of %d tries) SG name query in %s milliseconds", retry + 1, RETRY_COUNT, RETRY_SLEEP_MS));
                try {
                    Thread.sleep(RETRY_SLEEP_MS);
                } catch (InterruptedException e1) {
                // ignore
                }
            }
        } finally {
            closeCIMIterator(groupInstanceItr);
        }
        retry++;
    }
    _log.debug("Existing Group Names on Array : {}", Joiner.on("\t").join(storageGroups.values()));
    return storageGroups;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) StringSet(com.emc.storageos.db.client.model.StringSet) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) CIMObjectPath(javax.cim.CIMObjectPath) CIMInstance(javax.cim.CIMInstance) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) IOException(java.io.IOException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) ServiceCodeException(com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException) StorageGroupPolicyLimitsParam(com.emc.storageos.volumecontroller.impl.StorageGroupPolicyLimitsParam)

Example 4 with StorageGroupPolicyLimitsParam

use of com.emc.storageos.volumecontroller.impl.StorageGroupPolicyLimitsParam in project coprhd-controller by CoprHD.

the class VmaxExportOperations method removeVolumesFromPhantomStorageGroup.

/**
 * Removes the volumes from any phantom storage group.
 *
 * Determine if the volumes are associated with any phantom storage groups.
 * If so, we need to remove volumes from those storage groups and potentially remove them.
 */
private void removeVolumesFromPhantomStorageGroup(StorageSystem storage, WBEMClient client, URI exportMaskURI, List<URI> volumeURIList, String childGroupName, boolean forceFlag) throws Exception {
    CloseableIterator<CIMObjectPath> volumePathItr = null;
    try {
        Map<StorageGroupPolicyLimitsParam, List<URI>> policyVolumeMap = _helper.groupVolumesBasedOnFastPolicy(storage, volumeURIList);
        for (StorageGroupPolicyLimitsParam storageGroupPolicyLimitsParam : policyVolumeMap.keySet()) {
            if (!_helper.isFastPolicy(storageGroupPolicyLimitsParam.getAutoTierPolicyName())) {
                continue;
            }
            _log.info("Checking if volumes are associated with phantom storage groups with policy name: " + storageGroupPolicyLimitsParam);
            // See if there's a phantom group with this policy
            List<String> storageGroupNames = _helper.findPhantomStorageGroupAssociatedWithFastPolicy(storage, storageGroupPolicyLimitsParam);
            // We found a phantom storage group
            if (storageGroupNames != null) {
                for (String storageGroupName : storageGroupNames) {
                    List<URI> volumesToRemove = new ArrayList<URI>();
                    List<Volume> volumes = _dbClient.queryObject(Volume.class, policyVolumeMap.get(storageGroupPolicyLimitsParam));
                    // Get the volumes associated with this storage group. Match up with our volumes.
                    volumePathItr = _helper.getAssociatorNames(storage, _cimPath.getStorageGroupObjectPath(storageGroupName, storage), null, SmisConstants.CIM_STORAGE_VOLUME, null, null);
                    while (volumePathItr.hasNext()) {
                        CIMObjectPath volumePath = volumePathItr.next();
                        for (Volume volume : volumes) {
                            if (volume.getNativeGuid().equalsIgnoreCase(_helper.getVolumeNativeGuid(volumePath))) {
                                _log.info("Found volume " + volume.getLabel() + " is in phantom storage group " + storageGroupName);
                                volumesToRemove.add(volume.getId());
                            }
                        }
                    }
                    // Check to see if the volumes are associated with other non-fast, non-cascading masking views.
                    // If so, we should not remove that volume from the phantom storage group because another view
                    // is relying on
                    // it being there.
                    List<URI> inMoreViewsVolumes = new ArrayList<URI>();
                    for (URI volumeToRemove : volumesToRemove) {
                        if (_helper.isPhantomVolumeInMultipleMaskingViews(storage, volumeToRemove, childGroupName)) {
                            Volume volume = _dbClient.queryObject(Volume.class, volumeToRemove);
                            _log.info("Volume " + volume.getLabel() + " is in other masking views, so we will not remove it from storage group " + storageGroupName);
                            inMoreViewsVolumes.add(volume.getId());
                        }
                    }
                    volumesToRemove.removeAll(inMoreViewsVolumes);
                    // from the phantom storage group.
                    if (!volumesToRemove.isEmpty()) {
                        _log.info(String.format("Going to remove volumes %s from phantom storage group %s", Joiner.on("\t").join(volumesToRemove), storageGroupName));
                        Map<String, List<URI>> phantomGroupVolumeMap = _helper.groupVolumesBasedOnExistingGroups(storage, storageGroupName, volumesToRemove);
                        if (phantomGroupVolumeMap != null && phantomGroupVolumeMap.get(storageGroupName) != null && phantomGroupVolumeMap.get(storageGroupName).size() == volumesToRemove.size() && !_helper.isStorageGroupSizeGreaterThanGivenVolumes(storageGroupName, storage, volumesToRemove.size())) {
                            _log.info("Storage Group has no more than {} volumes", volumesToRemove.size());
                            URI blockURI = volumesToRemove.get(0);
                            BlockObject blockObj = BlockObject.fetch(_dbClient, blockURI);
                            CIMObjectPath maskingGroupPath = _cimPath.getMaskingGroupPath(storage, storageGroupName, SmisCommandHelper.MASKING_GROUP_TYPE.SE_DeviceMaskingGroup);
                            String foundPolicyName = ControllerUtils.getAutoTieringPolicyName(blockObj.getId(), _dbClient);
                            if (_helper.isFastPolicy(foundPolicyName) && storageGroupPolicyLimitsParam.getAutoTierPolicyName().equalsIgnoreCase(foundPolicyName)) {
                                _log.info("Storage Group {} contains only 1 volume, so this group will be disassociated from FAST because group can not be deleted if associated with FAST", storageGroupName);
                                _helper.removeVolumeGroupFromPolicyAndLimitsAssociation(client, storage, maskingGroupPath);
                            }
                        }
                        // Create a relatively empty completer associated with the export mask. We don't have the
                        // export group
                        // at this level, so there's nothing decent to attach the completer to anyway.
                        String task = UUID.randomUUID().toString();
                        ExportMaskVolumeToStorageGroupCompleter completer = new ExportMaskVolumeToStorageGroupCompleter(null, exportMaskURI, task);
                        List<URI> volumesInSG = _helper.findVolumesInStorageGroup(storage, storageGroupName, volumesToRemove);
                        List<CIMObjectPath> volumePaths = new ArrayList<CIMObjectPath>();
                        // Remove the found volumes from the phantom storage group
                        if (volumesInSG != null && !volumesInSG.isEmpty()) {
                            CIMArgument[] inArgs = _helper.getRemoveVolumesFromMaskingGroupInputArguments(storage, storageGroupName, volumesInSG, forceFlag);
                            CIMArgument[] outArgs = new CIMArgument[5];
                            _helper.invokeMethodSynchronously(storage, _cimPath.getControllerConfigSvcPath(storage), "RemoveMembers", inArgs, outArgs, new SmisMaskingViewRemoveVolumeJob(null, storage.getId(), volumePaths, null, storageGroupName, _cimPath, completer));
                        }
                    }
                }
            }
        }
    } finally {
        if (volumePathItr != null) {
            volumePathItr.close();
        }
    }
}
Also used : SmisMaskingViewRemoveVolumeJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisMaskingViewRemoveVolumeJob) CIMObjectPath(javax.cim.CIMObjectPath) ArrayList(java.util.ArrayList) URI(java.net.URI) ExportMaskVolumeToStorageGroupCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskVolumeToStorageGroupCompleter) Volume(com.emc.storageos.db.client.model.Volume) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) StorageGroupPolicyLimitsParam(com.emc.storageos.volumecontroller.impl.StorageGroupPolicyLimitsParam) BlockObject(com.emc.storageos.db.client.model.BlockObject) CIMArgument(javax.cim.CIMArgument)

Example 5 with StorageGroupPolicyLimitsParam

use of com.emc.storageos.volumecontroller.impl.StorageGroupPolicyLimitsParam in project coprhd-controller by CoprHD.

the class VmaxExportOperations method createOrSelectStorageGroup.

private CIMObjectPath createOrSelectStorageGroup(StorageSystem storage, URI exportMaskURI, Collection<Initiator> initiators, VolumeURIHLU[] volumeURIHLUs, String parentGroupName, Map<StorageGroupPolicyLimitsParam, CIMObjectPath> newlyCreatedChildVolumeGroups, TaskCompleter taskCompleter) throws Exception {
    List<CIMObjectPath> childVolumeGroupsToBeAddedToParentGroup = new ArrayList<CIMObjectPath>();
    String groupName = null;
    CIMObjectPath groupPath = null;
    ExportMask mask = _dbClient.queryObject(ExportMask.class, exportMaskURI);
    // group volumes based on policy
    ListMultimap<StorageGroupPolicyLimitsParam, VolumeURIHLU> policyToVolumeGroup = ArrayListMultimap.create();
    WBEMClient client = _helper.getConnection(storage).getCimClient();
    /**
     * Group Volumes by Fast Policy and Host IO limit attributes
     *
     * policyToVolumeGroupEntry - this will essentially have multiple Groups
     * E.g Group 1--> Fast Policy (FP1)+ FEBandwidth (100)
     * Group 2--> Fast Policy (FP2)+ IOPS (100)
     * Group 3--> FEBandwidth (100) + IOPS (100) ..
     *
     * For each Group {
     * 1. Create a Storage Group.
     * 2. Associate Fast Policy, bandwidth and IOPs ,based on the Group key.
     *
     * On failure ,remove the storage group, disassociate the added properties.
     * }
     */
    for (VolumeURIHLU volumeUriHLU : volumeURIHLUs) {
        StorageGroupPolicyLimitsParam sgPolicyLimitsParam = null;
        URI boUri = volumeUriHLU.getVolumeURI();
        BlockObject bo = BlockObject.fetch(_dbClient, boUri);
        boolean fastAssociatedAlready = false;
        // Export fast volumes to 2 different nodes.
        if (_helper.isFastPolicy(volumeUriHLU.getAutoTierPolicyName())) {
            fastAssociatedAlready = _helper.checkVolumeAssociatedWithAnySGWithPolicy(bo.getNativeId(), storage, volumeUriHLU.getAutoTierPolicyName());
        }
        // should not be created with a FAST policy assigned.
        if (fastAssociatedAlready || isRPJournalVolume(bo)) {
            _log.info("Forcing policy name to NONE to prevent volume from using FAST policy.");
            volumeUriHLU.setAutoTierPolicyName(Constants.NONE);
            sgPolicyLimitsParam = new StorageGroupPolicyLimitsParam(Constants.NONE, volumeUriHLU.getHostIOLimitBandwidth(), volumeUriHLU.getHostIOLimitIOPs(), storage);
        } else {
            sgPolicyLimitsParam = new StorageGroupPolicyLimitsParam(volumeUriHLU, storage);
        }
        policyToVolumeGroup.put(sgPolicyLimitsParam, volumeUriHLU);
    }
    _log.info("{} Groups generated based on grouping volumes by fast policy", policyToVolumeGroup.size());
    /**
     * Grouped Volumes based on Fast Policy
     */
    for (Entry<StorageGroupPolicyLimitsParam, Collection<VolumeURIHLU>> policyToVolumeGroupEntry : policyToVolumeGroup.asMap().entrySet()) {
        List<CIMObjectPath> childVolumeGroupsToBeAdded = new ArrayList<CIMObjectPath>();
        StorageGroupPolicyLimitsParam storageGroupPolicyLimitsParam = policyToVolumeGroupEntry.getKey();
        ListMultimap<String, VolumeURIHLU> expectedVolumeHluMap = ControllerUtils.getVolumeNativeGuids(policyToVolumeGroupEntry.getValue(), _dbClient);
        Map<String, Set<String>> existingGroupPaths;
        // in case of non-fast always create a new Storage Group
        if (!_helper.isFastPolicy(storageGroupPolicyLimitsParam.getAutoTierPolicyName())) {
            _log.info("Non-FAST create a new Storage Group");
            VolumeURIHLU[] volumeURIHLU = new VolumeURIHLU[policyToVolumeGroupEntry.getValue().size()];
            volumeURIHLU = policyToVolumeGroupEntry.getValue().toArray(volumeURIHLU);
            groupName = generateStorageGroupName(storage, mask, initiators, storageGroupPolicyLimitsParam);
            _log.debug("Group Name Created {}", groupName);
            groupPath = createVolumeGroup(storage, groupName, volumeURIHLU, taskCompleter, true);
            _log.info("Volume Group {} created on Array", groupPath);
        } else // in case of fast enabled, try to find any existing groups which can be reused.
        {
            /**
             * Find any existing Storage Groups can be reused, in
             * case of Fast Enabled volumes
             */
            _log.info("Running Storage Group Selection Process");
            existingGroupPaths = _helper.findAnyStorageGroupsCanBeReUsed(storage, expectedVolumeHluMap, storageGroupPolicyLimitsParam);
            if (existingGroupPaths.size() > 0) {
                _log.info("Existing Storage Groups Found :" + Joiner.on("\t").join(existingGroupPaths.keySet()));
            } else {
                _log.info("No existing Storage Groups Found for policy: " + storageGroupPolicyLimitsParam.toString());
            }
            if (existingGroupPaths.size() > 0) {
                childVolumeGroupsToBeAdded.addAll(_helper.constructMaskingGroupPathsFromNames(existingGroupPaths.keySet(), storage));
            }
            Set<String> volumesInExistingStorageGroups = _helper.constructVolumeNativeGuids(existingGroupPaths.values());
            _log.debug("Volumes part of existing reusable Storage Groups {}", Joiner.on("\t").join(volumesInExistingStorageGroups));
            // Storage Group needs to be created for those volumes,
            // which doesn't fit into
            // existing groups.
            Set<String> diff = Sets.difference(expectedVolumeHluMap.asMap().keySet(), volumesInExistingStorageGroups);
            _log.debug("Remaining Volumes, for which new Storage Group needs to be created", Joiner.on("\t").join(diff));
            // need to construct a new group for remaining volumes.
            if (!diff.isEmpty()) {
                VolumeURIHLU[] volumeURIHLU = ControllerUtils.constructVolumeUriHLUs(diff, expectedVolumeHluMap);
                groupName = generateStorageGroupName(storage, mask, initiators, storageGroupPolicyLimitsParam);
                _log.debug("Group Name Created :", groupName);
                groupPath = createVolumeGroup(storage, groupName, volumeURIHLU, taskCompleter, true);
                _log.info("Volume Group {} created on Array {}", groupName, storage.getSerialNumber());
            }
        }
        if (null != groupPath) {
            /**
             * used later in deleting created groups on failure
             */
            newlyCreatedChildVolumeGroups.put(storageGroupPolicyLimitsParam, groupPath);
            childVolumeGroupsToBeAdded.add(groupPath);
        }
        /**
         * check whether Storage Group is associated with Fast
         * Policy, if not associate
         */
        if (_helper.isFastPolicy(storageGroupPolicyLimitsParam.getAutoTierPolicyName())) {
            for (CIMObjectPath path : childVolumeGroupsToBeAdded) {
                // volumes).
                if (!_helper.checkVolumeAssociatedWithPhantomSG(path, storage, storageGroupPolicyLimitsParam.getAutoTierPolicyName()) && !_helper.checkVolumeGroupAssociatedWithPolicy(storage, path, storageGroupPolicyLimitsParam.getAutoTierPolicyName())) {
                    _log.debug("Adding Volume Group {} to Fast Policy {}", path, storageGroupPolicyLimitsParam.getAutoTierPolicyName());
                    addVolumeGroupToAutoTieringPolicy(storage, storageGroupPolicyLimitsParam.getAutoTierPolicyName(), path, taskCompleter);
                }
            }
        }
        childVolumeGroupsToBeAddedToParentGroup.addAll(childVolumeGroupsToBeAdded);
    }
    // Avoid duplicate names for the Cascaded VolumeGroup
    parentGroupName = _helper.generateGroupName(_helper.getExistingStorageGroupsFromArray(storage), parentGroupName);
    CIMObjectPath cascadedGroupPath = createCascadedVolumeGroup(storage, parentGroupName, childVolumeGroupsToBeAddedToParentGroup, taskCompleter);
    // for proper roll back , that is volume removal, if exception is thrown during update
    for (Entry<StorageGroupPolicyLimitsParam, CIMObjectPath> createdChildVolumeGroupEntry : newlyCreatedChildVolumeGroups.entrySet()) {
        CIMObjectPath childGroupPath = createdChildVolumeGroupEntry.getValue();
        StorageGroupPolicyLimitsParam storageGroupPolicyLimitsParam = createdChildVolumeGroupEntry.getKey();
        if (storageGroupPolicyLimitsParam.isHostIOLimitBandwidthSet()) {
            _helper.updateHostIOLimitBandwidth(client, childGroupPath, storageGroupPolicyLimitsParam.getHostIOLimitBandwidth());
        }
        if (storageGroupPolicyLimitsParam.isHostIOLimitIOPsSet()) {
            _helper.updateHostIOLimitIOPs(client, childGroupPath, storageGroupPolicyLimitsParam.getHostIOLimitIOPs());
        }
    }
    return cascadedGroupPath;
}
Also used : Set(java.util.Set) Sets.newHashSet(com.google.common.collect.Sets.newHashSet) HashSet(java.util.HashSet) StringSet(com.emc.storageos.db.client.model.StringSet) ExportMask(com.emc.storageos.db.client.model.ExportMask) CIMObjectPath(javax.cim.CIMObjectPath) ArrayList(java.util.ArrayList) URI(java.net.URI) Collection(java.util.Collection) StorageGroupPolicyLimitsParam(com.emc.storageos.volumecontroller.impl.StorageGroupPolicyLimitsParam) WBEMClient(javax.wbem.client.WBEMClient) BlockObject(com.emc.storageos.db.client.model.BlockObject) VolumeURIHLU(com.emc.storageos.volumecontroller.impl.VolumeURIHLU)

Aggregations

StorageGroupPolicyLimitsParam (com.emc.storageos.volumecontroller.impl.StorageGroupPolicyLimitsParam)18 CIMObjectPath (javax.cim.CIMObjectPath)14 ArrayList (java.util.ArrayList)10 HashSet (java.util.HashSet)10 StringSet (com.emc.storageos.db.client.model.StringSet)9 Set (java.util.Set)9 URI (java.net.URI)8 HashMap (java.util.HashMap)8 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)7 ExportMask (com.emc.storageos.db.client.model.ExportMask)7 VolumeURIHLU (com.emc.storageos.volumecontroller.impl.VolumeURIHLU)7 List (java.util.List)7 CIMInstance (javax.cim.CIMInstance)7 Sets.newHashSet (com.google.common.collect.Sets.newHashSet)6 WBEMException (javax.wbem.WBEMException)6 BlockObject (com.emc.storageos.db.client.model.BlockObject)5 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)5 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)5 WBEMClient (javax.wbem.client.WBEMClient)5 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)4