use of com.emc.storageos.cimadapter.connections.cim.CimConnectionInfo in project coprhd-controller by CoprHD.
the class ConnectionManagerTest method testShutdown.
/**
* Tests the shutdown method.
*/
@Test
public void testShutdown() {
Assert.assertNotNull(_connectionManager);
// Create the connection info.
CimConnectionInfo connectionInfo = new CimConnectionInfo();
connectionInfo.setType(CimConstants.ECOM_CONNECTION_TYPE);
connectionInfo.setHost(PROVIDER_IP);
connectionInfo.setPort(PROVIDER_PORT);
connectionInfo.setUser(PROVIDER_USER);
connectionInfo.setPassword(PROVIDER_PWD);
connectionInfo.setInteropNS(PROVIDER_INTEROP_NS);
connectionInfo.setImplNS(BLOCK_PROVIDER_IMPL_NS);
connectionInfo.setUseSSL(Boolean.parseBoolean(providerUseSsl));
// Add the connection.
boolean wasException = false;
try {
_connectionManager.addConnection(connectionInfo);
} catch (ConnectionManagerException e) {
wasException = true;
}
Assert.assertFalse(wasException);
// Assert the provider is connected.
try {
Assert.assertTrue(_connectionManager.isConnected(PROVIDER_IP));
} catch (ConnectionManagerException e) {
wasException = true;
}
Assert.assertFalse(wasException);
// Shutdown connection manager.
try {
_connectionManager.shutdown();
} catch (ConnectionManagerException e) {
wasException = true;
}
Assert.assertFalse(wasException);
// Assert the provider is not connected.
try {
Assert.assertFalse(_connectionManager.isConnected(PROVIDER_IP));
} catch (ConnectionManagerException e) {
wasException = true;
}
Assert.assertFalse(wasException);
}
use of com.emc.storageos.cimadapter.connections.cim.CimConnectionInfo in project coprhd-controller by CoprHD.
the class ConnectionManagerTest method testAddConnectionAlreadyConnected.
/**
* Tests the addConnection method for an ECOM File connection type.
*/
/*
* @Test public void testAddConnection_ECOM_FILE() {
* Assert.assertNotNull(_connectionManager);
*
* // Create the connection info. CimConnectionInfo connectionInfo = new
* CimConnectionInfo();
* connectionInfo.setType(CimConstants.ECOM_FILE_CONNECTION_TYPE);
* connectionInfo.setHost(PROVIDER_IP);
* connectionInfo.setPort(PROVIDER_PORT);
* connectionInfo.setUser(FILE_PROVIDER_USER);
* connectionInfo.setPassword(FILE_PROVIDER_PW);
* connectionInfo.setInteropNS(PROVIDER_INTEROP_NS);
* connectionInfo.setImplNS(FILE_PROVIDER_IMPL_NS);
* connectionInfo.setUseSSL(true);
*
* // Add the connection. boolean wasException = false; try {
* _connectionManager.addConnection(connectionInfo); } catch
* (ConnectionManagerException e) { wasException = true; }
* Assert.assertFalse(wasException);
*
* // Assert the provider is connected. try {
* Assert.assertTrue(_connectionManager.isConnected(PROVIDER_IP));
*
* } catch (ConnectionManagerException e) { wasException = true; }
* Assert.assertFalse(wasException);
*
* // Clean up by removing the connection. try {
* _connectionManager.removeConnection(PROVIDER_IP); } catch
* (ConnectionManagerException e) { wasException = true; }
* Assert.assertFalse(wasException);
*
* // Assert the provider is no longer connected. try {
* Assert.assertFalse(_connectionManager.isConnected(PROVIDER_IP));
*
* } catch (ConnectionManagerException e) { wasException = true; }
* Assert.assertFalse(wasException); }
*/
/**
* Tests the addConnection method when the provider is already connected.
*/
@Test
public void testAddConnectionAlreadyConnected() {
Assert.assertNotNull(_connectionManager);
// Create the connection info.
CimConnectionInfo connectionInfo = new CimConnectionInfo();
connectionInfo.setType(CimConstants.ECOM_CONNECTION_TYPE);
connectionInfo.setHost(PROVIDER_IP);
connectionInfo.setPort(PROVIDER_PORT);
connectionInfo.setUser(PROVIDER_USER);
connectionInfo.setPassword(PROVIDER_PWD);
connectionInfo.setInteropNS(PROVIDER_INTEROP_NS);
connectionInfo.setImplNS(BLOCK_PROVIDER_IMPL_NS);
connectionInfo.setUseSSL(Boolean.parseBoolean(providerUseSsl));
// Add the connection.
boolean wasException = false;
try {
_connectionManager.addConnection(connectionInfo);
} catch (ConnectionManagerException e) {
wasException = true;
}
Assert.assertFalse(wasException);
// Assert the provider is connected.
try {
Assert.assertTrue(_connectionManager.isConnected(PROVIDER_IP));
} catch (ConnectionManagerException e) {
wasException = true;
}
Assert.assertFalse(wasException);
// exception, the current connection is used.
try {
_connectionManager.addConnection(connectionInfo);
} catch (ConnectionManagerException e) {
wasException = true;
}
Assert.assertFalse(wasException);
// Assert the provider is still connected.
try {
Assert.assertTrue(_connectionManager.isConnected(PROVIDER_IP));
} catch (ConnectionManagerException e) {
wasException = true;
}
Assert.assertFalse(wasException);
// Clean up by removing the connection.
try {
_connectionManager.removeConnection(PROVIDER_IP);
} catch (ConnectionManagerException e) {
wasException = true;
}
Assert.assertFalse(wasException);
// Assert the provider is no longer connected.
try {
Assert.assertFalse(_connectionManager.isConnected(PROVIDER_IP));
} catch (ConnectionManagerException e) {
wasException = true;
}
Assert.assertFalse(wasException);
}
use of com.emc.storageos.cimadapter.connections.cim.CimConnectionInfo in project coprhd-controller by CoprHD.
the class CimStorageMonitor method startMonitoring.
/**
* Starts event monitoring for the passed storage device by creating a
* connection to the SMI-S provider for the storage device.
*
* @param storageDevice A reference to the storage device.
*
* @throws StorageMonitorException When an error occurs monitoring the
* device.
*/
@Override
public void startMonitoring(StorageSystem storageDevice, WorkPool.Work work) throws StorageMonitorException {
s_logger.debug("Connecting storage for event monitoring. {}", storageDevice.getSystemType());
// Verify we got a non-null storage device.
if (storageDevice == null) {
throw new StorageMonitorException("Passed storage device is null");
}
s_logger.info("Attempting to connect to storage provider {} for event monitoring.", storageDevice.getSmisProviderIP());
// Verify the CIM connection manager reference.
if (_cimConnectionManager == null) {
throw new StorageMonitorException("CIM adapter connection manager reference is null.");
}
// Create the CIM connection info for the connection.
CimConnectionInfo connectionInfo = new CimConnectionInfo();
connectionInfo.setHost(storageDevice.getSmisProviderIP());
connectionInfo.setPort(storageDevice.getSmisPortNumber());
connectionInfo.setUser(storageDevice.getSmisUserName());
connectionInfo.setPassword(storageDevice.getSmisPassword());
connectionInfo.setInteropNS(CimConstants.DFLT_CIM_CONNECTION_INTEROP_NS);
connectionInfo.setUseSSL(storageDevice.getSmisUseSSL());
// Set the type of connection to be created.
connectionInfo.setType(getConnectionTypeForDevice(storageDevice.getSystemType()));
// Set the implementation namespace for this type of storage device
connectionInfo.setImplNS(getImplNamespaceForDevice(storageDevice.getSystemType()));
// connection is not already managed.
try {
_cimConnectionManager.addConnection(connectionInfo);
} catch (ConnectionManagerException cme) {
throw new StorageMonitorException(MessageFormatter.format("Failed attempting to establish a connection to storage provider {}.", storageDevice.getSmisProviderIP()).getMessage(), cme);
}
s_logger.info("Connection established for storage provider {}.", storageDevice.getSmisProviderIP());
}
use of com.emc.storageos.cimadapter.connections.cim.CimConnectionInfo 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.cim.CimConnectionInfo 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;
}
Aggregations