Search in sources :

Example 31 with CIMInstance

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

the class SoftwareIdentityProcessor method processResult.

/**
 * {@inheritDoc}
 */
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    AccessProfile profile = null;
    try {
        _dbClient = (DbClient) keyMap.get(Constants.dbClient);
        coordinator = (CoordinatorClient) keyMap.get(Constants.COORDINATOR_CLIENT);
        profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
        @SuppressWarnings("unchecked") final Iterator<CIMInstance> it = (Iterator<CIMInstance>) resultObj;
        if (it.hasNext()) {
            CIMInstance softwareInstance = it.next();
            String providerId = profile.getIpAddress() + "-" + profile.getProviderPort();
            List<StorageProvider> providers = CustomQueryUtility.getActiveStorageProvidersByProviderId(_dbClient, providerId);
            if (!providers.isEmpty()) {
                checkProviderVersion(softwareInstance, providers.get(0));
            }
        } else {
            String errMsg = String.format("No information obtained from Provider %s for Provider version", profile.getIpAddress());
            throw new SMIPluginException(errMsg, SMIPluginException.ERRORCODE_OPERATIONFAILED);
        }
    } catch (SMIPluginException e) {
        throw e;
    } catch (Exception e) {
        String errMsg = String.format("An error occurred while verifying Provider version: %s", e.getMessage());
        throw new SMIPluginException(SMIPluginException.ERRORCODE_OPERATIONFAILED, e, errMsg);
    }
}
Also used : Iterator(java.util.Iterator) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) AccessProfile(com.emc.storageos.plugins.AccessProfile) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException)

Example 32 with CIMInstance

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

the class StorageConfigurationCapabilitiesProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    @SuppressWarnings("unchecked") final Iterator<CIMInstance> it = (Iterator<CIMInstance>) resultObj;
    _profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
    _dbClient = (DbClient) keyMap.get(Constants.dbClient);
    try {
        StorageSystem system = _dbClient.queryObject(StorageSystem.class, _profile.getSystemId());
        Boolean usingSMIS80 = (Boolean) keyMap.get(Constants.USING_SMIS80_DELIMITERS);
        boolean isSMIS80 = (usingSMIS80 != null && usingSMIS80);
        while (it.hasNext()) {
            CIMInstance storageConfigurationInstance = it.next();
            if (Type.vnxblock.toString().equalsIgnoreCase(system.getSystemType())) {
                updateStorageSystemCapabilityOnVolumeForVNX(storageConfigurationInstance, system);
            } else {
                updateStorageSystemCapabilityOnVolume(storageConfigurationInstance, system);
            }
            system.setUsingSmis80(isSMIS80);
        }
        _dbClient.persistObject(system);
    } catch (Exception e) {
        _logger.error("Finding out Storage System Capability on Volume Creation failed :", e);
    }
}
Also used : Iterator(java.util.Iterator) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 33 with CIMInstance

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

the class StorageVolumeProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    EnumerateResponse<CIMInstance> volumeInstanceChunks = (EnumerateResponse<CIMInstance>) resultObj;
    _dbClient = (DbClient) keyMap.get(Constants.dbClient);
    _keyMap = keyMap;
    _updateVolumes = new ArrayList<Volume>();
    _updateSnapShots = new ArrayList<BlockSnapshot>();
    _updateMirrors = new ArrayList<BlockMirror>();
    CloseableIterator<CIMInstance> volumeInstances = null;
    try {
        // create empty place holder list for meta volume paths (cannot define this in xml)
        _metaVolumePaths = (List<CIMObjectPath>) keyMap.get(Constants.META_VOLUMES);
        if (_metaVolumePaths == null) {
            keyMap.put(Constants.META_VOLUMES, new ArrayList<CIMObjectPath>());
        }
        _volumeToSpaceConsumedMap = (Map<String, String>) keyMap.get(Constants.VOLUME_SPACE_CONSUMED_MAP);
        CIMObjectPath storagePoolPath = getObjectPathfromCIMArgument(_args);
        _isVMAX3 = storagePoolPath.getObjectName().equals(StoragePool.PoolClassNames.Symm_SRPStoragePool.name());
        processResultbyChunk(resultObj, keyMap);
        _partitionManager.updateInBatches(_updateVolumes, getPartitionSize(keyMap), _dbClient, VOLUME);
        _partitionManager.updateInBatches(_updateSnapShots, getPartitionSize(keyMap), _dbClient, BLOCK_SNAPSHOT);
        _partitionManager.updateInBatches(_updateMirrors, getPartitionSize(keyMap), _dbClient, BLOCK_MIRROR);
    } catch (Exception e) {
        _logger.error("Processing Volumes and Snapshots failed", e);
    } finally {
        _updateVolumes = null;
        _updateSnapShots = null;
        _updateMirrors = null;
        if (null != volumeInstances) {
            volumeInstances.close();
        }
    }
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) CIMObjectPath(javax.cim.CIMObjectPath) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) Volume(com.emc.storageos.db.client.model.Volume) EnumerateResponse(javax.wbem.client.EnumerateResponse)

Example 34 with CIMInstance

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

the class StorageVolumeViewProcessor method processVolumes.

private void processVolumes(CloseableIterator<CIMInstance> volumeInstances, Map<String, Object> keyMap) throws IOException {
    List<CIMObjectPath> metaVolumes = new ArrayList<>();
    while (volumeInstances.hasNext()) {
        CIMInstance volumeViewInstance = volumeInstances.next();
        String nativeGuid = getVolumeViewNativeGuid(volumeViewInstance.getObjectPath(), keyMap);
        if (isSnapShot(volumeViewInstance)) {
            BlockSnapshot snapShot = checkSnapShotExistsInDB(nativeGuid, _dbClient);
            if (null == snapShot || snapShot.getInactive()) {
                _logger.debug("Skipping Snapshot, as its not being managed in Bourne");
                continue;
            }
            updateBlockSnapShot(volumeViewInstance, snapShot, keyMap);
            if (_updateSnapShots.size() > BATCH_SIZE) {
                _partitionManager.updateInBatches(_updateSnapShots, getPartitionSize(keyMap), _dbClient, BLOCK_SNAPSHOT);
                _updateSnapShots.clear();
            }
        } else if (isMirror(volumeViewInstance)) {
            BlockMirror mirror = checkBlockMirrorExistsInDB(nativeGuid, _dbClient);
            if (null == mirror || mirror.getInactive()) {
                _logger.debug("Skipping Mirror, as its not being managed in Bourne");
                continue;
            }
            updateBlockMirror(volumeViewInstance, mirror, keyMap);
            if (_updateMirrors.size() > BATCH_SIZE) {
                _partitionManager.updateInBatches(_updateMirrors, getPartitionSize(keyMap), _dbClient, BLOCK_MIRROR);
                _updateMirrors.clear();
            }
        } else {
            Volume storageVolume = checkStorageVolumeExistsInDB(nativeGuid, _dbClient);
            if (null == storageVolume || storageVolume.getInactive()) {
                continue;
            }
            _logger.debug("Volume managed by Bourne :" + storageVolume.getNativeGuid());
            updateStorageVolume(volumeViewInstance, storageVolume, keyMap);
            // This is applicable for meta volumes discovered as unmanaged volumes and ingested prior to vipr controller 2.2 .
            if (storageVolume.getIsComposite() && (storageVolume.getCompositionType() == null || storageVolume.getCompositionType().isEmpty())) {
                // meta volume is missing meta related data. Need to discover this data and set in the volume.
                metaVolumes.add(volumeViewInstance.getObjectPath());
                _logger.info("Found meta volume in vipr with missing data: {}, name: {}", volumeViewInstance.getObjectPath(), storageVolume.getLabel());
            }
        }
        if (_updateVolumes.size() > BATCH_SIZE) {
            _partitionManager.updateInBatches(_updateVolumes, getPartitionSize(keyMap), _dbClient, VOLUME);
            _updateVolumes.clear();
        }
    }
    // Add meta volumes to the keyMap
    try {
        if (metaVolumes != null && !metaVolumes.isEmpty()) {
            _metaVolumeViewPaths.addAll(metaVolumes);
            _logger.info("Added  {} meta volumes.", metaVolumes.size());
        }
    } catch (Exception ex) {
        _logger.error("Processing meta volumes.", ex);
    }
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Volume(com.emc.storageos.db.client.model.Volume) CIMObjectPath(javax.cim.CIMObjectPath) ArrayList(java.util.ArrayList) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) CIMInstance(javax.cim.CIMInstance) IOException(java.io.IOException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 35 with CIMInstance

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

the class StorageVolumeViewProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    EnumerateResponse<CIMInstance> volumeInstanceChunks = (EnumerateResponse<CIMInstance>) resultObj;
    WBEMClient client = SMICommunicationInterface.getCIMClient(keyMap);
    _dbClient = (DbClient) keyMap.get(Constants.dbClient);
    _updateVolumes = new ArrayList<Volume>();
    _updateSnapShots = new ArrayList<BlockSnapshot>();
    _updateMirrors = new ArrayList<BlockMirror>();
    CloseableIterator<CIMInstance> volumeInstances = null;
    try {
        _metaVolumeViewPaths = (List<CIMObjectPath>) keyMap.get(Constants.META_VOLUMES_VIEWS);
        if (_metaVolumeViewPaths == null) {
            _metaVolumeViewPaths = new ArrayList<CIMObjectPath>();
            keyMap.put(Constants.META_VOLUMES_VIEWS, _metaVolumeViewPaths);
        }
        // create empty place holder list for meta volume paths (cannot define this in xml)
        List<CIMObjectPath> metaVolumePaths = (List<CIMObjectPath>) keyMap.get(Constants.META_VOLUMES);
        if (metaVolumePaths == null) {
            keyMap.put(Constants.META_VOLUMES, new ArrayList<CIMObjectPath>());
        }
        CIMObjectPath storagePoolPath = getObjectPathfromCIMArgument(_args);
        volumeInstances = volumeInstanceChunks.getResponses();
        processVolumes(volumeInstances, keyMap);
        while (!volumeInstanceChunks.isEnd()) {
            _logger.info("Processing Next Volume Chunk of size {}", BATCH_SIZE);
            volumeInstanceChunks = client.getInstancesWithPath(storagePoolPath, volumeInstanceChunks.getContext(), new UnsignedInteger32(BATCH_SIZE));
            processVolumes(volumeInstanceChunks.getResponses(), keyMap);
        }
        // if list empty, this method returns back immediately.
        // partition size might not be used in this context, as batch size < partition size.
        // TODO metering might need some extra work to push volumes in batches, hence not changing this method
        // signature
        _partitionManager.updateInBatches(_updateVolumes, getPartitionSize(keyMap), _dbClient, VOLUME);
        _partitionManager.updateInBatches(_updateSnapShots, getPartitionSize(keyMap), _dbClient, BLOCK_SNAPSHOT);
        _partitionManager.updateInBatches(_updateMirrors, getPartitionSize(keyMap), _dbClient, BLOCK_MIRROR);
    } catch (Exception e) {
        _logger.error("Processing Volumes and Snapshots failed", e);
    } finally {
        _updateVolumes = null;
        _updateSnapShots = null;
        _updateMirrors = null;
        if (null != volumeInstances) {
            volumeInstances.close();
        }
    }
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) CIMObjectPath(javax.cim.CIMObjectPath) UnsignedInteger32(javax.cim.UnsignedInteger32) CIMInstance(javax.cim.CIMInstance) IOException(java.io.IOException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) Volume(com.emc.storageos.db.client.model.Volume) ArrayList(java.util.ArrayList) List(java.util.List) WBEMClient(javax.wbem.client.WBEMClient) EnumerateResponse(javax.wbem.client.EnumerateResponse)

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