Search in sources :

Example 66 with BaseCollectionException

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

the class XIVStoragePortProcessor method processResult.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("unchecked")
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        final Iterator<CIMInstance> it = (Iterator<CIMInstance>) resultObj;
        _profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
        Set<String> protocols = (Set<String>) keyMap.get(Constants.PROTOCOLS);
        _newPortList = new ArrayList<StoragePort>();
        _updatePortList = new ArrayList<StoragePort>();
        _dbClient = (DbClient) keyMap.get(Constants.dbClient);
        Map<URI, StoragePool> poolsToMatchWithVpool = (Map<URI, StoragePool>) keyMap.get(Constants.MODIFIED_STORAGEPOOLS);
        StorageSystem device = _dbClient.queryObject(StorageSystem.class, _profile.getSystemId());
        while (it.hasNext()) {
            CIMInstance portInstance = null;
            StoragePort port = null;
            try {
                portInstance = it.next();
                String protocol = getCIMPropertyValue(portInstance, LINKTECHNOLOGY);
                String className = portInstance.getClassName();
                // FC Port - 4
                if ("4".equals(protocol)) {
                    port = checkStoragePortExistsInDB(portInstance, device, _dbClient);
                    checkProtocolAlreadyExists(protocols, FC);
                    createStoragePort(port, portInstance, _profile, true, FC, device);
                } else if (IPPORT_CLASS_NAME.equals(className)) {
                    port = createStoragePort(null, portInstance, _profile, false, IP, device);
                    checkProtocolAlreadyExists(protocols, ISCSI);
                    keyMap.put(portInstance.getObjectPath().toString(), port);
                    addPath(keyMap, operation.getResult(), portInstance.getObjectPath());
                } else {
                    _logger.debug("Unsupported Port : {}", getCIMPropertyValue(portInstance, DEVICEID));
                }
            } catch (Exception e) {
                _logger.warn("Port Discovery failed for {}", getCIMPropertyValue(portInstance, DEVICEID), e);
            }
        }
        _dbClient.createObject(_newPortList);
        _dbClient.persistObject(_updatePortList);
        // ports used later to run Transport Zone connectivity
        List<List<StoragePort>> portsUsedToRunTZoneConnectivity = (List<List<StoragePort>>) keyMap.get(Constants.STORAGE_PORTS);
        portsUsedToRunTZoneConnectivity.add(_newPortList);
        portsUsedToRunTZoneConnectivity.add(_updatePortList);
        List<StoragePool> modifiedPools = StoragePoolAssociationHelper.getStoragePoolsFromPorts(_dbClient, _newPortList, _updatePortList);
        for (StoragePool pool : modifiedPools) {
            // pool matcher will be invoked on this pool
            if (!poolsToMatchWithVpool.containsKey(pool.getId())) {
                poolsToMatchWithVpool.put(pool.getId(), pool);
            }
        }
        _logger.debug("# Pools used in invoking PoolMatcher during StoragePortProcessor {}", Joiner.on("\t").join(poolsToMatchWithVpool.keySet()));
        // discovered ports used later to check for not visible ports
        List<StoragePort> discoveredPorts = (List<StoragePort>) keyMap.get(Constants.DISCOVERED_PORTS);
        discoveredPorts.addAll(_newPortList);
        discoveredPorts.addAll(_updatePortList);
        // if the port's end point is in a transport zone, associate the the
        // port to the
        // transport zone. Also update the storage pools and varray
        // association if needed.
        StoragePortAssociationHelper.updatePortAssociations(_newPortList, _dbClient);
        StoragePortAssociationHelper.updatePortAssociations(_updatePortList, _dbClient);
    } catch (Exception e) {
        _logger.error("Port Discovery failed -->{}", getMessage(e));
    } finally {
        _newPortList = null;
        _updatePortList = null;
    }
}
Also used : Set(java.util.Set) StoragePool(com.emc.storageos.db.client.model.StoragePool) StoragePort(com.emc.storageos.db.client.model.StoragePort) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 67 with BaseCollectionException

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

the class XIVSupportedAsynchronousActionsProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        _log.info("processResult");
        _dbClient = (DbClient) keyMap.get(Constants.dbClient);
        AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
        @SuppressWarnings("unchecked") Iterator<CIMInstance> iterator = (Iterator<CIMInstance>) resultObj;
        while (iterator.hasNext()) {
            CIMInstance instance = iterator.next();
            UnsignedInteger16[] supportedAsyncActions = (UnsignedInteger16[]) instance.getPropertyValue(Constants.SUPPORTED_ASYNCHRONOUS_ACTIONS);
            StorageSystem device = getStorageSystem(_dbClient, profile.getSystemId());
            StringSet supportedAsyncActionsSet = new StringSet();
            if (supportedAsyncActions != null) {
                for (UnsignedInteger16 actionValue : supportedAsyncActions) {
                    switch(actionValue.intValue()) {
                        case Constants.CREATE_ELEMENT_REPLICA_ASYNC_ACTION:
                            supportedAsyncActionsSet.add(StorageSystem.AsyncActions.CreateElementReplica.name());
                            break;
                        case Constants.CREATE_GROUP_REPLICA_ASYNC_ACTION:
                            supportedAsyncActionsSet.add(StorageSystem.AsyncActions.CreateGroupReplica.name());
                            break;
                        default:
                    }
                }
            }
            device.setSupportedAsynchronousActions(supportedAsyncActionsSet);
            StringSet replicationTypes = new StringSet();
            replicationTypes.add(SupportedReplicationTypes.LOCAL.name());
            device.setSupportedReplicationTypes(replicationTypes);
            _dbClient.persistObject(device);
        }
    } catch (Exception e) {
        _log.error("Supported asynchronous action processing failed: ", e);
    }
}
Also used : Iterator(java.util.Iterator) StringSet(com.emc.storageos.db.client.model.StringSet) AccessProfile(com.emc.storageos.plugins.AccessProfile) CIMInstance(javax.cim.CIMInstance) UnsignedInteger16(javax.cim.UnsignedInteger16) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 68 with BaseCollectionException

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

the class XIVTCPProtocolEndPointProcessor 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);
        while (it.hasNext()) {
            CIMInstance tcpPointInstance = null;
            StoragePort port = null;
            try {
                tcpPointInstance = it.next();
                String portInstanceID = getObjectPathfromCIMArgument(args).toString();
                port = _dbClient.queryObject(StoragePort.class, (URI) keyMap.get(portInstanceID));
                updateTCPEndPointDetails(port, tcpPointInstance);
            } catch (Exception e) {
                _logger.warn("Port TCP End Point Discovery failed for {}-->{}", "", getMessage(e));
            }
        }
    } catch (Exception e) {
        _logger.error("Port TCP End Point Discovery failed -->{}", getMessage(e));
    }
}
Also used : Iterator(java.util.Iterator) StoragePort(com.emc.storageos.db.client.model.StoragePort) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) IOException(java.io.IOException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 69 with BaseCollectionException

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

the class BlockStatisticsCapabilitiesProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        final Iterator<?> it = (Iterator<?>) resultObj;
        // Only 1 entry per each Array always
        while (it.hasNext()) {
            final CIMInstance queryInstance = (CIMInstance) it.next();
            CIMProperty prop = queryInstance.getProperty(Constants.CLOCK_TICK_INTERVAL);
            keyMap.put(Constants.CLOCK_TICK_INTERVAL, prop.getValue().toString());
        }
    } catch (Exception e) {
        _logger.error("Failed while processing QueryStatistics :", e);
    }
    resultObj = null;
}
Also used : CIMProperty(javax.cim.CIMProperty) Iterator(java.util.Iterator) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 70 with BaseCollectionException

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

the class CapacityPoolProcessor method processVolumeCapacity.

/**
 * Process volume capacity, iterates over the given chunk and process
 * each volume capacity.
 *
 * @param volumeInstances {@link CloseableIterator} instance
 * @param keyMap {@link Map} instance
 */
private void processVolumeCapacity(CloseableIterator<CIMInstance> volumeInstances, Map<String, Object> keyMap) {
    while (volumeInstances.hasNext()) {
        try {
            final CIMInstance volumeInstance = (CIMInstance) volumeInstances.next();
            String key = null;
            String spaceConsumed = null;
            if (keyMap.containsKey(Constants.IS_NEW_SMIS_PROVIDER) && Boolean.valueOf(keyMap.get(Constants.IS_NEW_SMIS_PROVIDER).toString())) {
                key = createKeyfor8x(volumeInstance);
                spaceConsumed = volumeInstance.getProperty(_emcspaceConsumed).getValue().toString();
            } else {
                key = createKeyfromProps(volumeInstance);
                spaceConsumed = volumeInstance.getProperty(_spaceConsumed).getValue().toString();
            }
            Object value = getMetrics(keyMap, key);
            if (null == value) {
                keyMap.put(key, Long.parseLong(spaceConsumed));
            } else if (value instanceof Stat) {
                Stat metrics = (Stat) value;
                metrics.setProvisionedCapacity(returnProvisionedCapacity(volumeInstance, keyMap));
                metrics.setAllocatedCapacity(Long.parseLong(spaceConsumed));
            }
        } catch (Exception ex) {
            // This check will make sure to skip unnecessary logs
            if (!(ex instanceof BaseCollectionException)) {
                _logger.error("Provisioned Capacity failure : ", ex);
            }
        }
    }
}
Also used : Stat(com.emc.storageos.db.client.model.Stat) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

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