Search in sources :

Example 1 with CimConnectionInfo

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

the class ShutdownTask method main.

public static void main(String[] args) {
    try {
        // Set the shutdown delay is one is passed.
        if (args.length > 0) {
            _shutdownDelay = Long.parseLong(args[0]);
        }
        // Create and start the connection manager.
        ClassPathXmlApplicationContext springContext = new ClassPathXmlApplicationContext(SPRING_CONFIG_FILE);
        _connectionManager = (ConnectionManager) springContext.getBean(CONNECTION_MANAGER_BEAN);
        // Create a CIM connection info and add the connection.
        CimConnectionInfo connectionInfo = new CimConnectionInfo();
        connectionInfo.setType(CimConstants.ECOM_CONNECTION_TYPE);
        connectionInfo.setHost(providerIP);
        connectionInfo.setPort(providerPort);
        connectionInfo.setUser(providerUser);
        connectionInfo.setPassword(providerPassword);
        connectionInfo.setInteropNS(providerInterOpNamespace);
        connectionInfo.setImplNS(providerNamespace);
        connectionInfo.setUseSSL(isProviderSslEnabled);
        _connectionManager.addConnection(connectionInfo);
        // Create the shut down task and schedule it.
        ShutdownTask shutDownTask = new ShutdownTask();
        Timer timer = new Timer();
        timer.schedule(shutDownTask, _shutdownDelay);
    } catch (Exception e) {
        s_logger.error("Exception adding connection.", e);
    }
}
Also used : Timer(java.util.Timer) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) CimConnectionInfo(com.emc.storageos.cimadapter.connections.cim.CimConnectionInfo)

Example 2 with CimConnectionInfo

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

the class ConnectionManagerTest method testAddConnectionECOM.

/**
 * Tests the addConnection method for an ECOM connection type.
 */
@Test
public void testAddConnectionECOM() {
    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);
    // 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);
}
Also used : CimConnectionInfo(com.emc.storageos.cimadapter.connections.cim.CimConnectionInfo) Test(org.junit.Test)

Example 3 with CimConnectionInfo

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

the class ConnectionManagerTest method testAddConnectionException.

/**
 * Tests the addConnection method when an exception occurs trying to create
 * the CIM client connection.
 */
@Test
public void testAddConnectionException() {
    Assert.assertNotNull(_connectionManager);
    // Create the connection info with an invalid provider host, which will
    // cause an exception to occur when creating the CIM client connection.
    CimConnectionInfo connectionInfo = new CimConnectionInfo();
    connectionInfo.setType(CimConstants.ECOM_CONNECTION_TYPE);
    connectionInfo.setHost(null);
    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.assertTrue(wasException);
    // Assert the provider is not connected.
    wasException = false;
    try {
        Assert.assertFalse(_connectionManager.isConnected(PROVIDER_IP));
    } catch (ConnectionManagerException e) {
        wasException = true;
    }
    Assert.assertFalse(wasException);
}
Also used : CimConnectionInfo(com.emc.storageos.cimadapter.connections.cim.CimConnectionInfo) Test(org.junit.Test)

Example 4 with CimConnectionInfo

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

the class CelerraConnectionTest method createConnectionInfo.

/**
 * Creates the connection info for the connection.
 *
 * @return The connection info for the connection
 */
private static CimConnectionInfo createConnectionInfo() {
    CimConnectionInfo connectionInfo = new CimConnectionInfo();
    connectionInfo.setType(CimConstants.ECOM_FILE_CONNECTION_TYPE);
    connectionInfo.setHost(PROVIDER_IP);
    connectionInfo.setPort(PROVIDER_PORT);
    connectionInfo.setUser(PROVIDER_USER);
    connectionInfo.setPassword(PROVIDER_PW);
    connectionInfo.setInteropNS(PROVIDER_INTEROP_NS);
    connectionInfo.setImplNS(PROVIDER_IMPL_NS);
    connectionInfo.setUseSSL(true);
    return connectionInfo;
}
Also used : CimConnectionInfo(com.emc.storageos.cimadapter.connections.cim.CimConnectionInfo)

Example 5 with CimConnectionInfo

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

the class EcomConnectionTest method createConnectionInfo.

/**
 * Creates the connection info for the connection.
 *
 * @return The connection info for the connection
 */
private static CimConnectionInfo createConnectionInfo() {
    CimConnectionInfo connectionInfo = new CimConnectionInfo();
    connectionInfo.setType(CimConstants.ECOM_CONNECTION_TYPE);
    connectionInfo.setHost(providerIP);
    connectionInfo.setPort(providerPort);
    connectionInfo.setUser(providerUser);
    connectionInfo.setPassword(providerPassword);
    connectionInfo.setInteropNS(providerInterOpNamespace);
    connectionInfo.setImplNS(providerNamespace);
    connectionInfo.setUseSSL(isProviderSslEnabled);
    return connectionInfo;
}
Also used : CimConnectionInfo(com.emc.storageos.cimadapter.connections.cim.CimConnectionInfo)

Aggregations

CimConnectionInfo (com.emc.storageos.cimadapter.connections.cim.CimConnectionInfo)16 Test (org.junit.Test)9 ConnectionManagerException (com.emc.storageos.cimadapter.connections.ConnectionManagerException)3 CimConnection (com.emc.storageos.cimadapter.connections.cim.CimConnection)2 StorageProvider (com.emc.storageos.db.client.model.StorageProvider)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 StorageMonitorException (com.emc.storageos.volumecontroller.StorageMonitorException)1 IOException (java.io.IOException)1 Timer (java.util.Timer)1 PostConstruct (javax.annotation.PostConstruct)1 WBEMException (javax.wbem.WBEMException)1 DependsOn (org.springframework.context.annotation.DependsOn)1 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)1