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