Search in sources :

Example 1 with SmisSynchSubTaskJob

use of com.emc.storageos.volumecontroller.impl.smis.job.SmisSynchSubTaskJob in project coprhd-controller by CoprHD.

the class VmaxExportOperations method addVolumesToParkingStorageGroup.

/**
 * This method is used for VMAX3 to add volumes to parking storage group
 * once volumes are unexported.
 * For volumes which are still part of another export and if they already
 * belong to FAST managed storage group, they won't be added to parking storage group.
 *
 * @param storage
 * @param policyName
 * @param volumeDeviceIds
 * @throws Exception
 */
private void addVolumesToParkingStorageGroup(StorageSystem storage, String policyName, Set<String> volumeDeviceIds) throws Exception {
    // Don't add volumes to parking SLO which are already part of a FAST managed storage group
    volumeDeviceIds = _helper.filterVolumesPartOfAnyFASTStorageGroup(storage, volumeDeviceIds);
    if (!volumeDeviceIds.isEmpty() && !Constants.NONE.equalsIgnoreCase(policyName)) {
        String[] tokens = policyName.split(Constants.SMIS_PLUS_REGEX);
        CIMObjectPath groupPath = _helper.getVolumeGroupBasedOnSLO(storage, storage, tokens[0], tokens[1], tokens[2]);
        if (groupPath == null) {
            groupPath = _helper.createVolumeGroupBasedOnSLO(storage, storage, tokens[0], tokens[1], tokens[2]);
        }
        CIMArgument[] inArgs = _helper.getAddVolumesToMaskingGroupInputArguments(storage, groupPath, volumeDeviceIds);
        CIMArgument[] outArgs = new CIMArgument[5];
        SmisJob addVolumesToSGJob = new SmisSynchSubTaskJob(null, storage.getId(), SmisConstants.ADD_MEMBERS);
        _helper.invokeMethodSynchronously(storage, _cimPath.getControllerConfigSvcPath(storage), "AddMembers", inArgs, outArgs, addVolumesToSGJob);
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) SmisJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisJob) SmisSynchSubTaskJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisSynchSubTaskJob) CIMArgument(javax.cim.CIMArgument)

Example 2 with SmisSynchSubTaskJob

use of com.emc.storageos.volumecontroller.impl.smis.job.SmisSynchSubTaskJob in project coprhd-controller by CoprHD.

the class VmaxExportOperations method deleteInitiatorGroup.

/**
 * Function will delete the IG specified by the CIMObjectPath from the array.
 *
 * @param storage
 *            [in] - StorageSystem object
 * @param igPath
 *            [in] - CIMObjectPath object to be query
 * @throws WBEMException
 * @throws Exception
 */
private boolean deleteInitiatorGroup(StorageSystem storage, CIMObjectPath igPath) throws Exception {
    CIMArgument[] deleteIn = _helper.getDeleteInitiatorMaskingGroup(storage, igPath);
    CIMArgument[] deleteOut = new CIMArgument[5];
    SmisJob deleteIgJob = new SmisSynchSubTaskJob(null, storage.getId(), SmisConstants.DELETE_GROUP);
    _helper.invokeMethodSynchronously(storage, _cimPath.getControllerConfigSvcPath(storage), SmisConstants.DELETE_GROUP, deleteIn, deleteOut, deleteIgJob);
    return deleteIgJob.isSuccess();
}
Also used : SmisJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisJob) SmisSynchSubTaskJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisSynchSubTaskJob) CIMArgument(javax.cim.CIMArgument)

Example 3 with SmisSynchSubTaskJob

use of com.emc.storageos.volumecontroller.impl.smis.job.SmisSynchSubTaskJob in project coprhd-controller by CoprHD.

the class VmaxExportOperations method validateAndUpdateStorageGroupPolicyAndLimits.

/**
 * Validates and updates fast policy in storage group.
 *
 * @param storage
 *            the storage system
 * @param exportMask
 *            exportMask
 * @param childGroupName
 *            the child group name
 * @param volumeURIs
 *            the volume uris
 * @param newVirtualPool
 *            the new virtual pool where new policy name and host limits can be obtained
 * @param phantomSGNames
 *            the phantom SG names if any
 * @param taskCompleter
 *            task completer
 * @return true, if successfully updated policy for SG
 * @throws WBEMException
 *             the wBEM exception
 * @throws Exception
 *             the exception
 */
private boolean validateAndUpdateStorageGroupPolicyAndLimits(StorageSystem storage, ExportMask exportMask, String childGroupName, List<URI> volumeURIs, VirtualPool newVirtualPool, Set<String> phantomSGNames, TaskCompleter taskCompleter) throws WBEMException, Exception {
    boolean policyUpdated = false;
    boolean isVmax3 = storage.checkIfVmax3();
    _log.info("Checking on Storage Group {}", childGroupName);
    WBEMClient client = _helper.getConnection(storage).getCimClient();
    // we need auto tiering policy object to get its name.
    String newPolicyName = ControllerUtils.getFastPolicyNameFromVirtualPool(_dbClient, storage, newVirtualPool);
    if (isVmax3) {
        newPolicyName = _helper.getVMAX3FastSettingForVolume(volumeURIs.get(0), newPolicyName);
    }
    StorageGroupPolicyLimitsParam newVirtualPoolPolicyLimits = new StorageGroupPolicyLimitsParam(newPolicyName, newVirtualPool.getHostIOLimitBandwidth(), newVirtualPool.getHostIOLimitIOPs(), newVirtualPool.getCompressionEnabled(), storage);
    CIMObjectPath childGroupPath = _cimPath.getMaskingGroupPath(storage, childGroupName, SmisCommandHelper.MASKING_GROUP_TYPE.SE_DeviceMaskingGroup);
    if (isVmax3) {
        /**
         * VMAX3 part of multiple exports: volumes will be part of multiple SGs
         * One as FAST SG and others as non-FAST SG.
         * If the requested SG is non FAST, do nothing. Other export mask's call
         * will take care of updating FAST setting.
         */
        BlockObject bo = BlockObject.fetch(_dbClient, volumeURIs.get(0));
        if (_helper.isVolumePartOfMoreThanOneExport(storage, bo)) {
            String currentPolicyName = _helper.getVMAX3FastSettingAssociatedWithVolumeGroup(storage, childGroupPath);
            if (Constants.NONE.equalsIgnoreCase(currentPolicyName) && _helper.checkVolumeAssociatedWithAnyFASTSG(bo.getNativeId(), storage)) {
                Map<ExportMask, ExportGroup> maskToGroupMap = ExportUtils.getExportMasks(bo, _dbClient);
                if (maskToGroupMap.size() > 1) {
                    _log.info("Volumes {} are part of multiple storage groups. " + "FAST Policy will be (or might already be) changed during other export mask's call.", Joiner.on("\t").join(volumeURIs));
                    return true;
                } else {
                    _log.error("FAST Policy cannot be updated on this storage group" + " since volumes are already part of another FAST managed storage group.");
                    return false;
                }
            }
        }
    }
    if (!isVmax3 && !phantomSGNames.isEmpty() && !_helper.isFastPolicy(_helper.getAutoTieringPolicyNameAssociatedWithVolumeGroup(storage, childGroupPath)) && !_helper.isCascadedSG(storage, childGroupPath)) {
        /**
         * Phantom SG will be taken into consideration only if MV contains Non-cascaded Non-FAST SG
         */
        _log.info("**** Phantom Storage Group ****");
        /**
         * For Volumes in Phantom SG - Volumes part of Phantom SG will be in Non-cascaded Non-FAST Storage Group
         * (CTRL-9064)
         *
         * We have the phantom SGs having volumes which are part of this Masking view
         * Group requested volumes by SG
         * volumes in each Phantom SG
         * also add an entry with volumes to Non-FAST SG (volumes requested minus volumes already in phantom SG)
         *
         * For each SG,
         * If Phantom SG:
         * If it is requested for all volumes
         * change the policy associated with phantom SG
         * else
         * Remove the volumes from that phantom SG
         * add them to new/existing phantom SG which is associated with new policy
         * Note: if new policy is NONE, we just remove the volumes from phantom SG, no need to add them to another
         * phantom SG.
         * Since these volumes are already part of Non-FAST SG, they are part of MV.
         * Else if it is Non-FAST SG:
         * place those volumes in new/existing Phantom SG which is associated with new Policy
         */
        Map<String, List<URI>> volumeGroup = new HashMap<String, List<URI>>();
        List<URI> volumeURIsOfNonFASTSG = new ArrayList<URI>();
        volumeURIsOfNonFASTSG.addAll(volumeURIs);
        for (String phantomSGName : phantomSGNames) {
            List<URI> volURIs = _helper.findVolumesInStorageGroup(storage, phantomSGName, volumeURIs);
            if (!volURIs.isEmpty()) {
                volumeGroup.put(phantomSGName, volURIs);
                volumeURIsOfNonFASTSG.removeAll(volURIs);
            }
        }
        // put Non-FAST SG with volumes (volumes requested minus volumes already in phantom SG)
        if (!volumeURIsOfNonFASTSG.isEmpty()) {
            volumeGroup.put(childGroupName, volumeURIsOfNonFASTSG);
        }
        for (Entry<String, List<URI>> sgNameToVolumes : volumeGroup.entrySet()) {
            String sgName = sgNameToVolumes.getKey();
            List<URI> volumesInSG = sgNameToVolumes.getValue();
            CIMObjectPath sgPath = _cimPath.getMaskingGroupPath(storage, sgName, SmisCommandHelper.MASKING_GROUP_TYPE.SE_DeviceMaskingGroup);
            // 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) {
                // The force flag only needs to be set once
                if (!forceFlag) {
                    forceFlag = ExportUtils.useEMCForceFlag(_dbClient, volURI);
                }
            }
            /**
             * update Policy on this SG. We don't use Phantom SG for IO Limits
             */
            String currentPolicyName = _helper.getAutoTieringPolicyNameAssociatedWithVolumeGroup(storage, sgPath);
            _log.info("FAST policy name associated with Storage Group {} : {}", sgName, currentPolicyName);
            if (!_helper.isFastPolicy(currentPolicyName)) {
                /**
                 * Not a Phantom SG. Create new or use existing Phantom SG for the requested volumes
                 * Request: non-FAST volumes in SG (associated with MV) to FAST volumes
                 */
                addVolumesToPhantomStorageGroup(storage, exportMask, volumesInSG, newPolicyName, childGroupName, taskCompleter, forceFlag);
            } else {
                /**
                 * phantom SG
                 */
                _log.info("Checking on Phantom Storage Group {}", sgName);
                // check if phantom SG has the same set of volumes as the volume list provided
                if (isGivenVolumeListSameAsInStorageGroup(storage, sgPath, volumesInSG)) {
                    _log.info("Changing Policy on Phantom Storage Group {} since it is requested " + "for all the volumes in the Group.", sgName);
                    if (!currentPolicyName.equalsIgnoreCase(newPolicyName)) {
                        if (_helper.isFastPolicy(currentPolicyName)) {
                            _helper.removeVolumeGroupFromAutoTieringPolicy(storage, sgPath);
                        }
                        if (_helper.isFastPolicy(newPolicyName)) {
                            _log.info("Adding Storage Group {} to FAST Policy {}", sgName, newPolicyName);
                            addVolumeGroupToAutoTieringPolicy(storage, newPolicyName, sgPath, taskCompleter);
                            StorageGroupPolicyLimitsParam phantomStorageGroupPolicyLimitsParam = new StorageGroupPolicyLimitsParam(newPolicyName);
                            String newSGName = generateNewNameForPhantomSG(storage, childGroupName, phantomStorageGroupPolicyLimitsParam);
                            // update SG name according to new policy
                            _helper.updateStorageGroupName(client, sgPath, newSGName);
                        }
                    } else {
                        _log.info("Current and new policy names are same '{}'." + " No need to update it on SG.", currentPolicyName);
                    }
                    /**
                     * if new policy is NONE & all volumes in request
                     * remove phantom SG since it won't be needed anymore
                     * (because volumes are already part of Non-FAST SG associated with MV)
                     * Request: FAST volumes to Non-FAST
                     */
                    if (!_helper.isFastPolicy(newPolicyName)) {
                        removePhantomStorageGroup(storage, client, exportMask.getId(), sgName, sgPath, volumesInSG, forceFlag);
                    }
                } else {
                    /**
                     * remove requested volumes from this phantom SG
                     * add them to the new/existing phantom SG which is associated with target policy
                     */
                    _log.info("Request is made for part of volumes in the Group");
                    removePhantomStorageGroup(storage, client, exportMask.getId(), sgName, sgPath, volumesInSG, forceFlag);
                    if (_helper.isFastPolicy(newPolicyName)) {
                        addVolumesToPhantomStorageGroup(storage, exportMask, volumesInSG, newPolicyName, childGroupName, taskCompleter, forceFlag);
                    }
                }
            }
            policyUpdated = true;
        }
    } else {
        /**
         * Usual flow for regular SGs
         *
         * check if SG has the same set of volumes as the volume list provided.
         */
        if (isGivenVolumeListSameAsInStorageGroup(storage, childGroupPath, volumeURIs)) {
            /**
             * update Policy and Limits on this SG
             */
            _log.info("Request is made for all volumes in the Group. Updating Policy and Limits on this Storage Group..");
            CIMInstance childGroupInstance = null;
            if (isVmax3) {
                childGroupInstance = _helper.getInstance(storage, childGroupPath, false, false, SmisConstants.PS_V3_STORAGE_GROUP_PROPERTIES);
            } else {
                childGroupInstance = _helper.checkExists(storage, childGroupPath, false, false);
            }
            StorageGroupPolicyLimitsParam currentStorageGroupPolicyLimits = _helper.createStorageGroupPolicyLimitsParam(storage, childGroupInstance);
            String currentPolicyName = currentStorageGroupPolicyLimits.getAutoTierPolicyName();
            if (!currentPolicyName.equalsIgnoreCase(newPolicyName)) {
                _log.info("FAST policy name associated with Storage Group {} : {}", childGroupName, currentPolicyName);
                if (isVmax3) {
                    newPolicyName = _helper.getVMAX3FastSettingWithRightNoneString(storage, newPolicyName);
                    CIMInstance toUpdate = new CIMInstance(childGroupInstance.getObjectPath(), _helper.getV3FastSettingProperties(newPolicyName));
                    _helper.modifyInstance(storage, toUpdate, SmisConstants.PS_V3_FAST_SETTING_PROPERTIES);
                    _log.info("Modified Storage Group {} FAST Setting to {}", childGroupName, newPolicyName);
                } else {
                    if (_helper.isFastPolicy(currentPolicyName)) {
                        _helper.removeVolumeGroupFromAutoTieringPolicy(storage, childGroupPath);
                    }
                    if (_helper.isFastPolicy(newPolicyName)) {
                        _log.info("Adding Storage Group {} to FAST Policy {}", childGroupName, newPolicyName);
                        addVolumeGroupToAutoTieringPolicy(storage, newPolicyName, childGroupPath, taskCompleter);
                    }
                }
            } else {
                _log.info("Current and new policy names are same '{}'." + " No need to update it on Storage Group.", currentPolicyName);
            }
            // Even if we don't change policy name on device
            // we need to set policyUpdated = true else rollback kicks in
            policyUpdated = true;
            // Update the compression attributes if it needs to be
            if (isVmax3) {
                // refresh the SG instance since compression property is enabled by default
                // when SG becomes FAST managed.
                childGroupInstance = _helper.getInstance(storage, childGroupPath, false, false, SmisConstants.PS_EMC_COMPRESSION);
                boolean currentCompressionSetting = SmisUtils.getEMCCompressionForStorageGroup(childGroupInstance);
                boolean newCompressionSetting = newVirtualPoolPolicyLimits.getCompression();
                if (currentCompressionSetting != newCompressionSetting) {
                    CIMInstance toUpdate = new CIMInstance(childGroupInstance.getObjectPath(), _helper.getV3CompressionProperties(newCompressionSetting));
                    _helper.modifyInstance(storage, toUpdate, SmisConstants.PS_EMC_COMPRESSION);
                    _log.info("Modified Storage Group {} Compression setting to {}", childGroupName, newCompressionSetting);
                } else {
                    _log.info("Current and new compression values are same '{}'." + " No need to update it on Storage Group.", newCompressionSetting);
                }
            }
            // update host io limits if need be
            if (!HostIOLimitsParam.isEqualsLimit(currentStorageGroupPolicyLimits.getHostIOLimitBandwidth(), newVirtualPoolPolicyLimits.getHostIOLimitBandwidth())) {
                _helper.updateHostIOLimitBandwidth(client, childGroupPath, newVirtualPoolPolicyLimits.getHostIOLimitBandwidth());
                policyUpdated = true;
            }
            if (!HostIOLimitsParam.isEqualsLimit(currentStorageGroupPolicyLimits.getHostIOLimitIOPs(), newVirtualPoolPolicyLimits.getHostIOLimitIOPs())) {
                _helper.updateHostIOLimitIOPs(client, childGroupPath, newVirtualPoolPolicyLimits.getHostIOLimitIOPs());
                policyUpdated = true;
            }
            if (policyUpdated) {
                Set<Initiator> initiators = ExportMaskUtils.getInitiatorsForExportMask(_dbClient, exportMask, null);
                _helper.updateStorageGroupName(client, childGroupPath, generateStorageGroupName(storage, exportMask, initiators, newVirtualPoolPolicyLimits));
            }
        } else if (isVmax3) {
            /**
             * Requested for fewer members in a SG
             *
             * V3 supports moveMembers from one SG to another, provided some conditions met.
             * see #helper.moveVolumesFromOneStorageGroupToAnother() for criteria.
             *
             * validate that current SG is not a parent SG and it is not associated with MV
             * check if there is another SG under CSG with new fastSetting & limits
             * else create new SG (with new fastSetting, IO limits) and associate it with CSG
             * call 'moveMembers' to move volumes from current SG to new SG
             */
            _log.info("Request is made for part of volumes in the Group (VMAX3). Moving those volumes to new Storage Group..");
            if (!_helper.isCascadedSG(storage, childGroupPath) && !_helper.findStorageGroupsAssociatedWithOtherMaskingViews(storage, childGroupName)) {
                String parentGroupName = _helper.getStorageGroupForGivenMaskingView(exportMask.getMaskName(), storage);
                Map<StorageGroupPolicyLimitsParam, List<String>> childGroupsByFast = _helper.groupStorageGroupsByAssociation(storage, parentGroupName);
                List<String> newChildGroups = childGroupsByFast.get(newVirtualPoolPolicyLimits);
                if (newChildGroups != null) {
                    // remove CSG
                    newChildGroups.remove(parentGroupName);
                }
                boolean newGroup = false;
                CIMObjectPath newChildGroupPath = null;
                String newChildGroupName = null;
                if (newChildGroups != null && !newChildGroups.isEmpty()) {
                    newChildGroupName = newChildGroups.iterator().next();
                    newChildGroupPath = _cimPath.getMaskingGroupPath(storage, newChildGroupName, SmisCommandHelper.MASKING_GROUP_TYPE.SE_DeviceMaskingGroup);
                } else {
                    newGroup = true;
                    newPolicyName = _helper.getVMAX3FastSettingWithRightNoneString(storage, newPolicyName);
                    String[] tokens = newPolicyName.split(Constants.SMIS_PLUS_REGEX);
                    newChildGroupPath = _helper.createVolumeGroupBasedOnSLO(storage, storage, tokens[0], tokens[1], tokens[2]);
                    // 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 : volumeURIs) {
                        if (!forceFlag) {
                            forceFlag = ExportUtils.useEMCForceFlag(_dbClient, volURI);
                        }
                    }
                    addGroupsToCascadedVolumeGroup(storage, parentGroupName, newChildGroupPath, null, null, forceFlag);
                }
                // We could enter the same situation if any of the SG characteristics were modified without ViPR knowledge.
                if (childGroupName.equalsIgnoreCase(newChildGroupName)) {
                    _log.info("Current Storage Group {} has the required charcteristics" + "No need to invoke SMI-S moveMembers method. Performing NO-OP", newChildGroupName);
                } else {
                    SmisJob moveVolumesToSGJob = new SmisSynchSubTaskJob(null, storage.getId(), SmisConstants.MOVE_MEMBERS);
                    _helper.moveVolumesFromOneStorageGroupToAnother(storage, childGroupPath, newChildGroupPath, volumeURIs, moveVolumesToSGJob);
                }
                if (newGroup) {
                    // update host IO limits if need be
                    if (newVirtualPoolPolicyLimits.isHostIOLimitBandwidthSet()) {
                        _helper.updateHostIOLimitBandwidth(client, newChildGroupPath, newVirtualPoolPolicyLimits.getHostIOLimitBandwidth());
                    }
                    if (newVirtualPoolPolicyLimits.isHostIOLimitIOPsSet()) {
                        _helper.updateHostIOLimitIOPs(client, newChildGroupPath, newVirtualPoolPolicyLimits.getHostIOLimitIOPs());
                    }
                    // Honor the compression settings if needed..
                    if (!newVirtualPoolPolicyLimits.getCompression()) {
                        // If the user opted out of compression, and the created SG has compression enabled by default,
                        // we need to opt out..
                        CIMInstance newChildGroupInstance = _helper.getInstance(storage, newChildGroupPath, false, false, SmisConstants.PS_EMC_COMPRESSION);
                        if (SmisUtils.getEMCCompressionForStorageGroup(newChildGroupInstance)) {
                            CIMInstance toUpdate = new CIMInstance(newChildGroupInstance.getObjectPath(), _helper.getV3CompressionProperties(false));
                            _helper.modifyInstance(storage, toUpdate, SmisConstants.PS_EMC_COMPRESSION);
                        }
                    }
                    Set<Initiator> initiators = ExportMaskUtils.getInitiatorsForExportMask(_dbClient, exportMask, null);
                    _helper.updateStorageGroupName(client, newChildGroupPath, generateStorageGroupName(storage, exportMask, initiators, newVirtualPoolPolicyLimits));
                }
                policyUpdated = true;
            } else {
                _log.info("Conditions for 'moveMembers' didn't meet for Storage Group {}." + " Hence, cannot move volumes to new Storage Group with new policy and limits.", childGroupName);
            }
        } else {
            _log.info("Given Volume list is not same as the one in Storage Group {}." + " Hence, FAST policy change won't be done on it.", childGroupName);
        }
    }
    return policyUpdated;
}
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) HashMap(java.util.HashMap) ExportMask(com.emc.storageos.db.client.model.ExportMask) CIMObjectPath(javax.cim.CIMObjectPath) ArrayList(java.util.ArrayList) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) SmisSynchSubTaskJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisSynchSubTaskJob) ExportGroup(com.emc.storageos.db.client.model.ExportGroup) Initiator(com.emc.storageos.db.client.model.Initiator) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) StorageGroupPolicyLimitsParam(com.emc.storageos.volumecontroller.impl.StorageGroupPolicyLimitsParam) SmisJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisJob) WBEMClient(javax.wbem.client.WBEMClient) Map(java.util.Map) HashMap(java.util.HashMap) AbstractMap(java.util.AbstractMap) StringMap(com.emc.storageos.db.client.model.StringMap) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 4 with SmisSynchSubTaskJob

use of com.emc.storageos.volumecontroller.impl.smis.job.SmisSynchSubTaskJob in project coprhd-controller by CoprHD.

the class VmaxExportOperations method deleteMaskingView.

private boolean deleteMaskingView(StorageSystem storage, URI exportMaskURI, Map<StorageGroupPolicyLimitsParam, List<String>> childrenStorageGroupMap, TaskCompleter taskCompleter) throws Exception {
    boolean maskingWasDeleted = false;
    _log.debug("{} deleteMaskingView START...", storage.getSerialNumber());
    String groupName = _helper.getExportMaskName(exportMaskURI);
    CIMInstance maskingViewInstance = maskingViewExists(storage, groupName);
    if (maskingViewInstance == null) {
        _log.info("{} deleteMaskingView END...Masking view already deleted: {}", storage.getSerialNumber(), groupName);
        return true;
    }
    try {
        // get parent ig from masking view
        CIMObjectPath igPath = _helper.getInitiatorGroupForGivenMaskingView(maskingViewInstance.getObjectPath(), storage);
        // 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;
        ExportMask exportMask = _dbClient.queryObject(ExportMask.class, exportMaskURI);
        for (String volURI : exportMask.getUserAddedVolumes().values()) {
            forceFlag = ExportUtils.useEMCForceFlag(_dbClient, URI.create(volURI));
            if (forceFlag) {
                break;
            }
        }
        CIMArgument[] inArgs = _helper.getDeleteMaskingViewInputArguments(storage, exportMaskURI, forceFlag);
        CIMArgument[] outArgs = new CIMArgument[5];
        // Collect the current list of associated IGs for the MaskingView. This
        // will include cascaded and child IGs.
        List<CIMObjectPath> igPaths = new ArrayList<CIMObjectPath>();
        getInitiatorGroupsFromMvOrIg(storage, maskingViewInstance.getObjectPath(), igPaths);
        // remove parent IG
        igPaths.remove(igPath);
        WBEMClient client = _helper.getConnection(storage).getCimClient();
        // if SG is associated with other MVs/parent groups, set IO Limits back on it at the end
        for (Entry<StorageGroupPolicyLimitsParam, List<String>> storageGroupEntry : childrenStorageGroupMap.entrySet()) {
            for (String storageGroupName : storageGroupEntry.getValue()) {
                CIMObjectPath storageGroupPath = _cimPath.getMaskingGroupPath(storage, storageGroupName, SmisCommandHelper.MASKING_GROUP_TYPE.SE_DeviceMaskingGroup);
                _helper.resetHostIOLimits(client, storage, storageGroupPath);
            }
        }
        // Invoke operation to delete the MaskingView. This should clean up
        // IG that are directly related to the MV. We will have to check if any
        // others that may be child IGs are left dangling. If they are and not
        // associated with other IGs or MVs, we shall have to delete them.
        SmisSynchSubTaskJob deleteJob = new SmisSynchSubTaskJob(null, storage.getId(), "DeleteMaskingView");
        _helper.invokeMethodSynchronously(storage, _cimPath.getControllerConfigSvcPath(storage), "DeleteMaskingView", inArgs, outArgs, deleteJob);
        if (deleteJob.isSuccess()) {
            if (_helper.checkExists(storage, igPath, true, false) != null) {
                List<CIMObjectPath> associatedMaskingViews = getAssociatedMaskingViews(storage, igPath);
                List<CIMObjectPath> associatedIGs = getAssociatedParentIGs(storage, igPath);
                if (associatedMaskingViews.isEmpty() && (associatedIGs.isEmpty() || _helper.isCascadedIG(storage, igPath))) {
                    // parentIGs has associated IGs, not the parent
                    // delete CIG if it is not associated with any MV (CTRL-9662)
                    // CTRL-9323 : deleting Parent IG associated with masking view.
                    deleteInitiatorGroup(storage, igPath);
                } else {
                    _log.info(String.format("Did not delete %s as it is still associated to MaskingViews [%s] and/or AssociatedIGs [%s]", igPath.toString(), Joiner.on(',').join(associatedMaskingViews), Joiner.on(',').join(associatedIGs)));
                }
            } else {
                _log.info("IG already deleted {}", igPath);
            }
            // CTRL-9323 : only child IGs will be processed, as parent is deleted already we will not hit the cyclic
            // issue
            maskingWasDeleted = checkIGsAndDeleteIfUnassociated(storage, igPaths);
            if (!maskingWasDeleted) {
                taskCompleter.error(_dbClient, DeviceControllerException.errors.unableToDeleteIGs(groupName));
                return false;
            }
        } else {
            String opName = ResourceOperationTypeEnum.DELETE_EXPORT_GROUP.getName();
            ServiceError serviceError = DeviceControllerException.errors.jobFailedOp(opName);
            taskCompleter.error(_dbClient, serviceError);
            return maskingWasDeleted;
        }
        _log.debug("{} deleteMaskingView END...", storage.getSerialNumber());
    } catch (WBEMException we) {
        _log.error(String.format("Problem when trying to delete masking view - array: %s, view: %s", storage.getSerialNumber(), groupName), we);
        String opName = ResourceOperationTypeEnum.DELETE_EXPORT_GROUP.getName();
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(we);
        taskCompleter.error(_dbClient, serviceError);
        throw we;
    }
    _log.debug("{} deleteMaskingView END...", storage.getSerialNumber());
    return maskingWasDeleted;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ExportMask(com.emc.storageos.db.client.model.ExportMask) CIMObjectPath(javax.cim.CIMObjectPath) ArrayList(java.util.ArrayList) WBEMException(javax.wbem.WBEMException) CIMInstance(javax.cim.CIMInstance) SmisSynchSubTaskJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisSynchSubTaskJob) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) StorageGroupPolicyLimitsParam(com.emc.storageos.volumecontroller.impl.StorageGroupPolicyLimitsParam) WBEMClient(javax.wbem.client.WBEMClient) CIMArgument(javax.cim.CIMArgument)

Aggregations

SmisSynchSubTaskJob (com.emc.storageos.volumecontroller.impl.smis.job.SmisSynchSubTaskJob)4 SmisJob (com.emc.storageos.volumecontroller.impl.smis.job.SmisJob)3 CIMArgument (javax.cim.CIMArgument)3 CIMObjectPath (javax.cim.CIMObjectPath)3 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 ExportMask (com.emc.storageos.db.client.model.ExportMask)2 StorageGroupPolicyLimitsParam (com.emc.storageos.volumecontroller.impl.StorageGroupPolicyLimitsParam)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 CIMInstance (javax.cim.CIMInstance)2 WBEMClient (javax.wbem.client.WBEMClient)2 BlockObject (com.emc.storageos.db.client.model.BlockObject)1 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)1 Initiator (com.emc.storageos.db.client.model.Initiator)1 StringMap (com.emc.storageos.db.client.model.StringMap)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)1 Sets.newHashSet (com.google.common.collect.Sets.newHashSet)1 URI (java.net.URI)1 AbstractMap (java.util.AbstractMap)1