Search in sources :

Example 6 with SMIPluginException

use of com.emc.storageos.plugins.metering.smis.SMIPluginException in project coprhd-controller by CoprHD.

the class ProfileProcessor method processResult.

/**
 * {@inheritDoc}
 */
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    @SuppressWarnings("unchecked") final Iterator<CIMInstance> it = (Iterator<CIMInstance>) resultObj;
    CIMInstance profileInstance = isRegisteredProfileValid(it);
    if (null != profileInstance) {
        _logger.info("RegisteredProfile : {}", profileInstance.getObjectPath());
        addPath(keyMap, operation.getResult(), profileInstance.getObjectPath());
    } else {
        throw new SMIPluginException("Provider Version not supported,hence skipping scanning", SMIPluginException.ERRORCODE_PROVIDER_NOT_SUPPORTED);
    }
}
Also used : Iterator(java.util.Iterator) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) CIMInstance(javax.cim.CIMInstance)

Example 7 with SMIPluginException

use of com.emc.storageos.plugins.metering.smis.SMIPluginException in project coprhd-controller by CoprHD.

the class FEPortStatsProcessor method processResult.

@SuppressWarnings("unchecked")
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws SMIPluginException {
    try {
        CIMArgument<?>[] outputArguments = (CIMArgument<?>[]) resultObj;
        DbClient dbClient = (DbClient) keyMap.get(Constants.dbClient);
        AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
        List<Stat> metricsObjList = (List<Stat>) keyMap.get(Constants._Stats);
        List<String> metricSequence = (List<String>) keyMap.get(Constants.STORAGEOS_FEPORT_MANIFEST);
        String[] feportsMetricValues = ((String[]) outputArguments[0].getValue())[0].split("\n");
        List<StoragePort> systemPorts = ControllerUtils.getSystemPortsOfSystem(dbClient, profile.getSystemId());
        _logger.debug("FEPort metricNames Sequence {}", metricSequence);
        // process the results.
        if (null != metricSequence && !metricSequence.isEmpty()) {
            // Step2: For each feport metric record
            for (String fePortMetricValue : feportsMetricValues) {
                if (fePortMetricValue.isEmpty()) {
                    _logger.debug("Empty FEPort stats returned as part of Statistics Response");
                    continue;
                }
                String[] metrics = fePortMetricValue.split(Constants.SEMI_COLON);
                // Step 3: For each port in db for a given system.
                for (StoragePort port : systemPorts) {
                    // Step 4: if port in db is null just continue.
                    if (null == port) {
                        continue;
                    } else if (!port.getInactive() && metrics[0].endsWith(port.getPortName())) {
                        // Step 5: Check whether provider returned port
                        // exists in db or not. if port exists in db,
                        // then create a PortStat object for it.
                        _logger.debug("found FEPort in db for {}", port.getPortName());
                        createPortStatMetric(metricSequence, port, keyMap, metricsObjList, metrics);
                    }
                }
            }
            // 
            // compute port metric to trigger if any port allocation qualification changed. If there is
            // changes, run vpool matcher
            // 
            portMetricsProcessor.triggerVpoolMatcherIfPortAllocationQualificationChanged(profile.getSystemId(), systemPorts);
            // 
            // compute storage system's average of port metrics. Then, persist it into storage system object.
            // 
            portMetricsProcessor.computeStorageSystemAvgPortMetrics(profile.getSystemId());
            // Compute port group's port metrics for vmax only
            portMetricsProcessor.computePortGroupMetrics(profile.getSystemId());
        } else {
            _logger.error("failed processing FEPOrt Metric values as metric sequence is null.");
        }
    } catch (Exception e) {
        _logger.error("Failed while extracting stats for FEPorts: ", e);
    }
    resultObj = null;
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) StoragePort(com.emc.storageos.db.client.model.StoragePort) AccessProfile(com.emc.storageos.plugins.AccessProfile) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) Stat(com.emc.storageos.db.client.model.Stat) List(java.util.List) CIMArgument(javax.cim.CIMArgument)

Example 8 with SMIPluginException

use of com.emc.storageos.plugins.metering.smis.SMIPluginException in project coprhd-controller by CoprHD.

the class XIVCommunicationInterface method scan.

/**
 * {@inheritDoc}
 */
@Override
public void scan(AccessProfile accessProfile) throws BaseCollectionException {
    // Call scan method of SMICommunication interface to validate SMIS connectivity
    super.scan(accessProfile);
    URI providerURI = null;
    StorageProvider providerObj = null;
    String detailedStatusMessage = "Unknown Status";
    try {
        providerURI = accessProfile.getSystemId();
        providerObj = _dbClient.queryObject(StorageProvider.class, providerURI);
        // Validate Secondary URL for its availability
        validateManagementURL(providerObj.getSecondaryURL(), providerObj.getSecondaryUsername(), providerObj.getSecondaryPassword());
        // scan succeeds
        detailedStatusMessage = String.format("Scan job completed successfully for REST API: %s", providerObj.getSecondaryURL());
    } catch (Exception e) {
        detailedStatusMessage = String.format("Scan job failed for REST API: %s because %s", providerObj.getSecondaryURL(), e.getMessage());
        throw new SMIPluginException(detailedStatusMessage);
    } finally {
        if (providerObj != null) {
            try {
                // set detailed message
                providerObj.setLastScanStatusMessage(detailedStatusMessage);
                _dbClient.updateObject(providerObj);
            } catch (DatabaseException ex) {
                _logger.error("Error while persisting object to DB", ex);
            }
        }
    }
}
Also used : SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) XIVRestException(com.emc.storageos.xiv.api.XIVRestException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException)

Example 9 with SMIPluginException

use of com.emc.storageos.plugins.metering.smis.SMIPluginException in project coprhd-controller by CoprHD.

the class SMICommunicationInterface method discoverArrayAffinity.

/**
 * {@inheritDoc}
 */
@Override
public void discoverArrayAffinity(AccessProfile accessProfile) {
    _logger.info("Calling discoverArrayAffinity");
    URI storageSystemURI = accessProfile.getSystemId();
    String detailedStatusMessage = "Array Affinity Discovery completed successfully for Storage System: %s";
    long startTime = System.currentTimeMillis();
    try {
        _logger.info("Access Profile Details :" + accessProfile.toString());
        _keyMap = new ConcurrentHashMap<String, Object>();
        _wbemClient = getCIMClient(accessProfile);
        _logger.info("CIMClient initialized successfully");
        _keyMap.put(Constants._cimClient, _wbemClient);
        _keyMap.put(Constants.dbClient, _dbClient);
        _keyMap.put(Constants.COORDINATOR_CLIENT, _coordinator);
        _keyMap.put(Constants.PROPS, accessProfile.getProps());
        _keyMap.put(Constants._InteropNamespace, accessProfile.getInteropNamespace());
        _keyMap.put(Constants.ACCESSPROFILE, accessProfile);
        _keyMap.put(Constants.SYSTEMID, accessProfile.getSystemId());
        _keyMap.put(Constants._serialID, accessProfile.getserialID());
        _keyMap.put(Constants.MASKING_VIEWS, new LinkedList<CIMObjectPath>());
        StorageSystem storageSystem = queryStorageSystem(accessProfile);
        String providerVersion = getProviderVersionString(storageSystem);
        if (null != providerVersion) {
            _keyMap.put(Constants.VERSION, providerVersion);
            _keyMap.put(Constants.IS_NEW_SMIS_PROVIDER, isSMIS8XProvider(providerVersion));
        }
        executor.setKeyMap(_keyMap);
        executor.execute((Namespace) namespaces.getNsList().get(DISCOVER));
    } catch (Exception e) {
        detailedStatusMessage = "Array Affinity Discovery failed for Storage System: %s because " + e.getMessage();
        _logger.error(String.format(detailedStatusMessage, storageSystemURI.toString()), e);
        throw new SMIPluginException(String.format(detailedStatusMessage, storageSystemURI.toString()));
    } finally {
        try {
            String systemIdsStr = accessProfile.getProps().get(Constants.SYSTEM_IDS);
            String[] systemIds = systemIdsStr.split(Constants.ID_DELIMITER);
            List<StorageSystem> systemsToUpdate = new ArrayList<StorageSystem>();
            for (String systemId : systemIds) {
                StorageSystem system = _dbClient.queryObject(StorageSystem.class, URI.create(systemId));
                // set detailed message
                system.setLastArrayAffinityStatusMessage(String.format(detailedStatusMessage, systemId));
                systemsToUpdate.add(system);
            }
            _dbClient.updateObject(systemsToUpdate);
        } catch (DatabaseException ex) {
            _logger.error("Error while persisting object to DB", ex);
        }
        releaseResources();
        long totalTime = System.currentTimeMillis() - startTime;
        _logger.info(String.format("Array Affinity discovery of Storage System %s took %f seconds", storageSystemURI.toString(), (double) totalTime / (double) 1000));
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) ArrayList(java.util.ArrayList) URI(java.net.URI) WBEMException(javax.wbem.WBEMException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) IOException(java.io.IOException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) LocalReplicaObject(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.processor.detailedDiscovery.LocalReplicaObject) RemoteMirrorObject(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.processor.detailedDiscovery.RemoteMirrorObject) StorageSystemViewObject(com.emc.storageos.plugins.StorageSystemViewObject) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 10 with SMIPluginException

use of com.emc.storageos.plugins.metering.smis.SMIPluginException in project coprhd-controller by CoprHD.

the class SMICommunicationInterface method discover.

/**
 * {@inheritDoc}
 */
@Override
public void discover(AccessProfile accessProfile) throws BaseCollectionException {
    URI storageSystemURI = null;
    StorageSystem storageSystem = null;
    String detailedStatusMessage = "Unknown Status";
    long startTime = System.currentTimeMillis();
    try {
        _logger.info("Access Profile Details :" + accessProfile.toString());
        storageSystemURI = accessProfile.getSystemId();
        storageSystem = queryStorageSystem(accessProfile);
        _keyMap = new ConcurrentHashMap<String, Object>();
        _wbemClient = getCIMClient(accessProfile);
        _logger.info("CIMClient initialized successfully");
        _keyMap.put(Constants._cimClient, _wbemClient);
        _keyMap.put(Constants.dbClient, _dbClient);
        _keyMap.put(Constants.COORDINATOR_CLIENT, _coordinator);
        if (_networkDeviceController != null) {
            _keyMap.put(Constants.networkDeviceController, _networkDeviceController);
        }
        _keyMap.put(Constants.PROPS, accessProfile.getProps());
        _keyMap.put(Constants._InteropNamespace, accessProfile.getInteropNamespace());
        _keyMap.put(Constants.ACCESSPROFILE, accessProfile);
        _keyMap.put(Constants.SYSTEMID, accessProfile.getSystemId());
        _keyMap.put(Constants._serialID, accessProfile.getserialID());
        _keyMap.put(Constants.STORAGEPOOLS, new LinkedList<CIMObjectPath>());
        _keyMap.put(Constants.PROTOCOLS, new HashSet<String>());
        _keyMap.put(Constants.STORAGEETHERNETPORTS, new LinkedList<CIMObjectPath>());
        _keyMap.put(Constants.IPENDPOINTS, new LinkedList<CIMObjectPath>());
        _keyMap.put(Constants.STORAGEVOLUMES, new LinkedList<CIMObjectPath>());
        String providerVersion = getProviderVersionString(storageSystem);
        if (null != providerVersion) {
            _keyMap.put(Constants.VERSION, providerVersion);
            _keyMap.put(Constants.IS_NEW_SMIS_PROVIDER, isSMIS8XProvider(providerVersion));
        }
        Map<URI, StoragePool> poolsToMatchWithVpool = new HashMap<URI, StoragePool>();
        _keyMap.put(Constants.MODIFIED_STORAGEPOOLS, poolsToMatchWithVpool);
        // need this nested structure to be able to minimize the changes on existing code.
        List<List<StoragePort>> portsToRunNetworkConnectivity = new ArrayList<List<StoragePort>>();
        _keyMap.put(Constants.STORAGE_PORTS, portsToRunNetworkConnectivity);
        List<StoragePort> discoveredPorts = new ArrayList<StoragePort>();
        _keyMap.put(Constants.DISCOVERED_PORTS, discoveredPorts);
        _keyMap.put(Constants.SLO_NAMES, new HashSet<String>());
        if (Type.ibmxiv.name().equals(accessProfile.getSystemType())) {
            initIBMDiscoveryKeyMap(accessProfile);
        } else {
            initEMCDiscoveryKeyMap(accessProfile);
            if (Type.vmax.name().equals(accessProfile.getSystemType())) {
                // discover port group
                _keyMap.put(Constants.PORTGROUP, CimObjectPathCreator.createInstance(Constants.SE_TARGETMASKINGGROUP, accessProfile.getInteropNamespace()));
            }
        }
        executor.setKeyMap(_keyMap);
        executor.execute((Namespace) namespaces.getNsList().get(DISCOVER));
    } catch (Exception e) {
        detailedStatusMessage = String.format("Discovery failed for Storage System: %s because %s", storageSystemURI.toString(), e.getMessage());
        _logger.error(detailedStatusMessage, e);
        throw new SMIPluginException(detailedStatusMessage);
    } finally {
        if (storageSystem != null) {
            try {
                // set detailed message
                storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
                _dbClient.persistObject(storageSystem);
            } catch (DatabaseException ex) {
                _logger.error("Error while persisting object to DB", ex);
            }
        }
        releaseResources();
        long totalTime = System.currentTimeMillis() - startTime;
        _logger.info(String.format("Discovery of Storage System %s took %f seconds", storageSystemURI.toString(), (double) totalTime / (double) 1000));
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) CIMObjectPath(javax.cim.CIMObjectPath) ArrayList(java.util.ArrayList) StoragePort(com.emc.storageos.db.client.model.StoragePort) URI(java.net.URI) WBEMException(javax.wbem.WBEMException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) IOException(java.io.IOException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) LocalReplicaObject(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.processor.detailedDiscovery.LocalReplicaObject) RemoteMirrorObject(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.processor.detailedDiscovery.RemoteMirrorObject) StorageSystemViewObject(com.emc.storageos.plugins.StorageSystemViewObject) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) NamespaceList(com.emc.storageos.plugins.common.domainmodel.NamespaceList) List(java.util.List) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

SMIPluginException (com.emc.storageos.plugins.metering.smis.SMIPluginException)22 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)12 List (java.util.List)7 CIMObjectPath (javax.cim.CIMObjectPath)7 WBEMException (javax.wbem.WBEMException)7 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)6 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)6 AccessProfile (com.emc.storageos.plugins.AccessProfile)6 IOException (java.io.IOException)5 URI (java.net.URI)5 CIMInstance (javax.cim.CIMInstance)5 DbClient (com.emc.storageos.db.client.DbClient)4 Stat (com.emc.storageos.db.client.model.Stat)4 StorageProvider (com.emc.storageos.db.client.model.StorageProvider)3 StorageSystemViewObject (com.emc.storageos.plugins.StorageSystemViewObject)3 LocalReplicaObject (com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.processor.detailedDiscovery.LocalReplicaObject)3 RemoteMirrorObject (com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.processor.detailedDiscovery.RemoteMirrorObject)3 CIMConnectionFactory (com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory)3 Iterator (java.util.Iterator)3 CIMArgument (javax.cim.CIMArgument)3