Search in sources :

Example 31 with StorageProvider

use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.

the class HDSCommunicationInterface method scan.

@Override
public void scan(AccessProfile accessProfile) throws BaseCollectionException {
    _logger.info("Scanning started for provider: {}", accessProfile.getSystemId());
    StorageProvider provider = _dbClient.queryObject(StorageProvider.class, accessProfile.getSystemId());
    boolean exceptionOccured = false;
    try {
        HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(accessProfile), accessProfile.getUserName(), accessProfile.getPassword());
        String apiVersion = hdsApiClient.getProviderAPIVersion();
        _logger.info("Provider {} API Version:{}", provider.getLabel(), apiVersion);
        provider.setVersionString(apiVersion);
        String minimumSupportedVersion = ControllerUtils.getPropertyValueFromCoordinator(_coordinator, CONTROLLER_HICOMMAND_PROVIDER_VERSION);
        if (VersionChecker.verifyVersionDetails(minimumSupportedVersion, apiVersion) < 0) {
            provider.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.INCOMPATIBLE.name());
            throw new HDSCollectionException(String.format(" ** The HiCommand Device Manager API version is not supported. Minimum supported version should be: %s", minimumSupportedVersion));
        }
        provider.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
        List<StorageArray> storageArrayList = hdsApiClient.getStorageSystemsInfo();
        if (null != storageArrayList && !storageArrayList.isEmpty()) {
            _logger.debug("Received proper response from HiCommand server");
            processScanResponse(storageArrayList, accessProfile);
        } else {
            _logger.info("No Systems found during scanning of provider: {}", provider.getId());
        }
    } catch (Exception ex) {
        exceptionOccured = true;
        _logger.error("Exception occurred while scanning provider {}", accessProfile.getSystemId(), ex);
        throw HDSException.exceptions.scanFailed(ex);
    } finally {
        if (exceptionOccured) {
            provider.setConnectionStatus(ConnectionStatus.NOTCONNECTED.name());
        } else {
            provider.setConnectionStatus(ConnectionStatus.CONNECTED.name());
        }
        _dbClient.persistObject(provider);
    }
    _logger.info("Scanning ended for provider: {}", accessProfile.getSystemId());
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) HDSCollectionException(com.emc.storageos.volumecontroller.impl.hds.HDSCollectionException) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) HDSCollectionException(com.emc.storageos.volumecontroller.impl.hds.HDSCollectionException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) HDSException(com.emc.storageos.hds.HDSException) WBEMException(javax.wbem.WBEMException) IOException(java.io.IOException) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) StorageArray(com.emc.storageos.hds.model.StorageArray)

Example 32 with StorageProvider

use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.

the class ScaleIOHandleFactory method getClientHandle.

public ScaleIORestClient getClientHandle(StorageSystem storageSystem) throws Exception {
    ScaleIORestClient handle = null;
    synchronized (syncObject) {
        URI activeProviderURI = storageSystem.getActiveProviderURI();
        if (NullColumnValueGetter.isNullURI(activeProviderURI)) {
            throw ScaleIOException.exceptions.noActiveStorageProvider(storageSystem.getNativeGuid());
        }
        StorageProvider provider = dbClient.queryObject(StorageProvider.class, activeProviderURI);
        if (provider == null) {
            throw ScaleIOException.exceptions.noActiveStorageProvider(storageSystem.getNativeGuid());
        }
        String providerId = provider.getProviderID();
        handle = ScaleIORestClientMap.get(providerId);
        handle = getHandle(handle, provider);
    }
    return handle;
}
Also used : ScaleIORestClient(com.emc.storageos.scaleio.api.restapi.ScaleIORestClient) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) URI(java.net.URI)

Example 33 with StorageProvider

use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.

the class ScaleIOStorageDevice method refreshConnectionStatusForAllSIOProviders.

/**
 * Refresh connection status for all ScaleIO providers.
 *
 * @return A list of providers whose connections were successful.
 */
public List<URI> refreshConnectionStatusForAllSIOProviders() {
    log.info("Refreshing connection statuses for ScaleIO providers");
    List<URI> activeProviders = Lists.newArrayList();
    List<StorageProvider> providers = CustomQueryUtility.getActiveStorageProvidersByInterfaceType(dbClient, StorageProvider.InterfaceType.scaleioapi.name());
    for (StorageProvider provider : providers) {
        try {
            // Flag for success/failure
            boolean success = false;
            // Prepare to try secondary IPs if necessary
            StringSet secondaryIps = provider.getSecondaryIps();
            Iterator<String> iterator = secondaryIps.iterator();
            // Cache the current IP address
            String currentIPAddress = provider.getIPAddress();
            String nextIp = null;
            do {
                try {
                    ScaleIORestClient handle = scaleIOHandleFactory.using(dbClient).getClientHandle(provider);
                    // Ignore the result on success, otherwise catch the exception
                    handle.getSystem();
                    log.info("Successfully connected to ScaleIO MDM {}: {}", provider.getIPAddress(), provider.getId());
                    success = true;
                    break;
                } catch (Exception e) {
                    log.error(String.format("Failed to connect to ScaleIO MDM %s: %s", provider.getIPAddress(), provider.getId()), e);
                    if (iterator.hasNext()) {
                        nextIp = iterator.next();
                        log.info("Attempting connection to potential new Primary MDM {}: {}", nextIp, provider.getId());
                        provider.setIPAddress(nextIp);
                    } else {
                        log.warn("Exhausted list of secondary IPs for ScaleIO provider: {}", provider.getId());
                        nextIp = null;
                    }
                }
            } while (// while we have more IPs to try
            nextIp != null);
            if (success) {
                // Update secondary IP addresses if we switched over
                if (!provider.getIPAddress().equalsIgnoreCase(currentIPAddress)) {
                    StringSet newSecondaryIps = new StringSet();
                    // Copy old secondary list
                    newSecondaryIps.addAll(secondaryIps);
                    // Remove the new primary IP
                    newSecondaryIps.remove(provider.getIPAddress());
                    // Add the old primary IP
                    newSecondaryIps.add(currentIPAddress);
                    // TODO Improve how we update the StringSet based on infra team suggestions
                    provider.setSecondaryIps(newSecondaryIps);
                }
                activeProviders.add(provider.getId());
                provider.setConnectionStatus(StorageProvider.ConnectionStatus.CONNECTED.toString());
            } else {
                provider.setIPAddress(currentIPAddress);
                provider.setConnectionStatus(StorageProvider.ConnectionStatus.NOTCONNECTED.toString());
            }
        } finally {
            dbClient.persistObject(provider);
        }
    }
    return activeProviders;
}
Also used : StringSet(com.emc.storageos.db.client.model.StringSet) ScaleIORestClient(com.emc.storageos.scaleio.api.restapi.ScaleIORestClient) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ScaleIOException(com.emc.storageos.scaleio.ScaleIOException)

Example 34 with StorageProvider

use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.

the class CIMConnectionFactory method refreshConnections.

/**
 * Refresh the SMISProvider connections. This will be called after loading
 * the SMIS Provider information from DB.
 *
 * @param smisproviderList
 *            : List of SMISProvider.
 * @return List<URI> : returns the list of active provider URIs.
 */
public List<URI> refreshConnections(final List<StorageProvider> smisProviderList) {
    _log.debug("In refreshConnections()");
    List<URI> activeProviderURIList = new ArrayList<URI>();
    for (StorageProvider smisProvider : smisProviderList) {
        try {
            CimConnection connection = getConnection(smisProvider.getIPAddress(), smisProvider.getPortNumber().toString());
            if (null == connection) {
                _log.error("No CIMOM connection found for ip/port {}", ConnectionManager.generateConnectionCacheKey(smisProvider.getIPAddress(), smisProvider.getPortNumber()));
                // No need to add connection, as getConnection() called from any thread would create it.
                continue;
            }
            validateProviderConnection(smisProvider, connection, activeProviderURIList);
        } catch (final DatabaseException ex) {
            _log.error("DatabaseException occurred while fetching the storageDevice for {} due to ", smisProvider.getId(), ex);
        } catch (final ConnectionManagerException ex) {
            _log.error("No CIMOM Connection found for ipaddress due to ", ex);
        } catch (final Exception ex) {
            _log.error("Exception while refreshing connections due to ", ex);
        }
    }
    return activeProviderURIList;
}
Also used : ArrayList(java.util.ArrayList) CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) ConnectionManagerException(com.emc.storageos.cimadapter.connections.ConnectionManagerException) URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) WBEMException(javax.wbem.WBEMException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) ConnectionManagerException(com.emc.storageos.cimadapter.connections.ConnectionManagerException) IOException(java.io.IOException)

Example 35 with StorageProvider

use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.

the class VPlexPerpetualCSVFileCollector method collect.

@Override
public void collect(AccessProfile accessProfile, Map<String, Object> context) {
    init();
    DbClient dbClient = (DbClient) context.get(Constants.dbClient);
    // Get which VPlex array that this applies to
    URI storageSystemURI = accessProfile.getSystemId();
    StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, storageSystemURI);
    if (storageSystem == null) {
        log.error("Could not find StorageSystem '{}' in DB", storageSystemURI);
        return;
    }
    StringSet providerIds = storageSystem.getProviders();
    for (String providerId : providerIds) {
        StorageProvider provider = dbClient.queryObject(StorageProvider.class, URI.create(providerId));
        LinuxSystemCLI cli = new LinuxSystemCLI(provider.getIPAddress(), provider.getUserName(), provider.getPassword());
        ListVPlexPerpetualCSVFileNames listDataFileNamesCmd = new ListVPlexPerpetualCSVFileNames();
        cli.executeCommand(listDataFileNamesCmd);
        // Process each of the data files that we found on the VPlex management station
        List<String> fileNames = listDataFileNamesCmd.getResults();
        for (String fileName : fileNames) {
            log.info("Processing VPLEX performance statistics file {}", fileName);
            // Extract and hold the data for this data file
            ReadAndParseVPlexPerpetualCSVFile readDataFile = new ReadAndParseVPlexPerpetualCSVFile(fileName);
            cli.executeCommand(readDataFile);
            VPlexPerpetualCSVFileData fileData = readDataFile.getResults();
            // Read the headers and extract those metric names that we're interested in and to which
            // DataObject (StorageHADomain or StoragePort) that it should be associated with. This
            // will be used as a way to look up the object when processing the actual metric data
            Map<String, MetricHeaderInfo> metricNamesToHeaderInfo = processCSVFileDataHeader(dbClient, storageSystem, fileData.getDirectorName(), fileData.getHeaders());
            List<Map<String, String>> dataLines = fileData.getDataLines();
            int lineCount = dataLines.size();
            // There is at least one data point
            if (lineCount > 1) {
                // Determine the last time that metrics were collected.
                Long lastCollectionTimeUTC = getLastCollectionTime(metricNamesToHeaderInfo);
                // Try to find the index into dataLines based on the last collection time.
                // What we're trying to do here is determine the maximum value for the metrics
                // from the last collection time in ViPR, until the last data line in the file.
                int start = fileData.getDataIndexForTime(lastCollectionTimeUTC);
                // Have a mapping of metrics to their maximum value found in the dataLines
                Map<String, Double> maxValues = findMaxMetricValues(dataLines, start, lineCount);
                // Process the metrics for this file
                Map<String, String> last = dataLines.get(lineCount - 1);
                processDirectorStats(metricNamesToHeaderInfo, maxValues, last);
                processPortStats(context, metricNamesToHeaderInfo, maxValues, last);
            }
            // Clean up fileData resources
            fileData.close();
        }
        // Clean out the cache data, so that it's not laying around
        clearCaches();
    }
}
Also used : LinuxSystemCLI(com.iwave.ext.linux.LinuxSystemCLI) DbClient(com.emc.storageos.db.client.DbClient) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) URI(java.net.URI) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) StringSet(com.emc.storageos.db.client.model.StringSet) HashMap(java.util.HashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

StorageProvider (com.emc.storageos.db.client.model.StorageProvider)97 URI (java.net.URI)44 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)26 ArrayList (java.util.ArrayList)24 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)23 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)19 Produces (javax.ws.rs.Produces)19 IOException (java.io.IOException)18 StringSet (com.emc.storageos.db.client.model.StringSet)17 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)15 Path (javax.ws.rs.Path)15 Consumes (javax.ws.rs.Consumes)11 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)10 MapStorageProvider (com.emc.storageos.api.mapper.functions.MapStorageProvider)8 StorageSystemViewObject (com.emc.storageos.plugins.StorageSystemViewObject)8 GET (javax.ws.rs.GET)8 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)7 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)7 AsyncTask (com.emc.storageos.volumecontroller.AsyncTask)7 BlockController (com.emc.storageos.volumecontroller.BlockController)7