Search in sources :

Example 1 with HP3PARException

use of com.emc.storageos.hp3par.impl.HP3PARException in project coprhd-controller by CoprHD.

the class HP3PARApiFactory method getRESTClient.

/**
 * Create HP3PAR API client
 *
 * @param endpoint
 * @param username
 * @param password
 * @return api client
 * @throws HP3PARException
 */
public HP3PARApi getRESTClient(URI endpoint, String username, String password) throws HP3PARException {
    try {
        _log.info("3PARDriver:getRESTClient");
        // key=uri+user+pass to make unique, value=HP3PARApi object
        HP3PARApi hp3parApi = _clientMap.get(endpoint.toString() + ":" + username + ":" + password);
        if (hp3parApi == null) {
            _log.info("3PARDriver:getRESTClient1 hp3parApi null");
            ClientHandler handler = new URLConnectionClientHandler();
            Client connClient = new Client(handler, configureClient());
            RESTClient restClient = new RESTClient(connClient);
            hp3parApi = new HP3PARApi(endpoint, restClient, username, password);
            _clientMap.putIfAbsent(endpoint.toString() + ":" + username + ":" + password, hp3parApi);
        }
        return hp3parApi;
    } catch (Exception e) {
        e.printStackTrace();
        _log.error("3PARDriver:getRESTClient Error in getting RESTclient");
        throw new HP3PARException(e.toString());
    }
}
Also used : HP3PARException(com.emc.storageos.hp3par.impl.HP3PARException) ClientHandler(com.sun.jersey.api.client.ClientHandler) URLConnectionClientHandler(com.sun.jersey.client.urlconnection.URLConnectionClientHandler) ApacheHttpClientHandler(com.sun.jersey.client.apache.ApacheHttpClientHandler) URLConnectionClientHandler(com.sun.jersey.client.urlconnection.URLConnectionClientHandler) HP3PARApi(com.emc.storageos.hp3par.impl.HP3PARApi) ApacheHttpClient(com.sun.jersey.client.apache.ApacheHttpClient) HttpClient(org.apache.commons.httpclient.HttpClient) Client(com.sun.jersey.api.client.Client) HP3PARException(com.emc.storageos.hp3par.impl.HP3PARException) IOException(java.io.IOException) KeyManagementException(java.security.KeyManagementException) CertificateException(java.security.cert.CertificateException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Example 2 with HP3PARException

use of com.emc.storageos.hp3par.impl.HP3PARException in project coprhd-controller by CoprHD.

the class HP3PARUtil method getHP3PARDeviceFromNativeId.

public HP3PARApi getHP3PARDeviceFromNativeId(String nativeId, Registry driverRegistry) throws HP3PARException {
    try {
        Map<String, List<String>> connectionInfo = driverRegistry.getDriverAttributesForKey(HP3PARConstants.DRIVER_NAME, nativeId);
        List<String> ipAddress = connectionInfo.get(HP3PARConstants.IP_ADDRESS);
        List<String> portNumber = connectionInfo.get(HP3PARConstants.PORT_NUMBER);
        List<String> userName = connectionInfo.get(HP3PARConstants.USER_NAME);
        List<String> password = connectionInfo.get(HP3PARConstants.PASSWORD);
        HP3PARApi hp3parApi = getHP3PARDevice(ipAddress.get(0), portNumber.get(0), userName.get(0), password.get(0));
        return hp3parApi;
    } catch (Exception e) {
        e.printStackTrace();
        _log.error("3PARDriver:Error in getting 3PAR device with nativeId");
        throw new HP3PARException("Error in getting 3PAR device");
    }
}
Also used : HP3PARException(com.emc.storageos.hp3par.impl.HP3PARException) List(java.util.List) HP3PARApi(com.emc.storageos.hp3par.impl.HP3PARApi) HP3PARException(com.emc.storageos.hp3par.impl.HP3PARException)

Example 3 with HP3PARException

use of com.emc.storageos.hp3par.impl.HP3PARException in project coprhd-controller by CoprHD.

the class HP3PARUtil method getHP3PARDevice.

public HP3PARApi getHP3PARDevice(String ip, String port, String user, String pass) throws HP3PARException {
    URI deviceURI;
    _log.info("3PARDriver:getHP3PARDevice input full details");
    try {
        deviceURI = new URI("https", null, ip, Integer.parseInt(port), "/", null, null);
        return hp3parApiFactory.getRESTClient(deviceURI, user, pass);
    } catch (Exception e) {
        e.printStackTrace();
        _log.error("3PARDriver:Error in getting 3PAR device with details");
        throw new HP3PARException("Error in getting 3PAR device");
    }
}
Also used : HP3PARException(com.emc.storageos.hp3par.impl.HP3PARException) URI(java.net.URI) HP3PARException(com.emc.storageos.hp3par.impl.HP3PARException)

Example 4 with HP3PARException

use of com.emc.storageos.hp3par.impl.HP3PARException in project coprhd-controller by CoprHD.

the class HP3PARUtil method getHP3PARDevice.

public HP3PARApi getHP3PARDevice(StorageSystem hp3parSystem) throws HP3PARException {
    URI deviceURI;
    _log.info("3PARDriver:getHP3PARDevice input storage system");
    try {
        deviceURI = new URI("https", null, hp3parSystem.getIpAddress(), hp3parSystem.getPortNumber(), "/", null, null);
        return hp3parApiFactory.getRESTClient(deviceURI, hp3parSystem.getUsername(), hp3parSystem.getPassword());
    } catch (Exception e) {
        e.printStackTrace();
        _log.error("3PARDriver:Error in getting 3PAR device, with StorageSystem");
        throw new HP3PARException("Error in getting 3PAR device");
    }
}
Also used : HP3PARException(com.emc.storageos.hp3par.impl.HP3PARException) URI(java.net.URI) HP3PARException(com.emc.storageos.hp3par.impl.HP3PARException)

Aggregations

HP3PARException (com.emc.storageos.hp3par.impl.HP3PARException)4 HP3PARApi (com.emc.storageos.hp3par.impl.HP3PARApi)2 URI (java.net.URI)2 Client (com.sun.jersey.api.client.Client)1 ClientHandler (com.sun.jersey.api.client.ClientHandler)1 ApacheHttpClient (com.sun.jersey.client.apache.ApacheHttpClient)1 ApacheHttpClientHandler (com.sun.jersey.client.apache.ApacheHttpClientHandler)1 URLConnectionClientHandler (com.sun.jersey.client.urlconnection.URLConnectionClientHandler)1 IOException (java.io.IOException)1 KeyManagementException (java.security.KeyManagementException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 CertificateException (java.security.cert.CertificateException)1 List (java.util.List)1 HttpClient (org.apache.commons.httpclient.HttpClient)1