Search in sources :

Example 46 with CIMObjectPath

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

the class TierPolicyProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        _dbClient = (DbClient) keyMap.get(Constants.dbClient);
        CIMObjectPath storageGroupPath = getObjectPathfromCIMArgument(_args);
        @SuppressWarnings("unchecked") Map<String, CIMObjectPath> volumeToStorageGroupMapping = (Map<String, CIMObjectPath>) keyMap.get(Constants.VOLUME_STORAGE_GROUP_MAPPING);
        CIMObjectPath volumePath = volumeToStorageGroupMapping.get(storageGroupPath.getKey(Constants.INSTANCEID).getValue().toString());
        String nativeGuid = getUnManagedVolumeNativeGuidFromVolumePath(volumePath);
        UnManagedVolume preExistingVolume = checkUnManagedVolumeExistsInDB(nativeGuid, _dbClient);
        if (null == preExistingVolume) {
            return;
        }
        // get VolumeInfo Object and inject Fast Policy Name.
        @SuppressWarnings("unchecked") final Iterator<CIMObjectPath> it = (Iterator<CIMObjectPath>) resultObj;
        while (it.hasNext()) {
            CIMObjectPath policyPath = it.next();
            injectIntoVolumeInformationContainer(preExistingVolume, Constants.POLICYRULENAME, policyPath);
            preExistingVolume.putVolumeCharacterstics(SupportedVolumeCharacterstics.IS_AUTO_TIERING_ENABLED.toString(), "true");
        }
        _dbClient.persistObject(preExistingVolume);
    } catch (Exception e) {
        _logger.error("Processing Tier Policy in Pre Existing Volume  failed", e);
    }
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) CIMObjectPath(javax.cim.CIMObjectPath) Iterator(java.util.Iterator) Map(java.util.Map) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 47 with CIMObjectPath

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

the class VNXFastVolumesProcessor method processVolumes.

private void processVolumes(Iterator<CIMObjectPath> it, CIMObjectPath tierPolicyPath, Map<String, Object> keyMap, Operation operation) {
    AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
    StorageSystem system = _dbClient.queryObject(StorageSystem.class, profile.getSystemId());
    while (it.hasNext()) {
        CIMObjectPath volumePath = null;
        try {
            volumePath = it.next();
            if (tierPolicyPath.toString().contains(AutoTieringPolicy.VnxFastPolicy.DEFAULT_AUTOTIER.toString())) {
                _logger.debug("Adding Auto Tier Policy Rule ");
                addPath(keyMap, operation.getResult(), volumePath);
                continue;
            }
            String volumeNativeGuid = getVolumeNativeGuid(volumePath);
            Volume volume = checkStorageVolumeExistsInDB(volumeNativeGuid, _dbClient);
            if (null != volume) {
                _logger.debug("Skipping discovery, as this Volume {} is already being managed by ViPR.", volumeNativeGuid);
                continue;
            }
            String unManagedVolumeNativeGuid = getUnManagedVolumeNativeGuidFromVolumePath(volumePath);
            UnManagedVolume unManagedVolume = checkUnManagedVolumeExistsInDB(unManagedVolumeNativeGuid, _dbClient);
            if (null != unManagedVolume) {
                String policyName = getCIMPropertyValue(tierPolicyPath, Constants.POLICYRULENAME);
                _logger.info("Adding {} Policy Rule to UnManaged Volume {}", policyName, unManagedVolumeNativeGuid);
                injectIntoVolumeInformationContainer(unManagedVolume, Constants.POLICYRULENAME, tierPolicyPath);
                unManagedVolume.putVolumeCharacterstics(SupportedVolumeCharacterstics.IS_AUTO_TIERING_ENABLED.toString(), "true");
                // StorageVolumeInfoProcessor updated supported_vpool_list based on its pool's presence in vPool
                // Now, filter those vPools based on policy associated
                DiscoveryUtils.filterSupportedVpoolsBasedOnTieringPolicy(unManagedVolume, policyName, system, _dbClient);
                _unManagedVolumesUpdate.add(unManagedVolume);
            }
            if (_unManagedVolumesUpdate.size() > BATCH_SIZE) {
                _partitionManager.updateInBatches(_unManagedVolumesUpdate, getPartitionSize(keyMap), _dbClient, "VOLUME");
                _unManagedVolumesUpdate.clear();
            }
        } catch (Exception ex) {
            _logger.error("Processing UnManaged Storage Volume {} ", volumePath, ex);
        }
    }
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) CIMObjectPath(javax.cim.CIMObjectPath) AccessProfile(com.emc.storageos.plugins.AccessProfile) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 48 with CIMObjectPath

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

the class VNXFastVolumesProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    CloseableIterator<CIMObjectPath> volumeInstances = null;
    try {
        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);
        CIMObjectPath tierPolicypath = getObjectPathfromCIMArgument(_args);
        processVolumes(volumeInstances, tierPolicypath, keyMap, operation);
        while (!volumeInstanceChunks.isEnd()) {
            _logger.info("Processing Next Volume Chunk of size {}", BATCH_SIZE);
            volumeInstanceChunks = client.getInstancePaths(tierPolicypath, volumeInstanceChunks.getContext(), new UnsignedInteger32(BATCH_SIZE));
            processVolumes(volumeInstanceChunks.getResponses(), tierPolicypath, keyMap, operation);
        }
        if (!_unManagedVolumesUpdate.isEmpty()) {
            _partitionManager.updateInBatches(_unManagedVolumesUpdate, getPartitionSize(keyMap), _dbClient, "VOLUME");
            _unManagedVolumesUpdate.clear();
        }
    } catch (Exception e) {
        _logger.error("Discovering Tier Policies for vnx volumes failed", e);
    } finally {
        volumeInstances.close();
    }
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) CIMObjectPath(javax.cim.CIMObjectPath) UnsignedInteger32(javax.cim.UnsignedInteger32) WBEMClient(javax.wbem.client.WBEMClient) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) EnumerateResponse(javax.wbem.client.EnumerateResponse)

Example 49 with CIMObjectPath

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

the class VolumeAccessStateProcessor method processVolumes.

private void processVolumes(Iterator<CIMInstance> it, Map<String, Object> keyMap, Operation operation) {
    while (it.hasNext()) {
        try {
            CIMInstance volumeInstance = it.next();
            CIMObjectPath volumePath = volumeInstance.getObjectPath();
            // TODO add logic to get Access
            String access = null;
            Object value = volumeInstance.getPropertyValue(SupportedVolumeInformation.ACCESS.toString());
            if (value != null) {
                access = value.toString();
            }
            StringSet statusDesc = new StringSet();
            String[] descriptions = null;
            value = volumeInstance.getPropertyValue(SupportedVolumeInformation.STATUS_DESCRIPTIONS.toString());
            if (value != null) {
                descriptions = (String[]) value;
                for (String desc : descriptions) {
                    statusDesc.add(desc);
                }
            }
            String volumeNativeGuid = getVolumeNativeGuid(volumePath);
            Volume volume = checkStorageVolumeExistsInDB(volumeNativeGuid, _dbClient);
            if (null != volume) {
                _logger.debug("Skipping discovery, as this Volume is already being managed by ViPR :" + volumeNativeGuid);
                continue;
            }
            String unManagedVolumeNativeGuid = getUnManagedVolumeNativeGuidFromVolumePath(volumePath);
            UnManagedVolume unManagedVolume = checkUnManagedVolumeExistsInDB(unManagedVolumeNativeGuid, _dbClient);
            if (null != unManagedVolume) {
                _logger.debug("Adding Access {}", unManagedVolumeNativeGuid);
                StringSet accessSet = new StringSet();
                if (access != null) {
                    accessSet.add(access);
                }
                if (null == unManagedVolume.getVolumeInformation().get(SupportedVolumeInformation.ACCESS.toString())) {
                    unManagedVolume.getVolumeInformation().put(SupportedVolumeInformation.ACCESS.toString(), accessSet);
                } else {
                    unManagedVolume.getVolumeInformation().get(SupportedVolumeInformation.ACCESS.toString()).replace(accessSet);
                }
                if (null == unManagedVolume.getVolumeInformation().get(SupportedVolumeInformation.STATUS_DESCRIPTIONS.toString())) {
                    unManagedVolume.getVolumeInformation().put(SupportedVolumeInformation.STATUS_DESCRIPTIONS.toString(), statusDesc);
                } else {
                    unManagedVolume.getVolumeInformation().get(SupportedVolumeInformation.STATUS_DESCRIPTIONS.toString()).replace(statusDesc);
                }
                _unManagedVolumesUpdate.add(unManagedVolume);
            }
            if (_unManagedVolumesUpdate.size() > BATCH_SIZE) {
                _partitionManager.updateInBatches(_unManagedVolumesUpdate, getPartitionSize(keyMap), _dbClient, "UnManagedVolume");
                _unManagedVolumesUpdate.clear();
            }
        } catch (Exception ex) {
            _logger.error("Processing UnManaged Storage Volume", ex);
        }
    }
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) CIMObjectPath(javax.cim.CIMObjectPath) StringSet(com.emc.storageos.db.client.model.StringSet) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 50 with CIMObjectPath

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

the class ArrayAffinityProcessor method getPreferredPoolMap.

/**
 * Get preferred pool to export type map for a host
 *
 * @param hostId Id of Host instance
 * @param profile AccessProfile
 * @param cimClient WBEMClient
 * @param dbClient DbClient
 * @return preferred pool to export type map
 */
private Map<String, String> getPreferredPoolMap(URI hostId, AccessProfile profile, WBEMClient cimClient, DbClient dbClient) {
    Map<String, String> preferredPoolMap = new HashMap<String, String>();
    List<Initiator> allInitiators = CustomQueryUtility.queryActiveResourcesByConstraint(dbClient, Initiator.class, ContainmentConstraint.Factory.getContainedObjectsConstraint(hostId, Initiator.class, Constants.HOST));
    Set<CIMObjectPath> hardwareIdPaths = new HashSet<CIMObjectPath>();
    for (Initiator initiator : allInitiators) {
        _logger.info("Processing initiator {}", initiator.getLabel());
        String normalizedPortName = Initiator.normalizePort(initiator.getInitiatorPort());
        String query = String.format("SELECT %s.%s FROM %s where %s.%s ='%s'", SmisConstants.CIM_STORAGE_HARDWARE_ID, SmisConstants.CP_INSTANCE_ID, SmisConstants.CIM_STORAGE_HARDWARE_ID, SmisConstants.CIM_STORAGE_HARDWARE_ID, SmisConstants.CP_ELEMENT_NAME, normalizedPortName);
        CIMObjectPath hardwareIdPath = CimObjectPathCreator.createInstance(SmisConstants.CIM_STORAGE_HARDWARE_ID, Constants.EMC_NAMESPACE, null);
        List<CIMInstance> hardwareIds = DiscoveryUtils.executeQuery(cimClient, hardwareIdPath, query, CQL);
        if (!hardwareIds.isEmpty()) {
            hardwareIdPaths.add(hardwareIds.get(0).getObjectPath());
        }
    }
    Set<CIMObjectPath> maskPaths = new HashSet<CIMObjectPath>();
    for (CIMObjectPath hardwareIdPath : hardwareIdPaths) {
        maskPaths.addAll(DiscoveryUtils.getAssociatorNames(cimClient, hardwareIdPath, null, SmisConstants.CIM_PROTOCOL_CONTROLLER, null, null));
    }
    Set<CIMObjectPath> volumePathsInMasks = new HashSet<CIMObjectPath>();
    Map<CIMObjectPath, String> volumeToPool = new HashMap<CIMObjectPath, String>();
    for (CIMObjectPath path : maskPaths) {
        _logger.info("Processing masking view {}", path.toString());
        List<CIMObjectPath> hardwareIdsInMask = DiscoveryUtils.getAssociatorNames(cimClient, path, null, SmisConstants.CIM_STORAGE_HARDWARE_ID, null, null);
        // check if the mask is shared or exclusive
        String maskType = hardwareIdPaths.containsAll(hardwareIdsInMask) ? ExportGroup.ExportGroupType.Host.name() : ExportGroup.ExportGroupType.Cluster.name();
        List<CIMObjectPath> volumePaths = DiscoveryUtils.getAssociatorNames(cimClient, path, null, SmisConstants.CIM_STORAGE_VOLUME, null, null);
        for (CIMObjectPath volumePath : volumePaths) {
            if (ArrayAffinityDiscoveryUtils.isUnmanagedVolume(volumePath, dbClient)) {
                URI poolURI = ArrayAffinityDiscoveryUtils.getStoragePool(volumePath, cimClient, dbClient);
                if (!NullColumnValueGetter.isNullURI(poolURI)) {
                    if (ExportGroup.ExportGroupType.Host.name().equals(maskType)) {
                        volumePathsInMasks.add(volumePath);
                        volumeToPool.put(volumePath, poolURI.toString());
                    }
                    ArrayAffinityDiscoveryUtils.addPoolToPreferredPoolMap(preferredPoolMap, poolURI.toString(), maskType);
                }
            }
        }
    }
    for (CIMObjectPath volumePath : volumePathsInMasks) {
        // get masks from the volume path
        List<CIMObjectPath> masks = DiscoveryUtils.getAssociatorNames(cimClient, volumePath, null, SmisConstants.CIM_PROTOCOL_CONTROLLER, null, null);
        if (!maskPaths.containsAll(masks)) {
            // shared volumes
            _logger.info("Volume {} is shared by multiple hosts", volumePath);
            ArrayAffinityDiscoveryUtils.addPoolToPreferredPoolMap(preferredPoolMap, volumeToPool.get(volumePath), ExportGroup.ExportGroupType.Cluster.name());
        }
    }
    return preferredPoolMap;
}
Also used : HashMap(java.util.HashMap) CIMObjectPath(javax.cim.CIMObjectPath) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) Initiator(com.emc.storageos.db.client.model.Initiator) HashSet(java.util.HashSet)

Aggregations

CIMObjectPath (javax.cim.CIMObjectPath)582 CIMInstance (javax.cim.CIMInstance)254 WBEMException (javax.wbem.WBEMException)236 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)208 CIMArgument (javax.cim.CIMArgument)190 ArrayList (java.util.ArrayList)139 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)118 Volume (com.emc.storageos.db.client.model.Volume)108 URI (java.net.URI)108 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)82 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)76 WBEMClient (javax.wbem.client.WBEMClient)75 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)72 HashSet (java.util.HashSet)68 HashMap (java.util.HashMap)63 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)57 CIMProperty (javax.cim.CIMProperty)57 IOException (java.io.IOException)55 BlockObject (com.emc.storageos.db.client.model.BlockObject)52 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)52