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);
}
}
Aggregations