Search in sources :

Example 1 with ClientConfig

use of com.emc.vipr.client.ClientConfig in project coprhd-controller by CoprHD.

the class ApisvcTestBase method getViprClient.

/**
 * Get a logged in ViPR client instance.
 * @param viprIP -- IP address (or FQDN) of Vipr server or devkit.
 * @param userName -- String user name.
 * @param password -- String password (unobfuscated).
 * @return ViPRCoreClient that has been authenticated
 */
public ViPRCoreClient getViprClient(String viprIP, String userName, String password) {
    ClientConfig clientConfig = new ClientConfig().withHost(viprIP).withRequestLoggingDisabled().withMaxRetries(10).withMediaType("application/json").withIgnoringCertificates(true);
    viprCoreClient = new ViPRCoreClient(clientConfig);
    AuthClient auth = viprCoreClient.auth();
    String token = auth.login(userName, password);
    viprCoreClient.setAuthToken(token);
    log.info("Auth token is: " + token);
    return viprCoreClient;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AuthClient(com.emc.vipr.client.AuthClient) ClientConfig(com.emc.vipr.client.ClientConfig)

Example 2 with ClientConfig

use of com.emc.vipr.client.ClientConfig in project coprhd-controller by CoprHD.

the class BourneUtil method getBaseClientConfig.

private static ClientConfig getBaseClientConfig() {
    ClientConfig config = new ClientConfig();
    config.setHost(getViprHost());
    config.setRequestLoggingEnabled(isConfigPropertySet("storageos.api.debugging"));
    // Client timeout
    PropertyInfo propInfo = null;
    if (!Play.mode.isDev()) {
        propInfo = StorageOsPlugin.getInstance().getCoordinatorClient().getPropertyInfo();
    }
    String timeoutProperty = null;
    int timeout = 5;
    if (propInfo != null) {
        timeoutProperty = propInfo.getProperty("portal_service_timeout");
    }
    if (timeoutProperty != null) {
        timeout = Integer.parseInt(timeoutProperty);
    } else {
        timeout = Integer.parseInt(Play.configuration.getProperty("vipr.client.timeout.minutes", "5"));
    }
    config.setReadTimeout(timeout * MINUTES_IN_MS);
    config.setConnectionTimeout(timeout * MINUTES_IN_MS);
    if (StorageOsPlugin.isEnabled()) {
        config.setSocketFactory(getSocketFactory());
        config.setHostnameVerifier(SSLUtil.getNullHostnameVerifier());
    } else {
        config.setIgnoreCertificates(true);
    }
    return config;
}
Also used : ClientConfig(com.emc.vipr.client.ClientConfig) PropertyInfo(com.emc.storageos.model.property.PropertyInfo)

Aggregations

ClientConfig (com.emc.vipr.client.ClientConfig)2 PropertyInfo (com.emc.storageos.model.property.PropertyInfo)1 AuthClient (com.emc.vipr.client.AuthClient)1 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)1