Search in sources :

Example 41 with CIMInstance

use of javax.cim.CIMInstance 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)

Example 42 with CIMInstance

use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.

the class StorageGroupProcessor method findVolumesSLOFromSGInstance.

/**
 * Find the volumes associated with the SG and extract the SLOName and set
 * it in keyMap.
 *
 * @param client
 *            - WBEMClient
 * @param path
 *            - SG CoP.
 * @param volumesWithSLO
 *            - Volumes with SLO Names.
 */
private void findVolumesSLOFromSGInstance(WBEMClient client, CIMObjectPath path, Map<String, String> volumesWithSLO) {
    try {
        CIMInstance instance = client.getInstance(path, false, true, SmisConstants.PS_HOST_IO);
        String fastSetting = SmisUtils.getSLOPolicyName(instance);
        CloseableIterator<CIMObjectPath> volPaths = client.associatorNames(path, null, Constants.STORAGE_VOLUME, null, null);
        while (volPaths.hasNext()) {
            CIMObjectPath volPath = volPaths.next();
            String volumeNativeGuid = getVolumeNativeGuid(volPath);
            // Allow overwriting a previous entry if fast setting is non-null.
            if (!volumesWithSLO.containsKey(volumeNativeGuid) || fastSetting != null) {
                logger.debug("Volume key: {} fastSetting: {}", volumeNativeGuid, fastSetting);
                volumesWithSLO.put(volumeNativeGuid, fastSetting);
            }
        }
    } catch (Exception e) {
        logger.warn("Finding unexported volume SLOName failed during unmanaged volume discovery", e);
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 43 with CIMInstance

use of javax.cim.CIMInstance 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 44 with CIMInstance

use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.

the class StorageVolumeBoundPoolProcessor method processVolumes.

private void processVolumes(CloseableIterator<CIMInstance> allocatedFromStoragePoolInstances, Set<String> volumesList) {
    while (allocatedFromStoragePoolInstances.hasNext()) {
        CIMInstance allocatedFromStoragePoolInstance = allocatedFromStoragePoolInstances.next();
        String boundToThinStoragePool = allocatedFromStoragePoolInstance.getPropertyValue(SmisConstants.EMC_BOUND_TO_THIN_STORAGE_POOL).toString();
        if (Boolean.valueOf(boundToThinStoragePool)) {
            String volume = allocatedFromStoragePoolInstance.getPropertyValue(SmisConstants.CP_DEPENDENT).toString();
            CIMObjectPath volumePath = new CIMObjectPath(volume);
            String deviceId = volumePath.getKey(DEVICE_ID).getValue().toString();
            volumesList.add(deviceId);
        }
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) CIMInstance(javax.cim.CIMInstance)

Example 45 with CIMInstance

use of javax.cim.CIMInstance 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

CIMInstance (javax.cim.CIMInstance)370 CIMObjectPath (javax.cim.CIMObjectPath)254 WBEMException (javax.wbem.WBEMException)139 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)104 ArrayList (java.util.ArrayList)98 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)79 URI (java.net.URI)79 CIMArgument (javax.cim.CIMArgument)71 WBEMClient (javax.wbem.client.WBEMClient)69 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)62 Volume (com.emc.storageos.db.client.model.Volume)62 HashSet (java.util.HashSet)60 IOException (java.io.IOException)53 HashMap (java.util.HashMap)52 Iterator (java.util.Iterator)50 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)48 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)48 CIMProperty (javax.cim.CIMProperty)37 StringSet (com.emc.storageos.db.client.model.StringSet)31 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)29