Search in sources :

Example 1 with OSClientV2

use of org.openstack4j.api.OSClient.OSClientV2 in project so by onap.

the class OpenstackClientFactoryImpl method createOpenstackV2Client.

@Override
public OpenstackClient createOpenstackV2Client(OpenstackAccess osAccess) throws OpenstackClientException {
    Preconditions.checkNotNull(osAccess.getUrl(), "Keystone-v2 Auth: endpoint not set.");
    Preconditions.checkNotNull(osAccess.getUser(), "Keystone-v2 Auth: username not set.");
    Preconditions.checkNotNull(osAccess.getPassword(), "Keystone-v2 Auth: password not set.");
    Preconditions.checkNotNull(osAccess.getTenantId(), "Keystone-v2 Auth: tenant-id not set.");
    Preconditions.checkNotNull(osAccess.getRegion(), "Keystone-v2 Auth: region not set.");
    OSClientV2 client;
    try {
        OSFactory.enableHttpLoggingFilter(true);
        client = OSFactory.builderV2().endpoint(osAccess.getUrl()).credentials(osAccess.getUser(), osAccess.getPassword()).tenantId(osAccess.getTenantId()).authenticate().useRegion(osAccess.getRegion());
        return new OpenstackV2ClientImpl(client);
    } catch (AuthenticationException exception) {
        throw new OpenstackClientException("Failed to authenticate with Keystone-v2.0: " + osAccess.getUrl(), exception);
    }
}
Also used : OSClientV2(org.openstack4j.api.OSClient.OSClientV2) OpenstackV2ClientImpl(org.onap.so.heatbridge.openstack.api.OpenstackV2ClientImpl) AuthenticationException(org.openstack4j.api.exceptions.AuthenticationException) OpenstackClientException(org.onap.so.heatbridge.openstack.api.OpenstackClientException)

Aggregations

OpenstackClientException (org.onap.so.heatbridge.openstack.api.OpenstackClientException)1 OpenstackV2ClientImpl (org.onap.so.heatbridge.openstack.api.OpenstackV2ClientImpl)1 OSClientV2 (org.openstack4j.api.OSClient.OSClientV2)1 AuthenticationException (org.openstack4j.api.exceptions.AuthenticationException)1