Search in sources :

Example 11 with StorageSystemViewObject

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

the class TestDataCollectionJobConsumer method triggerScanning.

private void triggerScanning(DataCollectionScanJob job) throws Exception {
    _logger.info("Started scanning SMIS Providers : triggerScanning()");
    List<URI> allProviderURI = _dbClient.queryByType(StorageProvider.class, true);
    List<StorageProvider> allProviders = _dbClient.queryObject(StorageProvider.class, allProviderURI);
    Map<String, StorageSystemViewObject> storageSystemsCache = Collections.synchronizedMap(new HashMap<String, StorageSystemViewObject>());
    boolean exceptionIntercepted = false;
    try {
        List<URI> cacheProviders = new ArrayList<URI>();
        // since dbQuery does not return a normal list required by
        // bookkeeping, we need to rebuild it.
        allProviderURI = new ArrayList<URI>();
        // at the same time.
        for (StorageProvider provider : allProviders) {
            allProviderURI.add(provider.getId());
            ScanTaskCompleter scanCompleter = job.findProviderTaskCompleter(provider.getId());
            if (scanCompleter == null) {
                String taskId = UUID.randomUUID().toString();
                scanCompleter = new ScanTaskCompleter(StorageProvider.class, provider.getId(), taskId);
                job.addCompleter(scanCompleter);
            }
            try {
                provider.setLastScanStatusMessage("");
                _dbClient.persistObject(provider);
                _logger.info("provider.getInterfaceType():{}", provider.getInterfaceType());
                performScan(provider.getId(), scanCompleter, storageSystemsCache);
                cacheProviders.add(provider.getId());
            } catch (Exception ex) {
                _logger.error("Scan failed for {}--->", provider.getId(), ex);
            }
            _dbClient.persistObject(provider);
        }
        // Perform BooKKeeping
        // TODO: we need to access the status of job completer.
        // for now we assume that this operation can not fail.
        _util.performBookKeeping(storageSystemsCache, allProviderURI);
        for (URI provider : cacheProviders) {
            job.findProviderTaskCompleter(provider).ready(_dbClient);
            _logger.info("Scan complete successfully for " + provider);
        }
    } catch (final Exception ex) {
        _logger.error("Scan failed for {} ", ex.getMessage());
        job.error(_dbClient, DeviceControllerErrors.dataCollectionErrors.scanFailed(ex.getLocalizedMessage(), ex));
        exceptionIntercepted = true;
        throw ex;
    } finally {
        try {
            if (!exceptionIntercepted && job.isSchedulerJob()) {
                // Manually trigger discoveries, if any new Arrays detected
                triggerDiscoveryNew(storageSystemsCache, DataCollectionJob.JobOrigin.SCHEDULER);
            }
        } catch (Exception ex) {
            _logger.error(ex.getMessage(), ex);
        }
    }
}
Also used : StorageSystemViewObject(com.emc.storageos.plugins.StorageSystemViewObject) ArrayList(java.util.ArrayList) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) URI(java.net.URI) ControllerException(com.emc.storageos.volumecontroller.ControllerException)

Example 12 with StorageSystemViewObject

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

the class DataDomainCommunicationInterface method scan.

@Override
public void scan(AccessProfile accessProfile) throws DataDomainApiException {
    DataDomainClient ddClient = getDataDomainClient(accessProfile);
    StorageProvider provider = _dbClient.queryObject(StorageProvider.class, accessProfile.getSystemId());
    DDMCInfoDetail ddmcInfo = new DDMCInfoDetail();
    try {
        ddmcInfo = ddClient.getManagementSystemInfo();
    } catch (DataDomainApiException dex) {
        provider.setConnectionStatus(ConnectionStatus.NOTCONNECTED.toString());
        String op = "DDMC info retrieval";
        String sys = provider.getLabel() + "(" + provider.getIPAddress() + ")";
        throw DataDomainApiException.exceptions.opFailedProviderUnreachable(op, sys);
    }
    if (!validDdmcVersion(accessProfile, provider, ddmcInfo)) {
        String version = null;
        String minimumSupportedVersion = null;
        Map<String, String> props = accessProfile.getProps();
        if (props != null) {
            version = props.get(CURRENT_VERSION);
            minimumSupportedVersion = props.get(MINIMUM_VERSION);
        }
        throw DataDomainApiException.exceptions.scanFailedIncompatibleDdmc(version, minimumSupportedVersion);
    }
    Map<String, StorageSystemViewObject> cache = accessProfile.getCache();
    DDSystemList systemList = ddClient.getManagedSystemList();
    for (DDSystemInfo system : systemList.getSystemInfo()) {
        DDSystem ddSystem = ddClient.getDDSystem(system.getId());
        StorageSystemViewObject view = new StorageSystemViewObject();
        view.addprovider(accessProfile.getSystemId().toString());
        view.setDeviceType(accessProfile.getSystemType());
        view.setProperty(StorageSystemViewObject.SERIAL_NUMBER, ddSystem.serialNo);
        view.setProperty(StorageSystemViewObject.MODEL, ddSystem.model);
        view.setProperty(StorageSystemViewObject.STORAGE_NAME, ddSystem.name);
        view.setProperty(StorageSystemViewObject.VERSION, ddSystem.version);
        cache.put(system.getId(), view);
    }
}
Also used : DataDomainApiException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException) DDSystemInfo(com.emc.storageos.datadomain.restapi.model.DDSystemInfo) DDMCInfoDetail(com.emc.storageos.datadomain.restapi.model.DDMCInfoDetail) DDSystemList(com.emc.storageos.datadomain.restapi.model.DDSystemList) StorageSystemViewObject(com.emc.storageos.plugins.StorageSystemViewObject) DDSystem(com.emc.storageos.datadomain.restapi.model.DDSystem) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) DataDomainClient(com.emc.storageos.datadomain.restapi.DataDomainClient)

Example 13 with StorageSystemViewObject

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

the class SMICommunicationInterface method scan.

/**
 * {@inheritDoc}
 */
@Override
public void scan(AccessProfile accessProfile) throws BaseCollectionException {
    URI providerURI = null;
    StorageProvider providerObj = null;
    String detailedStatusMessage = "Unknown Status";
    try {
        _logger.info("Access Profile Details :" + accessProfile.toString());
        providerURI = accessProfile.getSystemId();
        providerObj = _dbClient.queryObject(StorageProvider.class, providerURI);
        _keyMap = new ConcurrentHashMap<String, Object>();
        _wbemClient = getCIMClient(accessProfile);
        _logger.info("CIMClient initialized successfully");
        _keyMap.put(Constants.PROPS, accessProfile.getProps());
        if (accessProfile.getCache() == null) {
            accessProfile.setCache(new HashMap<String, StorageSystemViewObject>());
        }
        _keyMap.put(Constants._computerSystem, new ArrayList<CIMObjectPath>());
        _keyMap.put(Constants.REGISTEREDPROFILE, CimObjectPathCreator.createInstance(Constants.PROFILECLASS, "interop"));
        _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._InteropNamespace, accessProfile.getInteropNamespace());
        _keyMap.put(Constants.ACCESSPROFILE, accessProfile);
        _keyMap.put(Constants.SYSTEMCACHE, accessProfile.getCache());
        executor.setKeyMap(_keyMap);
        executor.execute((Namespace) namespaces.getNsList().get(SCAN));
        // scan succeeds
        detailedStatusMessage = String.format("Scan job completed successfully for " + "SMISProvider: %s", providerURI.toString());
    } catch (Exception e) {
        detailedStatusMessage = String.format("Scan job failed for SMISProvider: %s because %s", providerURI.toString(), e.getMessage());
        throw new SMIPluginException(detailedStatusMessage);
    } finally {
        if (providerObj != null) {
            try {
                // set detailed message
                providerObj.setLastScanStatusMessage(detailedStatusMessage);
                _dbClient.persistObject(providerObj);
            } catch (DatabaseException ex) {
                _logger.error("Error while persisting object to DB", ex);
            }
        }
        releaseResources();
    }
}
Also used : StorageSystemViewObject(com.emc.storageos.plugins.StorageSystemViewObject) CIMObjectPath(javax.cim.CIMObjectPath) 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) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) 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)

Example 14 with StorageSystemViewObject

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

the class VNXUnityCommunicationInterface method scan.

/**
 * Implementation for scan for Vnx Unity storage systems.
 *
 * @param accessProfile
 *
 * @throws BaseCollectionException
 */
@Override
public void scan(AccessProfile accessProfile) throws BaseCollectionException {
    _logger.info("Starting scan of Unity StorageProvider. IP={}", accessProfile.getIpAddress());
    StorageProvider.ConnectionStatus cxnStatus = StorageProvider.ConnectionStatus.CONNECTED;
    StorageProvider provider = _dbClient.queryObject(StorageProvider.class, accessProfile.getSystemId());
    _locker.acquireLock(accessProfile.getIpAddress(), LOCK_WAIT_SECONDS);
    try {
        VNXeApiClient apiClient = getVnxUnityClient(accessProfile);
        if (apiClient != null) {
            Map<String, StorageSystemViewObject> storageSystemsCache = accessProfile.getCache();
            BasicSystemInfo unitySystem = apiClient.getBasicSystemInfo();
            String unityType = StorageSystem.Type.unity.name();
            String version = unitySystem.getApiVersion();
            String compatibility = StorageSystem.CompatibilityStatus.COMPATIBLE.name();
            provider.setCompatibilityStatus(compatibility);
            provider.setVersionString(version);
            VNXeStorageSystem system = apiClient.getStorageSystem();
            _logger.info("Found Unity: {} ", system.getSerialNumber());
            String id = system.getSerialNumber();
            String nativeGuid = generateNativeGuid(unityType, id);
            StorageSystemViewObject viewObject = storageSystemsCache.get(nativeGuid);
            if (viewObject == null) {
                viewObject = new StorageSystemViewObject();
            }
            viewObject.setDeviceType(unityType);
            viewObject.addprovider(accessProfile.getSystemId().toString());
            viewObject.setProperty(StorageSystemViewObject.MODEL, unitySystem.getModel());
            viewObject.setProperty(StorageSystemViewObject.SERIAL_NUMBER, id);
            storageSystemsCache.put(nativeGuid, viewObject);
        }
    } catch (Exception e) {
        cxnStatus = StorageProvider.ConnectionStatus.NOTCONNECTED;
        _logger.error(String.format("Exception was encountered when attempting to scan Unity Instance %s", accessProfile.getIpAddress()), e);
        throw VNXeException.exceptions.scanFailed(accessProfile.getIpAddress(), e);
    } finally {
        provider.setConnectionStatus(cxnStatus.name());
        _dbClient.updateObject(provider);
        _logger.info("Completed scan of Unity StorageProvider. IP={}", accessProfile.getIpAddress());
        _locker.releaseLock(accessProfile.getIpAddress());
    }
}
Also used : VNXeStorageSystem(com.emc.storageos.vnxe.models.VNXeStorageSystem) StorageSystemViewObject(com.emc.storageos.plugins.StorageSystemViewObject) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) BasicSystemInfo(com.emc.storageos.vnxe.models.BasicSystemInfo) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) VNXeException(com.emc.storageos.vnxe.VNXeException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 15 with StorageSystemViewObject

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

the class VPlexCommunicationInterface method checkForClusterHardwareChange.

/**
 * Checks for hardware change from local to metro or vice versa. If the
 * system flag controller_vplex_allow_local_to_metro_auto_upgrade is set to
 * true, then the StorageSystem object and related StoragePorts will be updated
 * with the new serial number information.
 *
 * @param clusterAssembyIds the cluster assembly IDs detected
 * @param systemNativeGUID the storage system native GUID
 * @param systemSerialNumber the storage system serial number
 * @param client the VPLEX api client
 * @param scanCache the scan cache
 * @param mgmntServer the StorageProvider
 * @throws Exception if an error occurred
 */
private void checkForClusterHardwareChange(List<String> clusterAssembyIds, String systemNativeGUID, String systemSerialNumber, VPlexApiClient client, Map<String, StorageSystemViewObject> scanCache, StorageProvider mgmntServer) throws Exception {
    // we need to ensure the discovered storage system is not a result
    // of a hardware reconfiguration from local to metro, or vice versa
    s_logger.info("clusterAssembyIds is " + clusterAssembyIds);
    if (VPlexApiConstants.VPLEX_METRO_ASSEMBLY_COUNT == clusterAssembyIds.size()) {
        // check if this system could have been upgraded from local to metro
        List<StorageSystem> vplexLocalStorageSystems = VPlexControllerUtils.getAllVplexLocalStorageSystems(_dbClient);
        for (StorageSystem vplex : vplexLocalStorageSystems) {
            if (null != vplex && null != vplex.getVplexAssemblyIdtoClusterId()) {
                // because this is a local system, it should have only one assembly id
                String assemblyId = vplex.getVplexAssemblyIdtoClusterId().keySet().iterator().next();
                if (systemNativeGUID.contains(assemblyId)) {
                    String message = String.format("The VPLEX storage system serial number unexpectedly changed. " + "Existing VPLEX local assembly id %s is a substring of the newly-discoverd system GUID %s, " + "which indicates a change in VPLEX hardware configuration from local to metro. " + "Scanning of this Storage Provider cannot continue. Recommended course of action is " + "to contact EMC Customer Support.", assemblyId, systemNativeGUID);
                    boolean allowAutoUpgrade = Boolean.valueOf(ControllerUtils.getPropertyValueFromCoordinator(_coordinator, ALLOW_LOCAL_TO_METRO_AUTO_UPGRADE));
                    if (!allowAutoUpgrade) {
                        if (null != vplex && systemNativeGUID.contains(vplex.getNativeGuid())) {
                            s_logger.error(message);
                            vplex.setDiscoveryStatus(DataCollectionJobStatus.ERROR.name());
                            vplex.setLastDiscoveryStatusMessage(message);
                            vplex.setLastDiscoveryRunTime(System.currentTimeMillis());
                            _dbClient.updateObject(vplex);
                            throw VPlexApiException.exceptions.vplexClusterConfigurationChangedFromLocalToMetro(assemblyId, systemNativeGUID);
                        }
                    } else {
                        s_logger.warn(message);
                        s_logger.warn("Auto upgrade is allowed, will attempt to automatically upgrade to Metro");
                        // we have to (possibly temporarily) persist the new serial number so that the
                        // storage port native guid generator works, but we need to hold on to the old
                        // serial number so that we can roll back if necessary
                        String oldSerialNumber = vplex.getSerialNumber();
                        vplex.setSerialNumber(systemSerialNumber);
                        _dbClient.updateObject(vplex);
                        // this data will be transient unless the upgrade process completes
                        if (null == vplex.getSmisProviderIP()) {
                            s_logger.info("The provider information was nulled out by a previous upgrade attempt, resetting");
                            vplex.setActiveProviderURI(mgmntServer.getId());
                            StringSet providers = new StringSet();
                            providers.add(mgmntServer.getId().toString());
                            vplex.setProviders(providers);
                            vplex.setSmisProviderIP(mgmntServer.getIPAddress());
                            vplex.setSmisPortNumber(mgmntServer.getPortNumber());
                            vplex.setSmisUserName(mgmntServer.getUserName());
                            vplex.setSmisPassword(mgmntServer.getPassword());
                        }
                        // update scan cache
                        StorageSystemViewObject systemViewObject = scanCache.get(vplex.getNativeGuid());
                        if (null == systemViewObject) {
                            systemViewObject = new StorageSystemViewObject();
                        } else {
                            // this is a strange scanCache state that doesn't make any sense. just fail for safety reasons
                            throw VPlexApiException.exceptions.vplexClusterConfigurationChangedFromLocalToMetro(assemblyId, systemNativeGUID);
                        }
                        s_logger.info("adding systemNativeGuid {} storage view object {} to scan cache", systemNativeGUID, systemViewObject);
                        scanCache.put(systemNativeGUID, systemViewObject);
                        // update the label if it has not been changed from the default native GUID
                        if (vplex.getLabel().equals(vplex.getNativeGuid())) {
                            vplex.setLabel(systemNativeGUID);
                        }
                        vplex.setNativeGuid(systemNativeGUID);
                        // clear the assembly id collection, which will be updated by discoverClusterIdentification
                        vplex.setVplexAssemblyIdtoClusterId(new StringMap());
                        // update the assembly id map in the VPLEX storage system object
                        discoverClusterIdentification(vplex, client);
                        // update storage port native guids and labels
                        // and add them to an autoUpgradePortsMap to short circuit
                        // another database check and hold them through until they can be persisted
                        // at the end of the discoverPorts method call below
                        Map<String, StoragePort> autoUpgradePortsMap = new HashMap<String, StoragePort>();
                        List<StoragePort> storagePorts = ControllerUtils.getSystemPortsOfSystem(_dbClient, vplex.getId());
                        for (StoragePort storagePort : storagePorts) {
                            String nativeGuid = NativeGUIDGenerator.generateNativeGuid(_dbClient, storagePort);
                            s_logger.info("autoUpgradePortsMap: setting native guid {} on storage port {}", nativeGuid, storagePort.forDisplay());
                            storagePort.setNativeGuid(nativeGuid);
                            storagePort.setLabel(nativeGuid);
                            autoUpgradePortsMap.put(storagePort.getPortNetworkId(), storagePort);
                        }
                        boolean doPersist = false;
                        try {
                            // now rediscover all storage ports to pull in the new second cluster's ports
                            discoverPorts(client, vplex, new ArrayList<StoragePort>(), autoUpgradePortsMap);
                            doPersist = true;
                        } catch (Exception ex) {
                            s_logger.error("Failed to discover ports. ", ex);
                            // throw an exception to tell the user to contact customer support.
                            throw VPlexApiException.exceptions.vplexClusterConfigurationChangedFromLocalToMetro(assemblyId, systemNativeGUID);
                        } finally {
                            if (doPersist) {
                                // storage ports would have been updated by the discoverPorts method
                                // but we still need to update the vplex object
                                _dbClient.updateObject(vplex);
                            } else {
                                // we failed, so we want to set the serial number back to the old
                                // serial number that was set above on the copy in the database
                                StorageSystem databaseVplex = _dbClient.queryObject(StorageSystem.class, vplex.getId());
                                databaseVplex.setSerialNumber(oldSerialNumber);
                                _dbClient.updateObject(databaseVplex);
                            }
                        }
                    }
                }
            }
        }
    } else if (VPlexApiConstants.VPLEX_LOCAL_ASSEMBLY_COUNT == clusterAssembyIds.size()) {
        // check if this system could have been downgraded from metro to local
        List<StorageSystem> vplexMetroStorageSystems = VPlexControllerUtils.getAllVplexMetroStorageSystems(_dbClient);
        for (StorageSystem vplex : vplexMetroStorageSystems) {
            if (null != vplex && null != vplex.getVplexAssemblyIdtoClusterId()) {
                for (String assemblyId : vplex.getVplexAssemblyIdtoClusterId().keySet()) {
                    if (systemNativeGUID.contains(assemblyId)) {
                        // THIS IS VERY BAD
                        String message = String.format("The VPLEX storage system serial number unexpectedly changed. " + "The newly-discovered native GUID %s contains the existing VPLEX metro system assembly " + "id %s of VPLEX %s, which indicates a change in VPLEX hardware configuration from metro to local. " + "Scanning of this Storage Provider cannot continue. Recommended course of action is " + "to contact EMC Customer Support.", systemNativeGUID, assemblyId, vplex.forDisplay());
                        s_logger.error(message);
                        vplex.setDiscoveryStatus(DataCollectionJobStatus.ERROR.name());
                        vplex.setLastDiscoveryStatusMessage(message);
                        vplex.setLastDiscoveryRunTime(System.currentTimeMillis());
                        _dbClient.updateObject(vplex);
                        throw VPlexApiException.exceptions.vplexClusterConfigurationChangedFromMetroToLocal(systemNativeGUID, assemblyId);
                    }
                }
            }
        }
    } else {
        s_logger.warn("Unexpected assembly id count {}", clusterAssembyIds.size());
    }
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) StorageSystemViewObject(com.emc.storageos.plugins.StorageSystemViewObject) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) StoragePort(com.emc.storageos.db.client.model.StoragePort) URISyntaxException(java.net.URISyntaxException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) VPlexCollectionException(com.emc.storageos.plugins.metering.vplex.VPlexCollectionException) IOException(java.io.IOException) StringSet(com.emc.storageos.db.client.model.StringSet) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

StorageSystemViewObject (com.emc.storageos.plugins.StorageSystemViewObject)18 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)13 StorageProvider (com.emc.storageos.db.client.model.StorageProvider)8 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)8 IOException (java.io.IOException)6 URI (java.net.URI)6 ArrayList (java.util.ArrayList)6 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)3 VPlexCollectionException (com.emc.storageos.plugins.metering.vplex.VPlexCollectionException)3 VPlexApiException (com.emc.storageos.vplex.api.VPlexApiException)3 URISyntaxException (java.net.URISyntaxException)3 HashMap (java.util.HashMap)3 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)2 AccessProfile (com.emc.storageos.plugins.AccessProfile)2 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)2 ControllerException (com.emc.storageos.volumecontroller.ControllerException)2 CephClient (com.emc.storageos.ceph.CephClient)1 CephException (com.emc.storageos.ceph.CephException)1 ClusterInfo (com.emc.storageos.ceph.model.ClusterInfo)1 DataDomainClient (com.emc.storageos.datadomain.restapi.DataDomainClient)1