Search in sources :

Example 51 with BaseCollectionException

use of com.emc.storageos.plugins.BaseCollectionException in project coprhd-controller by CoprHD.

the class ExportProcessor method processResult.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.plugins.common.Processor#processResult(com.emc.storageos.plugins.common.domainmodel.Operation,
     * java.lang.Object, java.util.Map)
     */
@SuppressWarnings("unchecked")
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    initialize(operation, resultObj, keyMap);
    CloseableIterator<CIMInstance> it = null;
    EnumerateResponse<CIMInstance> response = null;
    List<Initiator> matchedInitiators = new ArrayList<Initiator>();
    List<StoragePort> matchedPorts = new ArrayList<StoragePort>();
    WBEMClient client = SMICommunicationInterface.getCIMClient(keyMap);
    StringSet knownIniSet = new StringSet();
    StringSet knownNetworkIdSet = new StringSet();
    StringSet knownPortSet = new StringSet();
    StringSet knownVolumeSet = new StringSet();
    try {
        // set lun masking view CIM path
        CIMObjectPath path = this.getObjectPathfromCIMArgument(_args, keyMap);
        UnManagedExportMask mask = this.getUnManagedExportMask(path);
        mask.setMaskingViewPath(path.toString());
        _logger.info("looking at lun masking view: " + path.toString());
        CIMInstance lunMaskingView = client.getInstance(path, false, false, null);
        if (lunMaskingView != null) {
            String maskName = CIMPropertyFactory.getPropertyValue(lunMaskingView, SmisConstants.CP_NAME);
            if (maskName != null) {
                mask.setMaskName(maskName);
            }
            _logger.info("set UnManagedExportMask maskName to " + mask.getMaskName());
        } else {
            _logger.info("lunMaskingView was null");
        }
        CIMProperty<String> deviceIdProperty = (CIMProperty<String>) path.getKey(SmisConstants.CP_DEVICE_ID);
        if (deviceIdProperty != null) {
            mask.setNativeId(deviceIdProperty.getValue());
        }
        _logger.info("set UnManagedExportMask nativeId to " + mask.getNativeId());
        // set storage system id
        URI systemId = (URI) keyMap.get(Constants.SYSTEMID);
        mask.setStorageSystemUri(systemId);
        response = (EnumerateResponse<CIMInstance>) resultObj;
        processVolumesAndInitiatorsPaths(response.getResponses(), mask, matchedInitiators, matchedPorts, knownIniSet, knownNetworkIdSet, knownPortSet, knownVolumeSet);
        while (!response.isEnd()) {
            _logger.info("Processing next Chunk");
            response = client.getInstancesWithPath(Constants.MASKING_PATH, response.getContext(), new UnsignedInteger32(BATCH_SIZE));
            processVolumesAndInitiatorsPaths(response.getResponses(), mask, matchedInitiators, matchedPorts, knownIniSet, knownNetworkIdSet, knownPortSet, knownVolumeSet);
        }
        // CTRL - 8918 - always update the mask with new initiators and volumes.
        mask.replaceNewWithOldResources(knownIniSet, knownNetworkIdSet, knownVolumeSet, knownPortSet);
        // get zones and store them?
        updateZoningMap(mask, matchedInitiators, matchedPorts);
        updateVplexBackendVolumes(mask, matchedInitiators);
        updateRecoverPointVolumes(mask, matchedInitiators);
    } catch (Exception e) {
        _logger.error("something failed", e);
    } finally {
        if (it != null) {
            it.close();
        }
        wrapUp();
        if (response != null) {
            try {
                client.closeEnumeration(Constants.MASKING_PATH, response.getContext());
            } catch (Exception e) {
                _logger.debug("Exception occurred while closing enumeration", e);
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) StoragePort(com.emc.storageos.db.client.model.StoragePort) CIMObjectPath(javax.cim.CIMObjectPath) UnsignedInteger32(javax.cim.UnsignedInteger32) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) Initiator(com.emc.storageos.db.client.model.Initiator) CIMProperty(javax.cim.CIMProperty) StringSet(com.emc.storageos.db.client.model.StringSet) WBEMClient(javax.wbem.client.WBEMClient) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask)

Example 52 with BaseCollectionException

use of com.emc.storageos.plugins.BaseCollectionException in project coprhd-controller by CoprHD.

the class ControllerConfigurationProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        @SuppressWarnings("unchecked") final Iterator<CIMObjectPath> it = (Iterator<CIMObjectPath>) resultObj;
        while (it.hasNext()) {
            CIMObjectPath controllerConfigurationService = it.next();
            String systemName = controllerConfigurationService.getKey(Constants.SYSTEMNAME).getValue().toString();
            String serialID = (String) keyMap.get(Constants._serialID);
            if (systemName.contains(serialID)) {
                addPath(keyMap, operation.getResult(), controllerConfigurationService);
                if (systemName.toLowerCase().contains(Constants.SYMMETRIX)) {
                    keyMap.put(Constants.VMAXConfigurationService, controllerConfigurationService);
                } else if (systemName.toLowerCase().contains(Constants.CLARIION)) {
                    keyMap.put(Constants.VNXConfigurationService, controllerConfigurationService);
                }
            }
        }
    } catch (Exception e) {
        _logger.error("Controller Configuration Service Discovery Failed : ", e);
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) Iterator(java.util.Iterator) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 53 with BaseCollectionException

use of com.emc.storageos.plugins.BaseCollectionException in project coprhd-controller by CoprHD.

the class FASTPolicyProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        @SuppressWarnings("unchecked") final Iterator<CIMInstance> it = (Iterator<CIMInstance>) resultObj;
        _newFastPolicies = new ArrayList<AutoTieringPolicy>();
        _updateFastPolicies = new ArrayList<AutoTieringPolicy>();
        _dbClient = (DbClient) keyMap.get(Constants.dbClient);
        AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
        URI storageSystemURI = profile.getSystemId();
        Set<String> policyNames = new HashSet<String>();
        boolean vnxStartHighThenAutoTierPolicyCreated = false;
        while (it.hasNext()) {
            CIMInstance policyObjectInstance = it.next();
            CIMObjectPath policyObjectPath = policyObjectInstance.getObjectPath();
            String systemName = policyObjectPath.getKey(Constants.SYSTEMNAME).getValue().toString();
            if (!systemName.contains((String) keyMap.get(Constants._serialID))) {
                continue;
            }
            String[] array = systemName.split(Constants.PATH_DELIMITER_REGEX);
            String policyID = getFASTPolicyID(policyObjectPath);
            // Trim the policyID from "-+-" to "+" if necessary
            Boolean usingSMIS80 = (Boolean) keyMap.get(Constants.USING_SMIS80_DELIMITERS);
            if ((null != usingSMIS80) && (true == usingSMIS80)) {
                policyID = policyID.replaceAll(Constants.SMIS_80_STYLE, Constants.SMIS_PLUS_REGEX);
            }
            AutoTieringPolicy policy = getAutoTieringPolicyByNameFromDB(policyID, _dbClient);
            String policyRuleName = policyObjectPath.getKey(Constants.POLICYRULENAME).getValue().toString();
            policyNames.add(policyRuleName);
            String policyEnabled = policyObjectInstance.getPropertyValue(Constants.ENABLED).toString();
            String provisioningType = AutoTieringPolicy.ProvisioningType.getType(policyObjectInstance.getPropertyValue(Constants.PROVISIONING_TYPE).toString());
            /**
             * Only user Defined Policies are considered for VMAX
             * For VNX, only default policies are present, there is no concept of userDefined
             */
            if (!Constants.SYMMETRIX.equalsIgnoreCase(array[0]) && !Constants.CLARIION.equalsIgnoreCase(array[0])) {
                _logger.info("Unsupported FAST Policy :{}", policyID);
                return;
            }
            String fastPolicyServiceConstant = getFASTPolicyServiceConstant(array[0], policyRuleName);
            if (null != fastPolicyServiceConstant) {
                createFASTPolicy(policyID, policy, policyRuleName, storageSystemURI, policyEnabled, provisioningType);
                addPath(keyMap, fastPolicyServiceConstant, policyObjectPath);
                keyMap.put(policyRuleName, policyObjectPath);
                if (fastPolicyServiceConstant.equals(Constants.VMAXFASTPOLICIES)) {
                    addDeviceGroupNamesToSetUsedInVerifyingExistence(policyRuleName, keyMap, provisioningType);
                    addDeviceGroupNamesToSetUsedInVerifyingFASTPolicyRelationShipExistence(policyRuleName, keyMap, provisioningType);
                } else if (fastPolicyServiceConstant.equals(Constants.VNXFASTPOLICIES) && !vnxStartHighThenAutoTierPolicyCreated) {
                    /**
                     * NOTE: start_high_then_auto_tier policy will not be discovered, thus must
                     * create it for VNX in ViPR if not created already.
                     */
                    String startHighThenAutoTierPolicyName = Constants.START_HIGH_THEN_AUTO_TIER_POLICY_NAME;
                    policyNames.add(startHighThenAutoTierPolicyName);
                    String startHighThenAutTierPolicyId = getFASTPolicyID(systemName, startHighThenAutoTierPolicyName);
                    AutoTieringPolicy startHighThenAutTierPolicy = getAutoTieringPolicyByNameFromDB(startHighThenAutTierPolicyId, _dbClient);
                    createFASTPolicy(startHighThenAutTierPolicyId, startHighThenAutTierPolicy, startHighThenAutoTierPolicyName, storageSystemURI, "1", AutoTieringPolicy.ProvisioningType.All.name());
                    vnxStartHighThenAutoTierPolicyCreated = true;
                }
            }
        }
        _dbClient.createObject(_newFastPolicies);
        _dbClient.persistObject(_updateFastPolicies);
        performPolicyBookKeeping(policyNames, storageSystemURI);
    } catch (Exception e) {
        _logger.error("FAST Policy Processing failed", e);
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) AccessProfile(com.emc.storageos.plugins.AccessProfile) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) IOException(java.io.IOException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) AutoTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy) Iterator(java.util.Iterator) HashSet(java.util.HashSet)

Example 54 with BaseCollectionException

use of com.emc.storageos.plugins.BaseCollectionException in project coprhd-controller by CoprHD.

the class PersistFASTPolicyProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        _dbClient = (DbClient) keyMap.get(Constants.dbClient);
        List<AutoTieringPolicy> fastPolicies = new ArrayList<AutoTieringPolicy>();
        @SuppressWarnings("unchecked") Map<String, Set<String>> mapping = (Map<String, Set<String>>) keyMap.get(Constants.POLICY_TO_POOLS_MAPPING);
        for (String key : mapping.keySet()) {
            AutoTieringPolicy policy = getAutoTieringPolicyByNameFromDB(key, _dbClient);
            Set<String> pools = mapping.get(key);
            policy.addPools(pools);
            fastPolicies.add(policy);
        }
        _dbClient.persistObject(fastPolicies);
    } catch (Exception e) {
        _logger.error("Adding Pools to POlicy Objects and Persisting failed :", e);
    }
}
Also used : AutoTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy) Set(java.util.Set) ArrayList(java.util.ArrayList) Map(java.util.Map) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 55 with BaseCollectionException

use of com.emc.storageos.plugins.BaseCollectionException in project coprhd-controller by CoprHD.

the class TierPercentageProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    final Iterator<CIMInstance> it = (Iterator<CIMInstance>) resultObj;
    _dbClient = (DbClient) keyMap.get(Constants.dbClient);
    while (it.hasNext()) {
        try {
            CIMInstance symmAssociatedPolicyInstance = it.next();
            CIMObjectPath symmAssociatedPolicyPath = symmAssociatedPolicyInstance.getObjectPath();
            CIMObjectPath tierPath = (CIMObjectPath) symmAssociatedPolicyPath.getKey(DEPENDENT).getValue();
            String tierPercent = symmAssociatedPolicyInstance.getPropertyValue(MAX_PERCENT_ALLOCATED).toString();
            String tierID = tierPath.getKey(Constants.INSTANCEID).getValue().toString();
            String tierNativeGuid = getTierNativeGuidForVMax(tierID);
            StorageTier tierObject = checkStorageTierExistsInDB(tierNativeGuid, _dbClient);
            if (null != tierObject) {
                tierObject.setPercentage(tierPercent);
                _dbClient.persistObject(tierObject);
            }
        } catch (Exception e) {
            _logger.error("Vmax Tier Percentage Discovery failed", e);
        }
    }
}
Also used : Iterator(java.util.Iterator) CIMObjectPath(javax.cim.CIMObjectPath) StorageTier(com.emc.storageos.db.client.model.StorageTier) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Aggregations

BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)185 Iterator (java.util.Iterator)66 CIMInstance (javax.cim.CIMInstance)66 CIMObjectPath (javax.cim.CIMObjectPath)59 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)55 IOException (java.io.IOException)47 URI (java.net.URI)47 ArrayList (java.util.ArrayList)47 PostMethod (org.apache.commons.httpclient.methods.PostMethod)36 ResponsePacket (com.emc.nas.vnxfile.xmlapi.ResponsePacket)35 Status (com.emc.nas.vnxfile.xmlapi.Status)33 AccessProfile (com.emc.storageos.plugins.AccessProfile)30 List (java.util.List)30 Map (java.util.Map)30 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)28 StoragePool (com.emc.storageos.db.client.model.StoragePool)27 Header (org.apache.commons.httpclient.Header)27 StoragePort (com.emc.storageos.db.client.model.StoragePort)22 HashSet (java.util.HashSet)18 URISyntaxException (java.net.URISyntaxException)17