use of com.emc.storageos.cimadapter.connections.ConnectionManagerException 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;
}
use of com.emc.storageos.cimadapter.connections.ConnectionManagerException 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;
}
use of com.emc.storageos.cimadapter.connections.ConnectionManagerException 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;
}
Aggregations