Search in sources :

Example 41 with CimConnection

use of com.emc.storageos.cimadapter.connections.cim.CimConnection in project coprhd-controller by CoprHD.

the class CIMConnectionFactory method getConnection.

/**
 * Return the cimConnection for the given storageDevice.
 * We would end up in scenarios ,where Provider present in StorageDevice is not there in
 * PhysicalStorageSystem.
 * TODO remove once metering integrated.
 *
 * @param storageDevice
 *            : StorageDevice.
 * @return CimConnection.
 */
public synchronized CimConnection getConnection(final StorageSystem storageDevice) {
    CimConnection connection = null;
    try {
        _connectionManager.configure(coordinatorClient.getPropertyInfo());
        /**
         * Check cimConnection already exist for vnxfile, if not create new one
         */
        if (StorageSystem.Type.vnxfile.name().equals(storageDevice.getSystemType())) {
            connection = _connectionManager.getConnection(storageDevice.getSmisProviderIP(), storageDevice.getPortNumber());
        } else {
            connection = getConnection(storageDevice.getSmisProviderIP(), storageDevice.getSmisPortNumber().toString());
        }
        if (null == connection) {
            final CimConnectionInfo connInfo = new CimConnectionInfo();
            connInfo.setHost(storageDevice.getSmisProviderIP());
            connInfo.setPort(storageDevice.getSmisPortNumber());
            connInfo.setUser(storageDevice.getSmisUserName());
            connInfo.setPassword(storageDevice.getSmisPassword());
            connInfo.setUseSSL(storageDevice.getSmisUseSSL());
            connInfo.setInteropNS(CimConstants.DFLT_CIM_CONNECTION_INTEROP_NS);
            // Set the type of connection to be created.
            connInfo.setType(getConnectionTypeForDevice(storageDevice.getSystemType()));
            // Set the implementation namespace for this type of storage device
            connInfo.setImplNS(getImplNamespaceForDevice(storageDevice.getSystemType()));
            _connectionManager.addConnection(connInfo);
            connection = getConnection(storageDevice.getSmisProviderIP(), storageDevice.getSmisPortNumber().toString());
        }
    } catch (final ConnectionManagerException ex) {
        _log.error("No CIMOM Connection found for ipaddress due to ", ex);
    }
    return connection;
}
Also used : CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) ConnectionManagerException(com.emc.storageos.cimadapter.connections.ConnectionManagerException) CimConnectionInfo(com.emc.storageos.cimadapter.connections.cim.CimConnectionInfo)

Example 42 with CimConnection

use of com.emc.storageos.cimadapter.connections.cim.CimConnection in project coprhd-controller by CoprHD.

the class CIMConnectionFactory method refreshVnXFileConnections.

/**
 * Creates valid CIMConnection instances and removes invalid cimConnection instances from connectionManager for vnxfile StorageSystem's
 * smis provider
 * 1. Get all vnxFile StorageSystem from DB
 * 2. Check if the connection is valid one using liveliness check
 * 3. If the connection can communicate smis provider do nothing
 * 4. else remove connection from _connectionManager
 *
 * @throws IOException
 * @throws ConnectionManagerException
 */
public void refreshVnXFileConnections() throws IOException, ConnectionManagerException {
    List<URI> allStorageSystemsURIList = _dbClient.queryByType(StorageSystem.class, true);
    Iterator<StorageSystem> allStorageSystemItr = _dbClient.queryIterativeObjects(StorageSystem.class, allStorageSystemsURIList);
    while (allStorageSystemItr.hasNext()) {
        CimConnection cimConnection = null;
        StorageSystem storageSystem = allStorageSystemItr.next();
        if (null != storageSystem && Type.vnxfile.toString().equals(storageSystem.getSystemType())) {
            // Before calling getConnection check if storage System have valid SMIS connection during discovery
            if (null != storageSystem.getSmisConnectionStatus() && ConnectionStatus.CONNECTED.toString().equalsIgnoreCase(storageSystem.getSmisConnectionStatus())) {
                cimConnection = getConnection(storageSystem);
            }
            if (null == cimConnection) {
                _log.error("No CIMOM connection found for ip/port {}", ConnectionManager.generateConnectionCacheKey(storageSystem.getSmisProviderIP(), storageSystem.getSmisPortNumber()));
                recordStorageProviderEvent(OperationTypeEnum.STORAGE_PROVIDER_DOWN, STORAGE_PROVIDER_DOWN_DESCRIPTION_VNXFILE + storageSystem.getSmisProviderIP(), storageSystem.getId());
                // No need to add connection, as getConnection() called from any thread would create it.
                continue;
            }
            if (!checkConnectionliveness(cimConnection)) {
                // changing connection status for storagesystem
                if (null != storageSystem.getSmisConnectionStatus() && ConnectionStatus.CONNECTED.toString().equalsIgnoreCase(storageSystem.getSmisConnectionStatus())) {
                    recordStorageProviderEvent(OperationTypeEnum.STORAGE_PROVIDER_DOWN, STORAGE_PROVIDER_DOWN_DESCRIPTION_VNXFILE + storageSystem.getSmisProviderIP(), storageSystem.getId());
                    storageSystem.setSmisConnectionStatus(ConnectionStatus.NOTCONNECTED.toString());
                    _dbClient.persistObject(storageSystem);
                }
                _connectionManager.removeConnection(storageSystem.getSmisProviderIP(), storageSystem.getPortNumber());
                _log.info("Removed invalid connection for smis {} from connectionManager", ConnectionManager.generateConnectionCacheKey(storageSystem.getSmisProviderIP(), storageSystem.getSmisPortNumber()));
            } else {
                // changing connection status for storagesystem
                if (null != storageSystem.getSmisConnectionStatus() && ConnectionStatus.NOTCONNECTED.toString().equalsIgnoreCase(storageSystem.getSmisConnectionStatus())) {
                    recordStorageProviderEvent(OperationTypeEnum.STORAGE_PROVIDER_UP, STORAGE_PROVIDER_UP_DESCRIPTION_VNXFILE + storageSystem.getSmisProviderIP(), storageSystem.getId());
                    storageSystem.setSmisConnectionStatus(ConnectionStatus.CONNECTED.toString());
                    _dbClient.persistObject(storageSystem);
                }
            }
        }
    }
}
Also used : CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 43 with CimConnection

use of com.emc.storageos.cimadapter.connections.cim.CimConnection in project coprhd-controller by CoprHD.

the class CIMConnectionFactory method addConnection.

/**
 * If connection is null, create a new Connection
 *
 * @param smisIPAddress
 */
private synchronized CimConnection addConnection(String smisIPAddress, String port) {
    CimConnection connection = null;
    try {
        connection = _connectionManager.getConnection(smisIPAddress, Integer.parseInt(port));
        if (null == connection) {
            String smisAltId = smisIPAddress + "-" + port;
            List<StorageProvider> providers = CustomQueryUtility.getActiveStorageProvidersByProviderId(_dbClient, smisAltId);
            if (providers.isEmpty()) {
                _log.error("No SMISProvider found with id {}", smisAltId);
                return connection;
            }
            StorageProvider smisProvider = providers.get(0);
            final CimConnectionInfo connInfo = new CimConnectionInfo();
            connInfo.setHost(smisProvider.getIPAddress());
            connInfo.setPort(smisProvider.getPortNumber());
            connInfo.setUser(smisProvider.getUserName());
            connInfo.setPassword(smisProvider.getPassword());
            connInfo.setUseSSL(smisProvider.getUseSSL());
            if (smisProvider.getInterfaceType().equals(StorageProvider.InterfaceType.ibmxiv.name()) || "IBM".equals(smisProvider.getManufacturer())) {
                connInfo.setType(CimConstants.CIM_CONNECTION_TYPE);
                connInfo.setImplNS(CimConstants.DFLT_IBM_CIM_CONNECTION_IMPL_NS);
            } else {
                connInfo.setType(CimConstants.ECOM_CONNECTION_TYPE);
                connInfo.setImplNS(CimConstants.DFLT_CIM_CONNECTION_IMPL_NS);
            }
            connInfo.setInteropNS(CimConstants.DFLT_CIM_CONNECTION_INTEROP_NS);
            _connectionManager.addConnection(connInfo);
            connection = _connectionManager.getConnection(smisIPAddress, Integer.parseInt(port));
            _log.info("Connection Added to Cache {}", ConnectionManager.generateConnectionCacheKey(smisProvider.getIPAddress(), smisProvider.getPortNumber()));
        }
    } catch (ConnectionManagerException ex) {
        _log.error("Exception occurred while adding connections due to ", ex);
    } catch (Exception ex) {
        _log.error("Exception occurred while adding connections due to ", ex);
    }
    return connection;
}
Also used : CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) ConnectionManagerException(com.emc.storageos.cimadapter.connections.ConnectionManagerException) WBEMException(javax.wbem.WBEMException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) ConnectionManagerException(com.emc.storageos.cimadapter.connections.ConnectionManagerException) IOException(java.io.IOException) CimConnectionInfo(com.emc.storageos.cimadapter.connections.cim.CimConnectionInfo)

Example 44 with CimConnection

use of com.emc.storageos.cimadapter.connections.cim.CimConnection in project coprhd-controller by CoprHD.

the class CIMConnectionFactory method getConnection.

/**
 * Get a CimConnection for a given hostName.
 * if connection is null, then add a new Connection.
 * getConnection, at any point of time will get a new Connection Object.
 *
 * @param hostName
 *            : Provider hostName, if not existing.
 * @return CimConnection.
 * @throws IOException
 */
public synchronized CimConnection getConnection(String ipAddress, String port) {
    CimConnection connection = null;
    try {
        _connectionManager.configure(coordinatorClient.getPropertyInfo());
        connection = _connectionManager.getConnection(ipAddress, Integer.parseInt(port));
        if (null == connection) {
            connection = addConnection(ipAddress, port);
        }
    } catch (final ConnectionManagerException ex) {
        _log.error("Problem establishing connection to the SMI-S Provider: {} due to ", ipAddress, ex);
        throw new IllegalStateException("Problem establishing connection to the SMI-S Provider: " + ipAddress, ex);
    }
    return connection;
}
Also used : CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) ConnectionManagerException(com.emc.storageos.cimadapter.connections.ConnectionManagerException)

Example 45 with CimConnection

use of com.emc.storageos.cimadapter.connections.cim.CimConnection in project coprhd-controller by CoprHD.

the class CIMConnectionFactory method subscribeSMIProviderConnection.

/**
 * Make subscription to the given SMIS provider for monitoring use case
 *
 * @param smisProviderURI {@link String} Active SMIS Provider's URI for subscription
 * @return success flag. True means subscription for the given smisProvider is success, else returns false
 */
public boolean subscribeSMIProviderConnection(String smisProviderURI) {
    _log.debug("Entering {}", Thread.currentThread().getStackTrace()[1].getMethodName());
    boolean isSuccess = false;
    try {
        _log.debug("smisProviderURI :{}", smisProviderURI);
        CimConnection cimConnection = getSMISProviderConnection(smisProviderURI);
        if (null != cimConnection) {
            _connectionManager.subscribe(cimConnection);
            isSuccess = true;
        }
    } catch (Exception e) {
        _log.error("subscription for the SMIS provider {} is failed", smisProviderURI);
        _log.error(e.getMessage(), e);
    // throw e;
    }
    _log.debug("Exiting {}", Thread.currentThread().getStackTrace()[1].getMethodName());
    return isSuccess;
}
Also used : CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) WBEMException(javax.wbem.WBEMException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) ConnectionManagerException(com.emc.storageos.cimadapter.connections.ConnectionManagerException) IOException(java.io.IOException)

Aggregations

CimConnection (com.emc.storageos.cimadapter.connections.cim.CimConnection)45 WBEMException (javax.wbem.WBEMException)24 WBEMClient (javax.wbem.client.WBEMClient)24 CIMObjectPath (javax.cim.CIMObjectPath)20 CIMInstance (javax.cim.CIMInstance)16 IOException (java.io.IOException)13 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)12 ArrayList (java.util.ArrayList)12 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)10 ConnectionManagerException (com.emc.storageos.cimadapter.connections.ConnectionManagerException)9 Volume (com.emc.storageos.db.client.model.Volume)8 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)8 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)6 CIMArgument (javax.cim.CIMArgument)6 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)5 URI (java.net.URI)5 BlockObject (com.emc.storageos.db.client.model.BlockObject)4 StoragePool (com.emc.storageos.db.client.model.StoragePool)4 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)3 ExportMask (com.emc.storageos.db.client.model.ExportMask)3