Search in sources :

Example 36 with BaseCollectionException

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

the class SGsWithFastVolumesProcessor method processResult.

/**
 * This processor gets invoked only for VMAX unManaged volume discoveries.
 * Volumes belonging to SG are processed , and using the mapping information Storage Groups-->Fast Policy,
 * we identify the volume's policy.
 */
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    CloseableIterator<CIMObjectPath> volumeInstances = null;
    try {
        @SuppressWarnings("unchecked") Map<String, String> policyToStorageGroupMapping = (Map<String, String>) keyMap.get(Constants.POLICY_STORAGE_GROUP_MAPPING);
        CIMObjectPath storageGroupPath = getObjectPathfromCIMArgument(_args);
        String groupId = storageGroupPath.getKey(Constants.INSTANCEID).getValue().toString();
        String policyName = policyToStorageGroupMapping.get(groupId);
        _logger.info("Group {}  policy Name {}", groupId, policyName);
        if (null == policyName) {
            return;
        }
        WBEMClient client = SMICommunicationInterface.getCIMClient(keyMap);
        _unManagedVolumesUpdate = new ArrayList<UnManagedVolume>();
        @SuppressWarnings("unchecked") EnumerateResponse<CIMObjectPath> volumeInstanceChunks = (EnumerateResponse<CIMObjectPath>) resultObj;
        volumeInstances = volumeInstanceChunks.getResponses();
        _dbClient = (DbClient) keyMap.get(Constants.dbClient);
        processVolumes(volumeInstances, policyName, keyMap, operation);
        while (!volumeInstanceChunks.isEnd()) {
            _logger.debug("Processing Next Volume Chunk of size {}", BATCH_SIZE);
            volumeInstanceChunks = client.getInstancePaths(storageGroupPath, volumeInstanceChunks.getContext(), new UnsignedInteger32(BATCH_SIZE));
            processVolumes(volumeInstanceChunks.getResponses(), policyName, keyMap, operation);
        }
        if (!_unManagedVolumesUpdate.isEmpty()) {
            _partitionManager.updateInBatches(_unManagedVolumesUpdate, getPartitionSize(keyMap), _dbClient, "VOLUME");
            _unManagedVolumesUpdate.clear();
        }
    } catch (Exception e) {
        _logger.error("Discovering Tier Policies for vmax volumes failed", e);
    } finally {
        if (volumeInstances != null) {
            volumeInstances.close();
        }
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) UnsignedInteger32(javax.cim.UnsignedInteger32) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) WBEMClient(javax.wbem.client.WBEMClient) Map(java.util.Map) EnumerateResponse(javax.wbem.client.EnumerateResponse)

Example 37 with BaseCollectionException

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

the class StorageGroupProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    @SuppressWarnings("unchecked") final Iterator<CIMObjectPath> it = (Iterator<CIMObjectPath>) resultObj;
    WBEMClient client = SMICommunicationInterface.getCIMClient(keyMap);
    Map<String, String> volumesWithSLO = null;
    dbClient = (DbClient) keyMap.get(Constants.dbClient);
    AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
    URI systemId = profile.getSystemId();
    List<CIMObjectPath> processedSGs = new ArrayList<>();
    if (!keyMap.containsKey(Constants.VOLUMES_WITH_SLOS)) {
        volumesWithSLO = new HashMap<>();
        keyMap.put(Constants.VOLUMES_WITH_SLOS, volumesWithSLO);
    } else {
        volumesWithSLO = (Map<String, String>) keyMap.get(Constants.VOLUMES_WITH_SLOS);
    }
    try {
        StorageSystem device = dbClient.queryObject(StorageSystem.class, systemId);
        // Process these only for VMAX3 Systems.
        if (device.checkIfVmax3()) {
            if (keyMap.containsKey(Constants.STORAGE_GROUPS_PROCESSED)) {
                processedSGs = (List<CIMObjectPath>) keyMap.get(Constants.STORAGE_GROUPS_PROCESSED);
            }
            while (it.hasNext()) {
                CIMObjectPath path = it.next();
                if (null != processedSGs && processedSGs.contains(path)) {
                    logger.info("Skipping the already processed SG. {}", path);
                    continue;
                }
                findVolumesSLOFromSGInstance(client, path, volumesWithSLO);
            }
        }
    } catch (Exception e) {
        logger.error("Extracting storageGroup details failed.", e);
    } finally {
        // clean all the processedSGs here.
        processedSGs.clear();
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) ArrayList(java.util.ArrayList) AccessProfile(com.emc.storageos.plugins.AccessProfile) URI(java.net.URI) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) Iterator(java.util.Iterator) CloseableIterator(javax.wbem.CloseableIterator) WBEMClient(javax.wbem.client.WBEMClient) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 38 with BaseCollectionException

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

the class StoragePoolProcessor 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;
        _dbClient = (DbClient) keyMap.get(Constants.dbClient);
        while (it.hasNext()) {
            CIMObjectPath poolPath = it.next();
            String poolNativeGuid = NativeGUIDGenerator.generateNativeGuidForPool(poolPath);
            StoragePool pool = checkStoragePoolExistsInDB(poolNativeGuid, _dbClient);
            if (pool != null && validPool(poolPath)) {
                addPath(keyMap, operation.getResult(), poolPath);
                // add VMAX2 Thin pools to get BoundVolumes later
                if (poolPath.toString().contains(StoragePool.PoolClassNames.Symm_VirtualProvisioningPool.toString())) {
                    addPath(keyMap, Constants.VMAX2_THIN_POOLS, poolPath);
                }
                String poolClass = poolPath.getObjectName();
                if (poolClass.startsWith(SYMM_CLASS_PREFIX) && !poolClass.equals(StoragePool.PoolClassNames.Symm_SRPStoragePool.name())) {
                    addPath(keyMap, Constants.VMAX2POOLS, poolPath);
                }
            }
        }
    } catch (Exception e) {
        _logger.error("Processing Storage Pool failed", e);
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) CIMObjectPath(javax.cim.CIMObjectPath) Iterator(java.util.Iterator) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 39 with BaseCollectionException

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

the class StorageSynchronizedProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    final Iterator<?> it = (Iterator<?>) resultObj;
    @SuppressWarnings("unchecked") Map<String, RemoteMirrorObject> volumeToRAGroupMap = (Map<String, RemoteMirrorObject>) keyMap.get(Constants.UN_VOLUME_RAGROUP_MAP);
    _dbClient = (DbClient) keyMap.get(Constants.dbClient);
    while (it.hasNext()) {
        try {
            final CIMInstance instance = (CIMInstance) it.next();
            CIMObjectPath volumePath = instance.getObjectPath();
            CIMObjectPath sourcePath = (CIMObjectPath) volumePath.getKey(Constants._SystemElement).getValue();
            CIMObjectPath destPath = (CIMObjectPath) volumePath.getKey(Constants._SyncedElement).getValue();
            String mode = instance.getPropertyValue(SmisConstants.CP_MODE).toString();
            String copyMode = null;
            if (mode != null) {
                copyMode = SupportedCopyModes.getCopyMode(mode);
            }
            String sourceNativeGuid = createKeyfromPath(sourcePath);
            sourceNativeGuid = sourceNativeGuid.replace("VOLUME", "UNMANAGEDVOLUME");
            _log.debug("Source Native Guid {}", sourceNativeGuid);
            String targetNativeGuid = createKeyfromPath(destPath);
            targetNativeGuid = targetNativeGuid.replace("VOLUME", "UNMANAGEDVOLUME");
            _log.debug("Target Native Guid {}", targetNativeGuid);
            // if child
            if (volumeToRAGroupMap.containsKey(targetNativeGuid)) {
                // set Parent
                // copyMode and raGroup Uri are already part of RemoteMirrorObject
                _log.debug("Found Target Native Guid {}", targetNativeGuid);
                RemoteMirrorObject rmObj = volumeToRAGroupMap.get(targetNativeGuid);
                _log.debug("Found Target Remote Object {}", rmObj);
                rmObj.setSourceVolumeNativeGuid(sourceNativeGuid);
                rmObj.setType(RemoteMirrorObject.Types.TARGET.toString());
                if (copyMode != null && !SupportedCopyModes.UNKNOWN.name().equals(copyMode) && !copyMode.equalsIgnoreCase(rmObj.getCopyMode()) && updateSupportedCopyMode(rmObj.getCopyMode())) {
                    rmObj.setCopyMode(copyMode);
                    updateCopyModeInRAGroupObjectIfRequired(copyMode, rmObj);
                }
            }
            if (volumeToRAGroupMap.containsKey(sourceNativeGuid)) {
                _log.debug("Found Source Native Guid {}", sourceNativeGuid);
                RemoteMirrorObject rmObj = volumeToRAGroupMap.get(sourceNativeGuid);
                _log.debug("Found Source Remote Object {}", rmObj);
                if (null == rmObj.getTargetVolumenativeGuids()) {
                    rmObj.setTargetVolumenativeGuids(new StringSet());
                }
                if (!findVolumesArefromSameArray(sourceNativeGuid, targetNativeGuid)) {
                    rmObj.getTargetVolumenativeGuids().add(targetNativeGuid);
                    // Set this only for the volumes have remote replication
                    rmObj.setType(RemoteMirrorObject.Types.SOURCE.toString());
                    _log.debug("Updated Target Volumes", rmObj);
                }
            }
        } catch (Exception e) {
            _log.error("Finding out Parent of a target Volume failed", e);
        }
    }
}
Also used : Iterator(java.util.Iterator) CIMObjectPath(javax.cim.CIMObjectPath) StringSet(com.emc.storageos.db.client.model.StringSet) Map(java.util.Map) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 40 with BaseCollectionException

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

the class StorageVolumeBoundPoolProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    CloseableIterator<CIMInstance> allocatedFromStoragePoolInstances = null;
    EnumerateResponse<CIMInstance> allocatedFromStoragePoolInstanceChunks = null;
    @SuppressWarnings("unchecked") Map<String, Set<String>> vmax2ThinPoolToBoundVolumesMap = (Map<String, Set<String>>) keyMap.get(Constants.VMAX2_THIN_POOL_TO_BOUND_VOLUMES);
    _dbClient = (DbClient) keyMap.get(Constants.dbClient);
    WBEMClient client = SMICommunicationInterface.getCIMClient(keyMap);
    CIMObjectPath storagePoolPath = null;
    try {
        storagePoolPath = getObjectPathfromCIMArgument(_args);
        _logger.debug("VMAX2 Thin Pool: {}", storagePoolPath.toString());
        String poolNativeGuid = NativeGUIDGenerator.generateNativeGuidForPool(storagePoolPath);
        StoragePool pool = checkStoragePoolExistsInDB(poolNativeGuid, _dbClient);
        if (pool == null) {
            _logger.error("Skipping unmanaged volume discovery as the storage pool with path {} doesn't exist in ViPR", storagePoolPath.toString());
            return;
        }
        Set<String> boundVolumes = new HashSet<String>();
        allocatedFromStoragePoolInstanceChunks = (EnumerateResponse<CIMInstance>) resultObj;
        allocatedFromStoragePoolInstances = allocatedFromStoragePoolInstanceChunks.getResponses();
        processVolumes(allocatedFromStoragePoolInstances, boundVolumes);
        while (!allocatedFromStoragePoolInstanceChunks.isEnd()) {
            _logger.info("Processing Next Volume Chunk of size {}", BATCH_SIZE);
            allocatedFromStoragePoolInstanceChunks = client.getInstancesWithPath(storagePoolPath, allocatedFromStoragePoolInstanceChunks.getContext(), new UnsignedInteger32(BATCH_SIZE));
            processVolumes(allocatedFromStoragePoolInstanceChunks.getResponses(), boundVolumes);
        }
        vmax2ThinPoolToBoundVolumesMap.put(storagePoolPath.toString(), boundVolumes);
        _logger.debug("Bound volumes list {}", Joiner.on("\t").join(boundVolumes));
    } catch (Exception e) {
        _logger.error("Processing Bound Storage Volume Information failed :", e);
    } finally {
        if (null != allocatedFromStoragePoolInstances) {
            allocatedFromStoragePoolInstances.close();
        }
        if (null != allocatedFromStoragePoolInstanceChunks) {
            try {
                client.closeEnumeration(storagePoolPath, allocatedFromStoragePoolInstanceChunks.getContext());
            } catch (Exception e) {
                _logger.debug("Exception occurred while closing enumeration", e);
            }
        }
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) StoragePool(com.emc.storageos.db.client.model.StoragePool) CIMObjectPath(javax.cim.CIMObjectPath) UnsignedInteger32(javax.cim.UnsignedInteger32) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) WBEMClient(javax.wbem.client.WBEMClient) Map(java.util.Map) HashSet(java.util.HashSet)

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