Search in sources :

Example 61 with StorageProvider

use of com.emc.storageos.db.client.model.StorageProvider 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 62 with StorageProvider

use of com.emc.storageos.db.client.model.StorageProvider 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 63 with StorageProvider

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

the class BlockControllerImpl method scanStorageProviders.

/**
 * {@inheritDoc}
 */
@Override
public void scanStorageProviders(AsyncTask[] tasks) throws ControllerException {
    try {
        Map<String, DataCollectionScanJob> scanJobByInterfaceType = new HashMap<String, DataCollectionScanJob>();
        for (AsyncTask task : tasks) {
            ScanTaskCompleter completer = new ScanTaskCompleter(task);
            StorageProvider provider = _dbClient.queryObject(StorageProvider.class, completer.getId());
            if (provider != null && !provider.getInactive()) {
                if (scanJobByInterfaceType.get(provider.getInterfaceType()) == null) {
                    scanJobByInterfaceType.put(provider.getInterfaceType(), new DataCollectionScanJob());
                }
                scanJobByInterfaceType.get(provider.getInterfaceType()).addCompleter(completer);
            }
        }
        for (DataCollectionScanJob job : scanJobByInterfaceType.values()) {
            _util.scheduleScanningJobs(job);
        }
    } catch (Exception e) {
        throw ClientControllerException.fatals.unableToScanSMISProviders(tasks, "BlockController", e);
    }
}
Also used : HashMap(java.util.HashMap) AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) ArrayAffinityAsyncTask(com.emc.storageos.volumecontroller.ArrayAffinityAsyncTask) ScanTaskCompleter(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.ScanTaskCompleter) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) DataCollectionScanJob(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.DataCollectionScanJob) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) ClientControllerException(com.emc.storageos.exceptions.ClientControllerException) RetryableDatabaseException(com.emc.storageos.db.exceptions.RetryableDatabaseException)

Example 64 with StorageProvider

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

the class VPlexCommunicationInterface method discoverAll.

/**
 * Implementation for discovering everything in a VPLEX storage system.
 *
 * @param accessProfile providing context for this discovery session
 *
 * @throws BaseCollectionException
 */
private void discoverAll(AccessProfile accessProfile) throws BaseCollectionException {
    boolean discoverySuccess = true;
    StringBuffer errMsgBuilder = new StringBuffer();
    URI storageSystemURI = null;
    StorageSystem vplexStorageSystem = null;
    String detailedStatusMessage = "Unknown Status";
    VPlexApiClient client = null;
    try {
        s_logger.info("Access Profile Details :  IpAddress : {}, PortNumber : {}", accessProfile.getIpAddress(), accessProfile.getPortNumber());
        storageSystemURI = accessProfile.getSystemId();
        // Get the VPlex storage system from the database.
        vplexStorageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemURI);
        s_logger.info("Discover VPlex storage system {} at IP:{}, PORT:{}", new Object[] { storageSystemURI.toString(), accessProfile.getIpAddress(), accessProfile.getPortNumber() });
        // Get the Http client for getting information about the VPlex
        // storage system.
        client = getVPlexAPIClient(accessProfile);
        s_logger.debug("Got handle to VPlex API client");
        // clear cached discovery data in the VPlexApiClient
        client.clearCaches();
        client.primeCaches();
        // The version for the storage system is the version of its active provider
        // and since we are discovering it, the provider was compatible, so the
        // VPLEX must also be compatible.
        StorageProvider activeProvider = _dbClient.queryObject(StorageProvider.class, vplexStorageSystem.getActiveProviderURI());
        String serialNumber = getSystemSerialNumber(client, activeProvider, null);
        if (!vplexStorageSystem.getSerialNumber().equals(serialNumber)) {
            s_logger.error(String.format("The VPLEX serial number unexpectedly changed from %s to %s.", vplexStorageSystem.getSerialNumber(), serialNumber));
            throw VPlexApiException.exceptions.vplexSerialNumberChanged(vplexStorageSystem.getSerialNumber(), serialNumber);
        }
        vplexStorageSystem.setFirmwareVersion(activeProvider.getVersionString());
        vplexStorageSystem.setCompatibilityStatus(CompatibilityStatus.COMPATIBLE.toString());
        // Discover the cluster identification (serial number / cluster id ) mapping
        try {
            s_logger.info("Discovering cluster identification.");
            discoverClusterIdentification(vplexStorageSystem, client);
            _completer.statusPending(_dbClient, "Completed cluster identification discovery");
        } catch (VPlexCollectionException vce) {
            discoverySuccess = false;
            String errMsg = String.format("Failed cluster identification discovery for VPlex %s", storageSystemURI.toString());
            s_logger.error(errMsg, vce);
            if (errMsgBuilder.length() != 0) {
                errMsgBuilder.append(", ");
            }
            errMsgBuilder.append(errMsg);
        }
        List<StoragePort> allPorts = new ArrayList<StoragePort>();
        // Discover the VPlex port information.
        try {
            // When we discover storage ports on the VPlex, we create
            // initiators, if they don't exist, for backend ports.
            // The backend storage ports serve as initiators for the
            // connected backend storage.
            s_logger.info("Discovering frontend and backend ports.");
            discoverPorts(client, vplexStorageSystem, allPorts, null);
            _dbClient.updateObject(vplexStorageSystem);
            _completer.statusPending(_dbClient, "Completed port discovery");
        } catch (VPlexCollectionException vce) {
            discoverySuccess = false;
            String errMsg = String.format("Failed port discovery for VPlex %s", storageSystemURI.toString());
            s_logger.error(errMsg, vce);
            if (errMsgBuilder.length() != 0) {
                errMsgBuilder.append(", ");
            }
            errMsgBuilder.append(errMsg);
        }
        // update host initiators with registered initiator names from VPLEX
        try {
            updateHostInitiators(client, vplexStorageSystem.getSerialNumber());
        } catch (VPlexCollectionException vce) {
            discoverySuccess = false;
            String errMsg = String.format("Failed host initiator update for VPlex %s", storageSystemURI.toString());
            s_logger.error(errMsg, vce);
            if (errMsgBuilder.length() != 0) {
                errMsgBuilder.append(", ");
            }
            errMsgBuilder.append(errMsg);
        }
        try {
            s_logger.info("Discovering connectivity.");
            discoverConnectivity(vplexStorageSystem);
            _dbClient.updateObject(vplexStorageSystem);
            _completer.statusPending(_dbClient, "Completed connectivity verification");
        } catch (VPlexCollectionException vce) {
            discoverySuccess = false;
            String errMsg = String.format("Failed connectivity discovery for VPlex %s", storageSystemURI.toString());
            s_logger.error(errMsg, vce);
            if (errMsgBuilder.length() != 0) {
                errMsgBuilder.append(", ");
            }
            errMsgBuilder.append(errMsg);
        }
        if (discoverySuccess) {
            vplexStorageSystem.setReachableStatus(true);
            _dbClient.updateObject(vplexStorageSystem);
        } else {
            // If part of the discovery process failed, throw an exception.
            vplexStorageSystem.setReachableStatus(false);
            _dbClient.updateObject(vplexStorageSystem);
            throw new Exception(errMsgBuilder.toString());
        }
        StoragePortAssociationHelper.runUpdatePortAssociationsProcess(allPorts, null, _dbClient, _coordinator, null);
        // discovery succeeds
        detailedStatusMessage = String.format("Discovery completed successfully for Storage System: %s", storageSystemURI.toString());
    } catch (Exception e) {
        if (null != client) {
            // clear cached discovery data in the VPlexApiClient
            client.clearCaches();
        }
        VPlexCollectionException vce = VPlexCollectionException.exceptions.failedDiscovery(storageSystemURI.toString(), e.getLocalizedMessage());
        detailedStatusMessage = vce.getLocalizedMessage();
        s_logger.error(detailedStatusMessage, e);
        throw vce;
    } finally {
        if (vplexStorageSystem != null) {
            try {
                // set detailed message
                vplexStorageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
                _dbClient.updateObject(vplexStorageSystem);
            } catch (DatabaseException ex) {
                s_logger.error("Error persisting last discovery status for storage system {}", vplexStorageSystem.getId(), ex);
            }
        }
    }
}
Also used : StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) URI(java.net.URI) 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) VPlexCollectionException(com.emc.storageos.plugins.metering.vplex.VPlexCollectionException) VPlexApiClient(com.emc.storageos.vplex.api.VPlexApiClient) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 65 with StorageProvider

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

the class VPlexCommunicationInterface method scan.

/**
 * Implementation for scan for VPlex storage systems.
 *
 * @param accessProfile
 *
 * @throws BaseCollectionException
 */
@Override
public void scan(AccessProfile accessProfile) throws BaseCollectionException {
    URI mgmntServerURI = accessProfile.getSystemId();
    StorageProvider mgmntServer = null;
    String scanStatusMessage = "Unknown Status";
    VPlexApiClient client = null;
    try {
        // Get the storage provider representing a VPLEX management server.
        mgmntServer = _dbClient.queryObject(StorageProvider.class, mgmntServerURI);
        // Get the Http client for getting information about the VPLEX
        // cluster(s) managed by the VPLEX management server.
        client = getVPlexAPIClient(accessProfile);
        s_logger.debug("Got handle to VPlex API client");
        // Verify the connectivity to the VPLEX management server.
        verifyConnectivity(client, mgmntServer);
        // Verify the VPLEX system firmware version is supported.
        verifyMinimumSupportedFirmwareVersion(client, mgmntServer);
        // Determine the VPLEX system managed by this management server.
        Map<String, StorageSystemViewObject> scanCache = accessProfile.getCache();
        s_logger.info("Storage System scanCache before scanning:" + scanCache);
        scanManagedSystems(client, mgmntServer, scanCache);
        s_logger.info("Storage System scanCache after scanning:" + scanCache);
        scanStatusMessage = String.format("Scan job completed successfully for " + "VPLEX management server: %s", mgmntServerURI.toString());
    } catch (Exception e) {
        if (null != client) {
            // clear cached discovery data in the VPlexApiClient
            client.clearCaches();
        }
        VPlexCollectionException vce = VPlexCollectionException.exceptions.failedScan(mgmntServer.getIPAddress(), e.getLocalizedMessage());
        scanStatusMessage = vce.getLocalizedMessage();
        throw vce;
    } finally {
        if (mgmntServer != null) {
            try {
                mgmntServer.setLastScanStatusMessage(scanStatusMessage);
                _dbClient.updateObject(mgmntServer);
            } catch (Exception e) {
                s_logger.error("Error persisting scan status message for management server {}", mgmntServerURI.toString(), e);
            }
        }
    }
}
Also used : VPlexCollectionException(com.emc.storageos.plugins.metering.vplex.VPlexCollectionException) StorageSystemViewObject(com.emc.storageos.plugins.StorageSystemViewObject) VPlexApiClient(com.emc.storageos.vplex.api.VPlexApiClient) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) URI(java.net.URI) 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)

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