Search in sources :

Example 31 with BaseCollectionException

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

the class VolumeSizeProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    DbClient _dbClient;
    AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
    try {
        String minVolSize = null;
        String maxVolSize = null;
        _dbClient = (DbClient) keyMap.get(Constants.dbClient);
        StorageSystem device = getStorageSystem(_dbClient, profile.getSystemId());
        if (resultObj instanceof CIMArgument<?>[]) {
            CIMArgument<?>[] outputArguments = (CIMArgument<?>[]) resultObj;
            for (CIMArgument<?> outArg : outputArguments) {
                if (null == outArg) {
                    continue;
                }
                if (outArg.getName().equalsIgnoreCase(MINIMUM_VOLUME_SIZE)) {
                    minVolSize = outArg.getValue().toString();
                } else if (outArg.getName().equalsIgnoreCase(MAXIMUM_VOLUME_SIZE)) {
                    maxVolSize = outArg.getValue().toString();
                }
            }
            // we are setting at compile time, hence value will be there always.
            CIMObjectPath poolObjectPath = getObjectPathfromCIMArgument();
            String instanceID = poolObjectPath.getKey(Constants.INSTANCEID).getValue().toString();
            StoragePool pool = checkStoragePoolExistsInDB(getNativeIDFromInstance(instanceID), _dbClient, device);
            if (null != pool) {
                Long maxVolumeSize = ControllerUtils.convertBytesToKBytes(maxVolSize);
                Long minVolumeSize = ControllerUtils.convertBytesToKBytes(minVolSize);
                if (Type.ibmxiv.name().equals((device.getSystemType()))) {
                    String supportedResourceType = pool.getSupportedResourceTypes();
                    if (SupportedResourceTypes.THIN_ONLY.name().equals(supportedResourceType)) {
                        pool.setMaximumThinVolumeSize(maxVolumeSize);
                        pool.setMinimumThinVolumeSize(minVolumeSize);
                    } else if (SupportedResourceTypes.THICK_ONLY.name().equals(supportedResourceType)) {
                        pool.setMaximumThickVolumeSize(maxVolumeSize);
                        pool.setMinimumThickVolumeSize(minVolumeSize);
                    }
                } else {
                    // TODO - could this be changed to use the same logic as for IBM pool?
                    // if the result is obtained from calling on Thick, use thick volume size else thin
                    String elementType = determineCallType();
                    if (elementType.equalsIgnoreCase(FIVE)) {
                        pool.setMaximumThinVolumeSize(maxVolumeSize);
                        pool.setMinimumThinVolumeSize(minVolumeSize);
                    } else if (elementType.equalsIgnoreCase(THREE)) {
                        pool.setMaximumThickVolumeSize(maxVolumeSize);
                        pool.setMinimumThickVolumeSize(minVolumeSize);
                    }
                }
                _logger.info(String.format("Maximum limits for volume capacity in storage pool: %s  %n   max thin volume capacity: %s, max thick volume capacity: %s ", pool.getId(), pool.getMaximumThinVolumeSize(), pool.getMaximumThickVolumeSize()));
                _dbClient.persistObject(pool);
            }
        }
    } catch (Exception e) {
        _logger.error("Failed while processing Result : ", e);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) StoragePool(com.emc.storageos.db.client.model.StoragePool) CIMObjectPath(javax.cim.CIMObjectPath) AccessProfile(com.emc.storageos.plugins.AccessProfile) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) CIMArgument(javax.cim.CIMArgument)

Example 32 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 {
        final Iterator<CIMObjectPath> it = (Iterator<CIMObjectPath>) resultObj;
        while (it.hasNext()) {
            final CIMObjectPath policyObjectPath = it.next();
            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 policyRuleName = policyObjectPath.getKey(Constants.POLICYRULENAME).getValue().toString();
            log.info("Policy Name {}", policyRuleName);
            String policyKey = validateFastPolicy(array[0], policyRuleName);
            if (null != policyKey) {
                log.info("Adding Policy Object Path {}", policyObjectPath);
                addPath(keyMap, policyKey, policyObjectPath);
            }
        }
    } catch (Exception e) {
        log.error("Fast Policy discovery failed during UnManaged Volume discovery", e);
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) Iterator(java.util.Iterator) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 33 with BaseCollectionException

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

the class MetaVolumeMembersProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        DbClient dbClient = (DbClient) keyMap.get(Constants.dbClient);
        WBEMClient client = SMICommunicationInterface.getCIMClient(keyMap);
        CIMObjectPath[] metaMembersPaths = (CIMObjectPath[]) getFromOutputArgs((CIMArgument[]) resultObj, "OutElements");
        if (metaMembersPaths == null || (metaMembersPaths.length == 0)) {
            _logger.info(String.format("There are no meta members to process"));
        } else {
            _logger.debug(String.format("Processing meta members: %s", Arrays.toString(metaMembersPaths)));
            // Get volume from db
            _logger.debug(String.format("Args size: %s", _args.size()));
            Object[] arguments = (Object[]) _args.get(0);
            CIMArgument theElement = ((CIMArgument[]) arguments[2])[1];
            _logger.info(String.format("TheElement: %s, type %s", theElement.getValue().toString(), theElement.getValue().getClass().toString()));
            CIMObjectPath theElementPath = (CIMObjectPath) theElement.getValue();
            UnManagedVolume preExistingVolume = null;
            String isMetaVolume = "true";
            String nativeGuid;
            // Check if storage volume exists in db (the method is called from re-discovery context).
            nativeGuid = getVolumeNativeGuid(theElementPath);
            Volume storageVolume = checkStorageVolumeExistsInDB(nativeGuid, dbClient);
            if (null == storageVolume || storageVolume.getInactive()) {
                // Check if unmanaged volume exists in db (the method is called from unmanaged volumes discovery context).
                nativeGuid = getUnManagedVolumeNativeGuidFromVolumePath(theElementPath);
                _logger.debug("Volume nativeguid :" + nativeGuid);
                preExistingVolume = checkUnManagedVolumeExistsInDB(nativeGuid, dbClient);
                if (null == preExistingVolume) {
                    _logger.debug("Volume Info Object not found :" + nativeGuid);
                    return;
                }
                isMetaVolume = preExistingVolume.getVolumeCharacterstics().get(UnManagedVolume.SupportedVolumeCharacterstics.IS_METAVOLUME.toString());
            } else {
                _logger.debug("Volume managed by Bourne :" + storageVolume.getNativeGuid());
                isMetaVolume = storageVolume.getIsComposite().toString();
            }
            if (isMetaVolume.equalsIgnoreCase("false")) {
                _logger.error(String.format("MetaVolumeMembersProcessor called for regular volume: %s", nativeGuid));
                return;
            }
            Integer membersCount = metaMembersPaths.length;
            // get meta member size. use second member --- the first member will show size of meta volume itself.
            CIMObjectPath metaMemberPath = metaMembersPaths[1];
            CIMInstance cimVolume = client.getInstance(metaMemberPath, false, false, META_MEMBER_SIZE_INFO);
            CIMProperty consumableBlocks = cimVolume.getProperty(SmisConstants.CP_CONSUMABLE_BLOCKS);
            CIMProperty blockSize = cimVolume.getProperty(SmisConstants.CP_BLOCK_SIZE);
            // calculate size = consumableBlocks * block size
            Long size = Long.valueOf(consumableBlocks.getValue().toString()) * Long.valueOf(blockSize.getValue().toString());
            // set meta member count and meta members size for meta volume (required for volume expansion)
            if (null != preExistingVolume) {
                StringSet metaMembersCount = new StringSet();
                metaMembersCount.add(membersCount.toString());
                preExistingVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.META_MEMBER_COUNT.toString(), metaMembersCount);
                StringSet metaMemberSize = new StringSet();
                metaMemberSize.add(size.toString());
                preExistingVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.META_MEMBER_SIZE.toString(), metaMemberSize);
                // persist unmanaged volume in db
                dbClient.persistObject(preExistingVolume);
            } else {
                storageVolume.setMetaMemberCount(membersCount);
                storageVolume.setMetaMemberSize(size);
                storageVolume.setTotalMetaMemberCapacity(membersCount * size);
                // persist volume in db
                dbClient.persistObject(storageVolume);
            }
            _logger.info(String.format("Meta member info: meta member count --- %s, blocks --- %s, block size --- %s, size --- %s .", membersCount, consumableBlocks.getValue().toString(), blockSize.getValue().toString(), size));
        }
    } catch (Exception e) {
        _logger.error("Processing meta volume  information failed :", e);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) CIMObjectPath(javax.cim.CIMObjectPath) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) CIMProperty(javax.cim.CIMProperty) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) StringSet(com.emc.storageos.db.client.model.StringSet) WBEMClient(javax.wbem.client.WBEMClient) CIMArgument(javax.cim.CIMArgument)

Example 34 with BaseCollectionException

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

the class MetaVolumeTypeProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        DbClient dbClient = (DbClient) keyMap.get(Constants.dbClient);
        WBEMClient client = SMICommunicationInterface.getCIMClient(keyMap);
        CIMObjectPath metaVolumePath = getObjectPathfromCIMArgument(_args);
        if (metaVolumePath == null) {
            _logger.info(String.format("MetaVolumePath is null."));
        } else {
            _logger.info(String.format("Processing EMC_Meta for meta volume: %s", metaVolumePath));
            UnManagedVolume preExistingVolume = null;
            String isMetaVolume = "true";
            String nativeGuid;
            // Check if storage volume exists in db (the method is called from re-discovery context).
            nativeGuid = getVolumeNativeGuid(metaVolumePath);
            Volume storageVolume = checkStorageVolumeExistsInDB(nativeGuid, dbClient);
            if (null == storageVolume || storageVolume.getInactive()) {
                // Check if unmanaged volume exists in db (the method is called from unmanaged volumes discovery context).
                nativeGuid = getUnManagedVolumeNativeGuidFromVolumePath(metaVolumePath);
                _logger.debug("Meta volume nativeguid :" + nativeGuid);
                preExistingVolume = checkUnManagedVolumeExistsInDB(nativeGuid, dbClient);
                if (null == preExistingVolume) {
                    _logger.debug("Volume Info Object not found :" + nativeGuid);
                    return;
                }
                isMetaVolume = preExistingVolume.getVolumeCharacterstics().get(UnManagedVolume.SupportedVolumeCharacterstics.IS_METAVOLUME.toString());
            } else {
                _logger.debug("Volume managed by Bourne :" + storageVolume.getNativeGuid());
                isMetaVolume = storageVolume.getIsComposite().toString();
            }
            if (isMetaVolume.equalsIgnoreCase("false")) {
                _logger.error(String.format("MetaVolumeTypeProcessor called for regular volume: %s", nativeGuid));
                return;
            }
            final Iterator<?> it = (Iterator<?>) resultObj;
            if (it.hasNext()) {
                final CIMObjectPath symmMetaPath = (CIMObjectPath) it.next();
                _logger.debug(String.format("Processing EMC_Meta: %s", symmMetaPath));
                CIMInstance cimMeta = client.getInstance(symmMetaPath, false, false, STRIPE_EXTENTS_NUMBER);
                CIMProperty stripeLengthProperty = cimMeta.getProperty(SmisConstants.CP_EXTENT_STRIPE_LENGTH);
                Long stripeLength = Long.valueOf(stripeLengthProperty.getValue().toString());
                String metaVolumeType;
                if (stripeLength < 1) {
                    _logger.error(String.format("Stripe length for EMC_Meta is less than 1: %s", stripeLength));
                    return;
                } else if (stripeLength == 1) {
                    // this is concatenated meta volume
                    _logger.debug(String.format("Stripe length for EMC_Meta is : %s. Type is concatenated.", stripeLength));
                    metaVolumeType = Volume.CompositionType.CONCATENATED.toString();
                } else {
                    // this is striped meta volume
                    _logger.debug(String.format("Stripe length for EMC_Meta is : %s. Type is striped.", stripeLength));
                    metaVolumeType = Volume.CompositionType.STRIPED.toString();
                }
                _logger.info(String.format("Meta volume: %s, type: %s", metaVolumePath, metaVolumeType));
                if (null == preExistingVolume) {
                    // storage volume update
                    storageVolume.setCompositionType(metaVolumeType);
                    // persist volume in db
                    dbClient.persistObject(storageVolume);
                } else {
                    // unmanaged volume update
                    StringSet metaVolumeTypeSet = new StringSet();
                    metaVolumeTypeSet.add(metaVolumeType);
                    preExistingVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.META_VOLUME_TYPE.toString(), metaVolumeTypeSet);
                    // for this volume.
                    if (Volume.CompositionType.STRIPED.toString().equalsIgnoreCase(metaVolumeType)) {
                        URI storageSystemUri = preExistingVolume.getStorageSystemUri();
                        StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, storageSystemUri);
                        if (DiscoveredDataObject.Type.vmax.toString().equalsIgnoreCase(storageSystem.getSystemType())) {
                            _logger.info("Check matched vpool list for vmax striped meta volume and remove fastExpansion vpools.");
                            StringSet matchedVirtualPools = preExistingVolume.getSupportedVpoolUris();
                            if (matchedVirtualPools != null && !matchedVirtualPools.isEmpty()) {
                                _logger.debug("Matched Pools :" + Joiner.on("\t").join(matchedVirtualPools));
                                StringSet newMatchedPools = new StringSet();
                                boolean needToReplace = false;
                                for (String vPoolUriStr : matchedVirtualPools) {
                                    URI vPoolUri = new URI(vPoolUriStr);
                                    VirtualPool virtualPool = dbClient.queryObject(VirtualPool.class, vPoolUri);
                                    // null check since supported vPool list in UnManagedVolume may contain inactive vPool
                                    if (virtualPool != null && !virtualPool.getFastExpansion()) {
                                        newMatchedPools.add(vPoolUriStr);
                                    } else {
                                        needToReplace = true;
                                    }
                                }
                                if (needToReplace) {
                                    matchedVirtualPools.replace(newMatchedPools);
                                    _logger.info("Replaced VPools : {}", Joiner.on("\t").join(preExistingVolume.getSupportedVpoolUris()));
                                }
                            }
                        }
                    }
                    // persist volume in db
                    dbClient.updateAndReindexObject(preExistingVolume);
                }
            }
        }
    } catch (Exception e) {
        _logger.error("Processing meta volume type information failed :", e);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) CIMObjectPath(javax.cim.CIMObjectPath) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) CIMProperty(javax.cim.CIMProperty) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Iterator(java.util.Iterator) StringSet(com.emc.storageos.db.client.model.StringSet) WBEMClient(javax.wbem.client.WBEMClient) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 35 with BaseCollectionException

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

the class PoolCapabilitiesProcessor 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;
        _dbClient = (DbClient) keyMap.get(Constants.dbClient);
        AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
        StorageSystem device = getStorageSystem(_dbClient, profile.getSystemId());
        // Process the response only for vmax3 systems.
        if (device.checkIfVmax3()) {
            while (it.hasNext()) {
                CIMInstance capabilitiesInstance = null;
                try {
                    capabilitiesInstance = it.next();
                    String instanceID = capabilitiesInstance.getPropertyValue(Constants.INSTANCEID).toString();
                    addPath(keyMap, operation.getResult(), capabilitiesInstance.getObjectPath());
                } catch (Exception e) {
                    _logger.warn("Pool Capabilities detailed discovery failed for {}-->{}", capabilitiesInstance.getObjectPath(), getMessage(e));
                }
            }
        }
    } catch (Exception e) {
        _logger.error("Pool Capabilities detailed discovery failed", e);
    }
}
Also used : Iterator(java.util.Iterator) AccessProfile(com.emc.storageos.plugins.AccessProfile) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

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