Search in sources :

Example 6 with BaseCollectionException

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

the class XtremIOCommunicationInterface method discoverArrayAffinity.

@Override
public void discoverArrayAffinity(AccessProfile accessProfile) throws BaseCollectionException {
    _logger.info("XtremIO Array Affinity discovery started for : {}", accessProfile.toString());
    boolean errorOccurred = false;
    StringBuilder errorStrBldr = new StringBuilder();
    try {
        XtremIOClient xtremIOClient = (XtremIOClient) xtremioRestClientFactory.getXtremIOV1Client(URI.create(XtremIOConstants.getXIOBaseURI(accessProfile.getIpAddress(), accessProfile.getPortNumber())), accessProfile.getUserName(), accessProfile.getPassword(), true);
        List<XtremIOSystem> xioSystems = xtremIOClient.getXtremIOSystemInfo();
        _logger.info("Found {} clusters for XMS {}", xioSystems.size(), accessProfile.getIpAddress());
        for (XtremIOSystem xioSystem : xioSystems) {
            try {
                String sysNativeGuid = NativeGUIDGenerator.generateNativeGuid(DiscoveredDataObject.Type.xtremio.name(), xioSystem.getSerialNumber());
                // check if system registered in ViPR
                List<StorageSystem> systems = CustomQueryUtility.getActiveStorageSystemByNativeGuid(_dbClient, sysNativeGuid);
                if (systems.isEmpty()) {
                    _logger.info("No Storage System found in database for {}, hence skipping..", sysNativeGuid);
                    continue;
                }
                StorageSystem system = systems.get(0);
                // Host based array affinity discovery
                if (accessProfile.getProps() != null && accessProfile.getProps().get(Constants.HOST_IDS) != null) {
                    String hostIdsStr = accessProfile.getProps().get(Constants.HOST_IDS);
                    _logger.info("Array Affinity Discovery started for Hosts {}, for XtremIO system {}", hostIdsStr, system.getNativeGuid());
                    String[] hostIds = hostIdsStr.split(Constants.ID_DELIMITER);
                    for (String hostId : hostIds) {
                        _logger.info("Processing Host {}", hostId);
                        Host host = _dbClient.queryObject(Host.class, URI.create(hostId));
                        if (host != null && !host.getInactive()) {
                            arrayAffinityDiscoverer.findAndUpdatePreferredPoolsForHost(system, host, _dbClient);
                        }
                    }
                } else {
                    // Storage system based array affinity discovery
                    _logger.info("Array Affinity Discovery started for XtremIO system {}", system.getNativeGuid());
                    arrayAffinityDiscoverer.findAndUpdatePreferredPools(system, _dbClient, _partitionManager);
                }
            } catch (Exception ex) {
                String errMsg = String.format("Error discovering Array Affinity for XtremIO system %s. Reason: %s", xioSystem.getSerialNumber(), ex.getMessage());
                _logger.error(errMsg, ex);
                errorOccurred = true;
                errorStrBldr.append(errMsg);
            }
        }
    } catch (Exception e) {
        _logger.error("Error discovering Array Affinity for XtremIO Provider {}", accessProfile.getIpAddress(), e);
        throw XtremIOApiException.exceptions.discoveryFailed(accessProfile.getIpAddress());
    } finally {
        if (errorOccurred) {
            _logger.error("Array Affinity discovery for XtremIO Provider {} failed. {}", accessProfile.getIpAddress(), errorStrBldr.toString());
            throw XtremIOApiException.exceptions.discoveryFailed(accessProfile.getIpAddress());
        }
    }
    _logger.info("XtremIO Array Affinity discovery ended");
}
Also used : XtremIOSystem(com.emc.storageos.xtremio.restapi.model.response.XtremIOSystem) XtremIOClient(com.emc.storageos.xtremio.restapi.XtremIOClient) Host(com.emc.storageos.db.client.model.Host) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 7 with BaseCollectionException

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

the class XtremIOCommunicationInterface method scan.

@Override
public void scan(AccessProfile accessProfile) throws BaseCollectionException {
    _logger.info("Scanning started for provider: {}", accessProfile.getSystemId());
    StorageProvider.ConnectionStatus cxnStatus = StorageProvider.ConnectionStatus.CONNECTED;
    StorageProvider provider = _dbClient.queryObject(StorageProvider.class, accessProfile.getSystemId());
    XtremIOClient xtremIOClient = null;
    try {
        xtremIOClient = (XtremIOClient) xtremioRestClientFactory.getXtremIOV1Client(URI.create(XtremIOConstants.getXIOBaseURI(accessProfile.getIpAddress(), accessProfile.getPortNumber())), accessProfile.getUserName(), accessProfile.getPassword(), true);
        String xmsVersion = xtremIOClient.getXtremIOXMSVersion();
        String minimumSupportedVersion = VersionChecker.getMinimumSupportedVersion(StorageSystem.Type.xtremio).replace("-", ".");
        String compatibility = (VersionChecker.verifyVersionDetails(minimumSupportedVersion, xmsVersion) < 0) ? StorageSystem.CompatibilityStatus.INCOMPATIBLE.name() : StorageSystem.CompatibilityStatus.COMPATIBLE.name();
        provider.setCompatibilityStatus(compatibility);
        provider.setVersionString(xmsVersion);
        String systemType = StorageSystem.Type.xtremio.name();
        List<XtremIOSystem> xioSystems = xtremIOClient.getXtremIOSystemInfo();
        _logger.info("Found {} clusters during scan of XMS {}", xioSystems.size(), accessProfile.getIpAddress());
        Map<String, StorageSystemViewObject> storageSystemsCache = accessProfile.getCache();
        for (XtremIOSystem system : xioSystems) {
            String arrayNativeGUID = NativeGUIDGenerator.generateNativeGuid(DiscoveredDataObject.Type.xtremio.name(), system.getSerialNumber());
            StorageSystemViewObject viewObject = storageSystemsCache.get(arrayNativeGUID);
            if (viewObject == null) {
                viewObject = new StorageSystemViewObject();
            }
            viewObject.setDeviceType(systemType);
            viewObject.addprovider(accessProfile.getSystemId().toString());
            viewObject.setProperty(StorageSystemViewObject.SERIAL_NUMBER, system.getSerialNumber());
            viewObject.setProperty(StorageSystemViewObject.VERSION, system.getVersion());
            viewObject.setProperty(StorageSystemViewObject.STORAGE_NAME, arrayNativeGUID);
            storageSystemsCache.put(arrayNativeGUID, viewObject);
        }
    } catch (Exception ex) {
        _logger.error("Error scanning XMS", ex);
        cxnStatus = StorageProvider.ConnectionStatus.NOTCONNECTED;
        // throw exception only if system discovery failed.
        throw XtremIOApiException.exceptions.discoveryFailed(provider.toString());
    } finally {
        provider.setConnectionStatus(cxnStatus.name());
        _dbClient.persistObject(provider);
        if (xtremIOClient != null) {
            xtremIOClient.close();
        }
        _logger.info("Completed scan of XtremIO StorageProvider. IP={}", accessProfile.getIpAddress());
    }
}
Also used : XtremIOSystem(com.emc.storageos.xtremio.restapi.model.response.XtremIOSystem) StorageSystemViewObject(com.emc.storageos.plugins.StorageSystemViewObject) XtremIOClient(com.emc.storageos.xtremio.restapi.XtremIOClient) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 8 with BaseCollectionException

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

the class FirmwareProcessor method processResult.

/**
 * {@inheritDoc}
 */
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        String serialNumber = null;
        @SuppressWarnings("unchecked") final Iterator<CIMInstance> it = (Iterator<CIMInstance>) resultObj;
        _dbClient = (DbClient) keyMap.get(Constants.dbClient);
        coordinator = (CoordinatorClient) keyMap.get(Constants.COORDINATOR_CLIENT);
        AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
        String delimiter = Constants.PATH_DELIMITER_REGEX;
        if (Type.ibmxiv.name().equals(profile.getSystemType())) {
            delimiter = Pattern.quote(Constants.COLON);
        }
        if (it.hasNext()) {
            // e.g., IBM XIV InstanceID, IBMTSDS:IBM.2810-7825363
            CIMInstance firmwareInstance = it.next();
            serialNumber = firmwareInstance.getPropertyValue(INSTANCEID).toString().split(delimiter)[1];
            String nativeGuid = NativeGUIDGenerator.generateNativeGuid(profile.getSystemType(), serialNumber);
            List<StorageSystem> systems = CustomQueryUtility.getActiveStorageSystemByNativeGuid(_dbClient, nativeGuid);
            if (!systems.isEmpty()) {
                StorageSystem system = systems.get(0);
                checkFirmwareVersion(firmwareInstance, system);
            }
        } else {
            String errMsg = String.format("No information obtained from Provider %s for Firmware 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 Firmware 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) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 9 with BaseCollectionException

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

the class PoolCapabilitiesProcessor 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);
        AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
        StorageSystem device = getStorageSystem(_dbClient, profile.getSystemId());
        while (it.hasNext()) {
            CIMInstance capabilitiesInstance = null;
            try {
                capabilitiesInstance = it.next();
                String instanceID = capabilitiesInstance.getPropertyValue(Constants.INSTANCEID).toString();
                if (DiscoveredDataObject.Type.vnxblock.toString().equalsIgnoreCase(device.getSystemType())) {
                    insertExpectedPoolSettingsPerTier(capabilitiesInstance.getObjectPath(), keyMap);
                    addPath(keyMap, Constants.VNXPOOLCAPABILITIES, capabilitiesInstance.getObjectPath());
                }
                addPath(keyMap, operation.getResult(), capabilitiesInstance.getObjectPath());
            } catch (Exception e) {
                _logger.warn("Pool Capabilities Discovery failed for {}-->{}", capabilitiesInstance.getObjectPath(), getMessage(e));
            }
        }
    } catch (Exception e) {
        _logger.error("Pool Capabilities Discovery failed -->{}", getMessage(e));
    }
}
Also used : Iterator(java.util.Iterator) AccessProfile(com.emc.storageos.plugins.AccessProfile) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 10 with BaseCollectionException

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

the class ConnectivityCollectionRelationshipsProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        @SuppressWarnings("unchecked") final Iterator<CIMObjectPath> it = (Iterator<CIMObjectPath>) resultObj;
        boolean volumeAdded = false;
        DbClient dbClient = (DbClient) keyMap.get(Constants.dbClient);
        CIMObjectPath raGroupPath = getObjectPathfromCIMArgument(args);
        String ragGroupId = NativeGUIDGenerator.generateRAGroupNativeGuid(raGroupPath);
        _log.debug("RA Group Id : {}", ragGroupId);
        RemoteDirectorGroup rg = getRAGroupUriFromDB(dbClient, ragGroupId);
        if (null == rg) {
            _log.info("RA Group Not found : {}", ragGroupId);
            return;
        }
        URI raGroupUri = rg.getId();
        @SuppressWarnings("unchecked") Map<String, URI> rAGroupMap = (Map<String, URI>) keyMap.get(Constants.RAGROUP);
        Set<String> volumeNativeGuids = new StringSet();
        while (it.hasNext()) {
            CIMObjectPath connCollectionRelationPaths = it.next();
            String cimClass = connCollectionRelationPaths.getObjectName();
            if (PROTOCOL_END_POINT.equals(cimClass)) {
                String endPointId = connCollectionRelationPaths.getKey(Constants.NAME).getValue().toString();
                _log.info("End Point Added {}", connCollectionRelationPaths);
                addPath(keyMap, Constants.ENDPOINTS_RAGROUP, connCollectionRelationPaths);
                rAGroupMap.put(endPointId, raGroupUri);
            } else if (VOLUME.equals(cimClass)) {
                String volumeNativeGuid = getVolumeNativeGuid(connCollectionRelationPaths);
                if (!volumeAdded && !rAGroupMap.containsKey(volumeNativeGuid)) {
                    volumeAdded = true;
                    _log.info("Volume Added {}", connCollectionRelationPaths);
                    addPath(keyMap, Constants.VOLUME_RAGROUP, connCollectionRelationPaths);
                    rAGroupMap.put(volumeNativeGuid, raGroupUri);
                } else {
                    _log.info("Volume {} is part of multiple RA Groups", volumeNativeGuid);
                }
                volumeNativeGuids.add(volumeNativeGuid);
            }
        }
        RemoteDirectorGroup remoteGroup = dbClient.queryObject(RemoteDirectorGroup.class, raGroupUri);
        // async
        if (!volumeAdded) {
            remoteGroup.setSupportedCopyMode(SupportedCopyModes.ALL.toString());
        }
        if (null == remoteGroup.getVolumes() || remoteGroup.getVolumes().isEmpty()) {
            remoteGroup.setVolumes(new StringSet(volumeNativeGuids));
        } else {
            _log.debug("Existing Volumes {}", Joiner.on("\t").join(remoteGroup.getVolumes()));
            _log.debug("New Volumes {}", Joiner.on("\t").join(volumeNativeGuids));
            remoteGroup.getVolumes().replace(volumeNativeGuids);
            _log.debug("Updated Volumes {}", Joiner.on("\t").join(remoteGroup.getVolumes()));
        }
        dbClient.persistObject(remoteGroup);
    } catch (Exception e) {
        _log.error("Exception occurred while processing remote connectivity information.", e);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) CIMObjectPath(javax.cim.CIMObjectPath) URI(java.net.URI) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) Iterator(java.util.Iterator) StringSet(com.emc.storageos.db.client.model.StringSet) RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup) Map(java.util.Map)

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