Search in sources :

Example 1 with OpenstackV3ClientImpl

use of org.onap.so.heatbridge.openstack.api.OpenstackV3ClientImpl in project so by onap.

the class OpenstackClientFactoryImpl method createOpenstackV3Client.

@Override
public OpenstackClient createOpenstackV3Client(OpenstackAccess osAccess) throws OpenstackClientException {
    Preconditions.checkNotNull(osAccess.getUrl(), "Keystone-v3 Auth: endpoint not set.");
    Preconditions.checkNotNull(osAccess.getUser(), "Keystone-v3 Auth: username not set.");
    Preconditions.checkNotNull(osAccess.getPassword(), "Keystone-v3 Auth: password not set.");
    Preconditions.checkNotNull(osAccess.getDomainNameIdentifier(), "Keystone-v3 Auth: domain not set.");
    Preconditions.checkNotNull(osAccess.getRegion(), "Keystone-v3 Auth: region not set.");
    Preconditions.checkNotNull(osAccess.getTenantId(), "Keystone-v3 Auth: tenant-id not set.");
    OSClientV3 client;
    try {
        OSFactory.enableHttpLoggingFilter(true);
        client = OSFactory.builderV3().endpoint(osAccess.getUrl()).credentials(osAccess.getUser(), osAccess.getPassword(), osAccess.getDomainNameIdentifier()).scopeToProject(Identifier.byId(osAccess.getTenantId()), osAccess.getProjectNameIdentifier()).authenticate().useRegion(osAccess.getRegion());
        return new OpenstackV3ClientImpl(client);
    } catch (AuthenticationException exception) {
        throw new OpenstackClientException("Failed to authenticate with Keystone-v3: " + osAccess.getUrl(), exception);
    }
}
Also used : OSClientV3(org.openstack4j.api.OSClient.OSClientV3) AuthenticationException(org.openstack4j.api.exceptions.AuthenticationException) OpenstackClientException(org.onap.so.heatbridge.openstack.api.OpenstackClientException) OpenstackV3ClientImpl(org.onap.so.heatbridge.openstack.api.OpenstackV3ClientImpl)

Aggregations

OpenstackClientException (org.onap.so.heatbridge.openstack.api.OpenstackClientException)1 OpenstackV3ClientImpl (org.onap.so.heatbridge.openstack.api.OpenstackV3ClientImpl)1 OSClientV3 (org.openstack4j.api.OSClient.OSClientV3)1 AuthenticationException (org.openstack4j.api.exceptions.AuthenticationException)1