Search in sources :

Example 11 with StorageGroupPolicyLimitsParam

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

the class VmaxExportOperations method getVolumesThatBelongToPolicy.

/**
 * Convenience method that collects volumes from the array that match the storage group.
 *
 * @param volumeURIHLUs
 *            volume objects
 * @param storageGroupPolicyLimitsParam
 *            storage group attributes
 * @return thinned-out list of volume objects that correspond to the supplied policy, or null
 */
private VolumeURIHLU[] getVolumesThatBelongToPolicy(VolumeURIHLU[] volumeURIHLUs, StorageGroupPolicyLimitsParam storageGroupPolicyLimitsParam, StorageSystem storage) {
    VolumeURIHLU[] result = null;
    Set<VolumeURIHLU> volumeURIHLUSet = new HashSet<VolumeURIHLU>();
    for (VolumeURIHLU volumeURIHLU : volumeURIHLUs) {
        StorageGroupPolicyLimitsParam tmpKey = new StorageGroupPolicyLimitsParam(volumeURIHLU.getAutoTierPolicyName(), volumeURIHLU.getHostIOLimitBandwidth(), volumeURIHLU.getHostIOLimitIOPs(), storage);
        if (tmpKey.equals(storageGroupPolicyLimitsParam)) {
            volumeURIHLUSet.add(volumeURIHLU);
        }
    }
    if (!volumeURIHLUSet.isEmpty()) {
        result = new VolumeURIHLU[volumeURIHLUSet.size()];
        result = volumeURIHLUSet.toArray(result);
    }
    return result;
}
Also used : StorageGroupPolicyLimitsParam(com.emc.storageos.volumecontroller.impl.StorageGroupPolicyLimitsParam) VolumeURIHLU(com.emc.storageos.volumecontroller.impl.VolumeURIHLU) Sets.newHashSet(com.google.common.collect.Sets.newHashSet) HashSet(java.util.HashSet)

Example 12 with StorageGroupPolicyLimitsParam

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

the class VmaxExportOperations method addVolumesToPhantomStorageGroup.

/**
 * Adds the volumes to new or existing phantom storage group which is associated with given policy.
 * This is used internally for operation - change volume's policy by moving them from one vPool to another.
 */
private void addVolumesToPhantomStorageGroup(StorageSystem storage, ExportMask exportMask, List<URI> volumesInSG, String newPolicyName, String childGroupName, TaskCompleter taskCompleter, boolean forceFlag) throws Exception {
    // Check to see if there already is a phantom storage group with this policy on the array
    StorageGroupPolicyLimitsParam phantomStorageGroupPolicyLimitsParam = new StorageGroupPolicyLimitsParam(newPolicyName);
    List<String> phantomStorageGroupNames = _helper.findPhantomStorageGroupAssociatedWithFastPolicy(storage, phantomStorageGroupPolicyLimitsParam);
    VolumeURIHLU[] volumeURIHlus = constructVolumeURIHLUFromURIList(volumesInSG, newPolicyName);
    // If there's no existing phantom storage group, create one.
    if (phantomStorageGroupNames == null || phantomStorageGroupNames.isEmpty()) {
        String phantomStorageGroupName = generateNewNameForPhantomSG(storage, childGroupName, phantomStorageGroupPolicyLimitsParam);
        // We need to create a new phantom storage group with our policy associated with it.
        _log.info("phantom storage group {} doesn't exist, creating a new group", phantomStorageGroupName);
        CIMObjectPath phantomStorageGroupCreated = createVolumeGroup(storage, phantomStorageGroupName, volumeURIHlus, taskCompleter, true);
        _log.info("Adding Storage Group {} to Fast Policy {}", phantomStorageGroupName, newPolicyName);
        addVolumeGroupToAutoTieringPolicy(storage, newPolicyName, phantomStorageGroupCreated, taskCompleter);
    } else {
        // take the first matching phantom SG from the list
        String phantomStorageGroupName = phantomStorageGroupNames.get(0);
        // We found a phantom storage group with our policy, use it.
        _log.info("Found that we need to add volumes to the phantom storage group: {}", phantomStorageGroupName);
        // 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, exportMask.getId(), task);
        SmisMaskingViewAddVolumeJob job = new SmisMaskingViewAddVolumeJob(null, storage.getId(), exportMask.getId(), volumeURIHlus, null, completer);
        job.setCIMObjectPathfactory(_cimPath);
        _helper.addVolumesToStorageGroup(volumeURIHlus, storage, phantomStorageGroupName, job, forceFlag);
        ExportOperationContext.insertContextOperation(taskCompleter, VmaxExportOperationContext.OPERATION_ADD_VOLUMES_TO_STORAGE_GROUP, phantomStorageGroupName, volumeURIHlus, forceFlag);
        _log.info("Adding Volumes to Phantom Storage Group {}", phantomStorageGroupName);
    }
}
Also used : ExportMaskVolumeToStorageGroupCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskVolumeToStorageGroupCompleter) SmisMaskingViewAddVolumeJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisMaskingViewAddVolumeJob) CIMObjectPath(javax.cim.CIMObjectPath) StorageGroupPolicyLimitsParam(com.emc.storageos.volumecontroller.impl.StorageGroupPolicyLimitsParam) VolumeURIHLU(com.emc.storageos.volumecontroller.impl.VolumeURIHLU)

Example 13 with StorageGroupPolicyLimitsParam

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

the class VmaxExportOperations method deleteExportMask.

@Override
public void deleteExportMask(StorageSystem storage, URI exportMaskURI, List<URI> volumeURIList, List<URI> targetURIList, List<Initiator> initiatorList, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("{} deleteExportMask START...", storage.getSerialNumber());
    try {
        _log.info("Export mask id: {}", exportMaskURI);
        if (volumeURIList != null) {
            _log.info("deleteExportMask: volumes:  {}", Joiner.on(',').join(volumeURIList));
        }
        if (targetURIList != null) {
            _log.info("deleteExportMask: assignments: {}", Joiner.on(',').join(targetURIList));
        }
        if (initiatorList != null) {
            _log.info("deleteExportMask: initiators: {}", Joiner.on(',').join(initiatorList));
        }
        boolean isVmax3 = storage.checkIfVmax3();
        WBEMClient client = _helper.getConnection(storage).getCimClient();
        String maskingViewName = _helper.getExportMaskName(exportMaskURI);
        // Always get the Storage Group from masking View, rather than depending on the name to find out SG.
        String groupName = _helper.getStorageGroupForGivenMaskingView(maskingViewName, storage);
        /*
             * The idea is to remove orphaned child Groups, after deleting masking view. We're getting
             * the list of childGroups here because once we call deleteMaskingView, the parent group
             * will be automatically deleted.
             * 
             * Run Associator Names to get details of child Storage Groups ,and group them based on
             * Fast Policy.
             */
        Map<StorageGroupPolicyLimitsParam, List<String>> childGroupsByFast = new HashMap<StorageGroupPolicyLimitsParam, List<String>>();
        // if SGs are already removed from masking view manually, then skip this part
        if (null != groupName) {
            childGroupsByFast = _helper.groupStorageGroupsByAssociation(storage, groupName);
        } else {
            _log.info("Masking View {} doesn't have any SGs associated, probably removed manually from Array", maskingViewName);
            if (isVmax3) {
                // If we did not find the storage group associated with the masking view it could be
                // the case that were were unexporting volumes and successfully deleted the masking
                // but failed at some point thereafter, and now the operation is being retried. If
                // that is the case, then for VMAX3 we want to make sure that none of the volumes being
                // unexported are still in non parking storage groups. If we find such volume we remove
                // them and add them to the parking storage group.
                ExportMask exportMask = _dbClient.queryObject(ExportMask.class, exportMaskURI);
                if (exportMask == null) {
                    // If we can't find the mask, there is really no cleanup we can do.
                    _log.warn("ExportMask {} no longer exists", exportMaskURI);
                    taskCompleter.ready(_dbClient);
                    return;
                }
                // See if any of the mask's volumes are still in a non-parking storage group. Map the
                // volumes by group name.
                List<URI> volumeURIs = ExportMaskUtils.getVolumeURIs(exportMask);
                Map<String, List<URI>> volumesInNonParkingStorageGroup = _helper.getVolumesInNonParkingStorageGroup(storage, volumeURIs);
                if (!volumesInNonParkingStorageGroup.isEmpty()) {
                    Map<String, Set<String>> volumeDeviceIdsMap = new HashMap<>();
                    for (Entry<String, List<URI>> storageGroupEntry : volumesInNonParkingStorageGroup.entrySet()) {
                        String storageGroupName = storageGroupEntry.getKey();
                        List<URI> storageGroupVolumeURIs = storageGroupEntry.getValue();
                        // then just skip the volume, we cannot clean it up as we may impact other exports.
                        if (_helper.findStorageGroupsAssociatedWithMultipleParents(storage, storageGroupName) || _helper.findStorageGroupsAssociatedWithOtherMaskingViews(storage, storageGroupName)) {
                            _log.info("Storage group {} is associated with multiple paranets or other masking views", storageGroupName);
                            continue;
                        }
                        // Otherwise, remove the volumes from the storage group.
                        _log.info("Removing volumes {} from non parking storage group {}", storageGroupVolumeURIs, storageGroupName);
                        _helper.removeVolumesFromStorageGroup(storage, storageGroupName, storageGroupVolumeURIs, true);
                        // parking storage group.
                        for (URI storageGroupVolumeURI : storageGroupVolumeURIs) {
                            Volume storageGroupVolume = _dbClient.queryObject(Volume.class, storageGroupVolumeURI);
                            if (storageGroupVolume != null) {
                                String policyName = ControllerUtils.getAutoTieringPolicyName(storageGroupVolumeURI, _dbClient);
                                String policyKey = _helper.getVMAX3FastSettingForVolume(storageGroupVolumeURI, policyName);
                                if (volumeDeviceIdsMap.containsKey(policyKey)) {
                                    volumeDeviceIdsMap.get(policyKey).add(storageGroupVolume.getNativeId());
                                } else {
                                    Set<String> volumeDeviceIds = new HashSet<>();
                                    volumeDeviceIds.add(storageGroupVolume.getNativeId());
                                    volumeDeviceIdsMap.put(policyKey, volumeDeviceIds);
                                }
                            }
                        }
                    }
                    // Finally for each parking storage group policy, add the volumes associated parking storage group.
                    for (Entry<String, Set<String>> volumeDeviceIdsMapEntry : volumeDeviceIdsMap.entrySet()) {
                        _log.info("Adding volumes {} on system {} to parking storage group for policy {}", volumeDeviceIdsMapEntry.getValue(), storage.getNativeGuid(), volumeDeviceIdsMapEntry.getKey());
                        addVolumesToParkingStorageGroup(storage, volumeDeviceIdsMapEntry.getKey(), volumeDeviceIdsMapEntry.getValue());
                    }
                }
            }
            taskCompleter.ready(_dbClient);
            return;
        }
        /*
             * If a maskingView was created by other instance, can not delete it here during roll back. Hence,
             * set task as done.
             */
        if (taskCompleter instanceof RollbackExportGroupCreateCompleter) {
            /*
                 * The purpose of rollback is to delete the masking view created by this very ViPR instance as
                 * part of this workflow, and it should not delete masking view created externally or another ViPR
                 */
            // Get the context from the task completer, in case this is a rollback.
            ExportOperationContext context = (ExportOperationContext) WorkflowService.getInstance().loadStepData(taskCompleter.getOpId());
            if (context != null) {
                exportMaskRollback(storage, context, taskCompleter);
            }
        } else {
            ExportOperationContext context = (ExportOperationContext) WorkflowService.getInstance().loadStepData(taskCompleter.getOpId());
            ExportMask exportMask = _dbClient.queryObject(ExportMask.class, exportMaskURI);
            List<URI> volumeURIs = ExportMaskUtils.getVolumeURIs(exportMask);
            ExportMaskValidationContext ctx = new ExportMaskValidationContext();
            ctx.setStorage(storage);
            ctx.setExportMask(exportMask);
            ctx.setBlockObjects(volumeURIList, _dbClient);
            ctx.setInitiators(initiatorList);
            ctx.setAllowExceptions(context == null);
            validator.exportMaskDelete(ctx).validate();
            if (!deleteMaskingView(storage, exportMaskURI, childGroupsByFast, taskCompleter)) {
                // deleteMaskingView call. Simply return from here.
                return;
            }
            for (Map.Entry<StorageGroupPolicyLimitsParam, List<String>> entry : childGroupsByFast.entrySet()) {
                _log.info(String.format("Mask %s FAST Policy %s associated with %d Storage Group(s)", maskingViewName, entry.getKey(), entry.getValue().size()));
            }
            if (groupName != null) {
                _log.info("storage group name : {}", groupName);
                // delete the CSG explicitly (CTRL-9236)
                CIMObjectPath storageGroupPath = _cimPath.getMaskingGroupPath(storage, groupName, SmisCommandHelper.MASKING_GROUP_TYPE.SE_DeviceMaskingGroup);
                // check if the storage group is shared before delete it
                if (_helper.checkExists(storage, storageGroupPath, false, false) != null && _helper.checkMaskingGroupShared(storage, storageGroupPath, exportMask.getMaskName())) {
                    // if the storage group is shared, don't delete the storage group
                    _log.info("The Storage group {} is shared, so it will not be deleted", groupName);
                    taskCompleter.ready(_dbClient);
                    return;
                }
                if (_helper.isCascadedSG(storage, storageGroupPath)) {
                    _helper.deleteMaskingGroup(storage, groupName, SmisCommandHelper.MASKING_GROUP_TYPE.SE_DeviceMaskingGroup);
                }
                /**
                 * After successful deletion of masking view, try to remove the child Storage Groups ,which were
                 * part of cascaded
                 * Parent Group. If Fast Policy is not enabled, then those child groups can be removed.
                 * If Fast enabled, then try to find if this child Storage Group is associated with more than 1
                 * Parent Cascaded
                 * Group, if yes, then we cannot delete the child Storage Group.
                 */
                for (Entry<StorageGroupPolicyLimitsParam, List<String>> childGroupByFastEntry : childGroupsByFast.entrySet()) {
                    for (String childGroupName : childGroupByFastEntry.getValue()) {
                        _log.info("Processing Group {} deletion with Fast Policy {}", childGroupName, childGroupByFastEntry.getKey());
                        CIMObjectPath maskingGroupPath = _cimPath.getMaskingGroupPath(storage, childGroupName, SmisCommandHelper.MASKING_GROUP_TYPE.SE_DeviceMaskingGroup);
                        if (!_helper.isFastPolicy(childGroupByFastEntry.getKey().getAutoTierPolicyName())) {
                            /**
                             * Remove the volumes from any phantom storage group (CTRL-8217).
                             *
                             * Volumes part of Phantom Storage Group will be in Non-CSG Non-FAST Storage Group
                             */
                            if (!_helper.isCascadedSG(storage, maskingGroupPath)) {
                                // Get volumes which are part of this Storage Group
                                List<URI> volumesInSG = _helper.findVolumesInStorageGroup(storage, childGroupName, volumeURIs);
                                // Flag to indicate whether or not we need to use the EMCForce flag on this
                                // operation.
                                // We currently use this flag when dealing with RP Volumes as they are tagged for RP
                                // and the
                                // operation on these volumes would fail otherwise.
                                boolean forceFlag = false;
                                for (URI volURI : volumesInSG) {
                                    forceFlag = ExportUtils.useEMCForceFlag(_dbClient, volURI);
                                    if (forceFlag) {
                                        break;
                                    }
                                }
                                removeVolumesFromPhantomStorageGroup(storage, client, exportMaskURI, volumesInSG, childGroupName, forceFlag);
                            }
                            // Delete the Storage Group
                            _helper.deleteMaskingGroup(storage, childGroupName, SmisCommandHelper.MASKING_GROUP_TYPE.SE_DeviceMaskingGroup);
                        } else if (!_helper.findStorageGroupsAssociatedWithMultipleParents(storage, childGroupName) && !_helper.findStorageGroupsAssociatedWithOtherMaskingViews(storage, childGroupName)) {
                            // volumeDeviceIds and policyName are required in case of VMAX3 to add volumes back
                            // to parking to storage group.
                            Set<String> volumeDeviceIds = new HashSet<String>();
                            String policyName = childGroupByFastEntry.getKey().getAutoTierPolicyName();
                            if (isVmax3) {
                                volumeDeviceIds = _helper.getVolumeDeviceIdsFromStorageGroup(storage, childGroupName);
                            }
                            // holds the group, if yes, then we should not delete this group
                            if (!isVmax3) {
                                _log.debug("Removing Storage Group {} from Fast Policy {}", childGroupName, childGroupByFastEntry.getKey());
                                _helper.removeVolumeGroupFromPolicyAndLimitsAssociation(client, storage, maskingGroupPath);
                            }
                            _log.debug("Deleting Storage Group {}", childGroupName);
                            _helper.deleteMaskingGroup(storage, childGroupName, SmisCommandHelper.MASKING_GROUP_TYPE.SE_DeviceMaskingGroup);
                            if (isVmax3 && !volumeDeviceIds.isEmpty()) {
                                // We need to add volumes back to appropriate parking storage group.
                                addVolumesToParkingStorageGroup(storage, policyName, volumeDeviceIds);
                            }
                        } else {
                            _log.info("Storage Group {} is either having more than one parent Storage Group or its part of another existing masking view", childGroupName);
                            // set Host IO Limits on SG which we reseted before deleting MV
                            if (childGroupByFastEntry.getKey().isHostIOLimitIOPsSet()) {
                                _helper.updateHostIOLimitIOPs(client, maskingGroupPath, childGroupByFastEntry.getKey().getHostIOLimitIOPs());
                            }
                            if (childGroupByFastEntry.getKey().isHostIOLimitBandwidthSet()) {
                                _helper.updateHostIOLimitBandwidth(client, maskingGroupPath, childGroupByFastEntry.getKey().getHostIOLimitBandwidth());
                            }
                        }
                    }
                }
            }
        }
        taskCompleter.ready(_dbClient);
    } catch (Exception e) {
        _log.error(String.format("deleteExportMask failed - maskName: %s", exportMaskURI.toString()), e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        taskCompleter.error(_dbClient, serviceError);
    }
    _log.info("{} deleteExportMask END...", storage.getSerialNumber());
}
Also used : RollbackExportGroupCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.RollbackExportGroupCreateCompleter) Set(java.util.Set) Sets.newHashSet(com.google.common.collect.Sets.newHashSet) HashSet(java.util.HashSet) StringSet(com.emc.storageos.db.client.model.StringSet) HashMap(java.util.HashMap) URI(java.net.URI) ExportOperationContext(com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) WBEMClient(javax.wbem.client.WBEMClient) Sets.newHashSet(com.google.common.collect.Sets.newHashSet) HashSet(java.util.HashSet) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ExportMask(com.emc.storageos.db.client.model.ExportMask) CIMObjectPath(javax.cim.CIMObjectPath) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) ExportMaskValidationContext(com.emc.storageos.volumecontroller.impl.validators.contexts.ExportMaskValidationContext) Volume(com.emc.storageos.db.client.model.Volume) StorageGroupPolicyLimitsParam(com.emc.storageos.volumecontroller.impl.StorageGroupPolicyLimitsParam) Map(java.util.Map) HashMap(java.util.HashMap) AbstractMap(java.util.AbstractMap)

Example 14 with StorageGroupPolicyLimitsParam

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

the class SmisCommandHelper method findAnyStorageGroupsCanBeReUsed.

public Map<String, Set<String>> findAnyStorageGroupsCanBeReUsed(StorageSystem storage, ListMultimap<String, VolumeURIHLU> expectedVolumeNativeGuids, StorageGroupPolicyLimitsParam storageGroupPolicyLimitsParam) throws WBEMException {
    CloseableIterator<CIMInstance> groupInstanceItr = null;
    CloseableIterator<CIMObjectPath> tierPolicyRuleItr = null;
    CloseableIterator<CIMObjectPath> volumePathItr = null;
    // concurrent hash map used to avoid concurrent modification exception
    // only
    Map<String, Set<String>> groupPaths = new ConcurrentHashMap<String, Set<String>>();
    try {
        boolean isVmax3 = storage.checkIfVmax3();
        CIMObjectPath deviceMaskingGroupPath = CimObjectPathCreator.createInstance(SmisCommandHelper.MASKING_GROUP_TYPE.SE_DeviceMaskingGroup.name(), ROOT_EMC_NAMESPACE);
        _log.info("Trying to get all Storage Groups");
        if (isVmax3) {
            CIMObjectPath controllerConfigSvcPath = _cimPath.getControllerConfigSvcPath(storage);
            groupInstanceItr = getAssociatorInstances(storage, controllerConfigSvcPath, null, SE_DEVICE_MASKING_GROUP, null, null, PS_V3_STORAGE_GROUP_PROPERTIES);
        } else {
            groupInstanceItr = getEnumerateInstances(storage, deviceMaskingGroupPath, PS_ELEMENT_NAME);
        }
        /**
         * used in finding out whether any volume already exists in a Storage Group, but this
         * storage Group not part of the selected list.i.e. in case of fast , then these volumes
         * cannot be part of a different storage group. hence, we cannot proceed with creating
         * export group.
         */
        Set<String> volumesInExistingGroups = new HashSet<String>();
        while (groupInstanceItr.hasNext()) {
            CIMInstance groupInstance = groupInstanceItr.next();
            CIMObjectPath groupPath = groupInstance.getObjectPath();
            // storage system
            if (!groupPath.toString().contains(storage.getSerialNumber())) {
                continue;
            }
            _log.debug("Trying to find group {} belongs to expected policy {}", groupPath, storageGroupPolicyLimitsParam.getAutoTierPolicyName());
            String fastSetting = null;
            if (isVmax3) {
                fastSetting = CIMPropertyFactory.getPropertyValue(groupInstance, CP_FAST_SETTING);
            } else {
                tierPolicyRuleItr = getAssociatorNames(storage, groupPath, null, CIM_TIER_POLICY_RULE, null, null);
            }
            String groupName = CIMPropertyFactory.getPropertyValue(groupInstance, CP_ELEMENT_NAME);
            /**
             * if storage group does not math with desired the properties (policyName, Bandwidth,IOPS), skip
             */
            StorageGroupPolicyLimitsParam existStorageGroupPolicyLimitsParam = createStorageGroupPolicyLimitsParam(storage, groupInstance);
            if (!existStorageGroupPolicyLimitsParam.equals(storageGroupPolicyLimitsParam)) {
                continue;
            }
            Set<String> returnedNativeGuids = new HashSet<String>();
            // loop through all the volumes of this storage group
            _log.debug("Looping through all volumes in storage group {}", groupName);
            volumePathItr = getAssociatorNames(storage, groupPath, null, CIM_STORAGE_VOLUME, null, null);
            while (volumePathItr.hasNext()) {
                returnedNativeGuids.add(getVolumeNativeGuid(volumePathItr.next()));
            }
            if (returnedNativeGuids.isEmpty()) {
                continue;
            }
            // these volumes are at least part of a storage group
            volumesInExistingGroups.addAll(returnedNativeGuids);
            if (isVmax3) {
                if (!fastSetting.equals(storageGroupPolicyLimitsParam.getAutoTierPolicyName())) {
                    continue;
                }
                if (fastSetting.equals(storageGroupPolicyLimitsParam.getAutoTierPolicyName()) && groupName.startsWith(Constants.STORAGE_GROUP_PREFIX)) {
                    continue;
                }
            }
            // Flag will be true if the group is non-FAST
            boolean isNonFastGroup = (tierPolicyRuleItr != null) ? !tierPolicyRuleItr.hasNext() : false;
            // storage group.
            if (!isVmax3 && !checkPolicyExistsInReturnedList(groupName, tierPolicyRuleItr, storageGroupPolicyLimitsParam.getAutoTierPolicyName())) {
                if (isNonFastGroup) {
                    // Ignore volumes that are in non FAST groups (we only care about volumes that could be in
                    // multiple FAST groups).
                    volumesInExistingGroups.removeAll(returnedNativeGuids);
                }
                continue;
            }
            Set<String> diff = Sets.difference(returnedNativeGuids, expectedVolumeNativeGuids.asMap().keySet());
            /**
             * If diff is 0, it means the same set of volumes reside in one of the Storage
             * Groups associated with this Policy, hence, this storage Group can be reused
             * during this export operation to different initiator set.
             */
            if (diff.isEmpty()) {
                // check whether this storage group is part of any existing parent group
                // if its not part of any group, then select this
                // even though this group is part of existing expected parent group, we need to
                // skip
                // as there is no action needed.This scenario is possible,only if the same value
                // is exported using the same export group again.
                // if thats the case, we throw Error
                // "Volumes already part of existing storage groups"
                _log.info("Trying to find parent cascaded groups any of reusable storage group {} ", groupName);
                if (checkStorageGroupAlreadyPartOfExistingParentGroups(storage, groupPath)) {
                    _log.info("Even though this group {} contains subset of given volumes {}, it cannot be reused, as it is part of another cascading group", groupPath, Joiner.on("\t").join(returnedNativeGuids));
                    continue;
                }
                _log.info("Found Group {} with subset of expected volumes {}", groupName, Joiner.on("\t").join(returnedNativeGuids));
                runStorageGroupSelectionProcess(groupPaths, returnedNativeGuids, groupName);
            // add the new group
            }
        }
        /**
         * In case of fast policy, if we find a volume which is part of Storage Group, but this
         * volume is not in the list of final selected Storage Groups volumes, then it means, we
         * cannot proceed with creating an Export Group.
         */
        if (groupPaths.size() > 0) {
            Set<String> volumesPartOfSelectedStorageGroups = constructVolumeNativeGuids(groupPaths.values());
            Set<String> remainingVolumes = new HashSet<String>();
            Sets.difference(expectedVolumeNativeGuids.asMap().keySet(), volumesPartOfSelectedStorageGroups).copyInto(remainingVolumes);
            _log.debug("Remaining volumes which doesn't fit into existing storage groups {}", Joiner.on("\t").join(remainingVolumes));
            // expected list
            if (!remainingVolumes.isEmpty()) {
                // volumes which are already part of storage group.
                _log.debug("Trying to find , if any of the remaining volumes is present in existing storage groups");
                remainingVolumes.retainAll(volumesInExistingGroups);
                // groups.
                if (!remainingVolumes.isEmpty()) {
                    throw DeviceControllerException.exceptions.volumesAlreadyPartOfStorageGroups(Joiner.on("\t").join(remainingVolumes));
                }
            }
        }
    } finally {
        closeCIMIterator(groupInstanceItr);
        closeCIMIterator(volumePathItr);
        closeCIMIterator(tierPolicyRuleItr);
    }
    return groupPaths;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) StringSet(com.emc.storageos.db.client.model.StringSet) CIMObjectPath(javax.cim.CIMObjectPath) StorageGroupPolicyLimitsParam(com.emc.storageos.volumecontroller.impl.StorageGroupPolicyLimitsParam) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) CIMInstance(javax.cim.CIMInstance) HashSet(java.util.HashSet)

Example 15 with StorageGroupPolicyLimitsParam

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

the class SmisCommandHelper method createStorageGroupPolicyLimitsParam.

/**
 * Construct a storage group policy limits based on info extracted from SMIS storage group object
 *
 * @param storage
 *            storage system
 * @param groupInstance
 *            SMIS storage group instance
 * @return
 */
public StorageGroupPolicyLimitsParam createStorageGroupPolicyLimitsParam(StorageSystem storage, CIMInstance groupInstance) throws WBEMException {
    StorageGroupPolicyLimitsParam storageGroupPolicyLimitsParam = null;
    String hostIOLimitBandwidth = CIMPropertyFactory.getPropertyValue(groupInstance, EMC_MAX_BANDWIDTH);
    String hostIOLimitIOPs = CIMPropertyFactory.getPropertyValue(groupInstance, EMC_MAX_IO);
    if (storage.checkIfVmax3()) {
        storageGroupPolicyLimitsParam = new StorageGroupPolicyLimitsParam(getVMAX3FastSettingAssociatedWithVolumeGroup(groupInstance), hostIOLimitBandwidth, hostIOLimitIOPs, storage);
        storageGroupPolicyLimitsParam.setCompression(SmisUtils.getEMCCompressionForStorageGroup(groupInstance));
    } else {
        storageGroupPolicyLimitsParam = new StorageGroupPolicyLimitsParam(getAutoTieringPolicyNameAssociatedWithVolumeGroup(storage, groupInstance.getObjectPath()), hostIOLimitBandwidth, hostIOLimitIOPs, storage);
    }
    return storageGroupPolicyLimitsParam;
}
Also used : StorageGroupPolicyLimitsParam(com.emc.storageos.volumecontroller.impl.StorageGroupPolicyLimitsParam)

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 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 HashMap (java.util.HashMap)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