use of org.onap.so.heatbridge.openstack.api.OpenstackAccess in project so by onap.
the class MsoCloudClientFactoryImpl method getOpenstackClient.
@Override
public OpenstackClient getOpenstackClient(@Nonnull String url, @Nonnull String msoId, @Nonnull String msoPass, @Nonnull String regionId, @Nonnull String tenantId, @Nonnull String keystoneVersion, String userDomainName, String projectDomainName) throws HeatBridgeException {
Objects.requireNonNull(url, "Null openstack url!");
Objects.requireNonNull(msoId, "Null openstack user id!");
Objects.requireNonNull(msoPass, "Null openstack password!");
Objects.requireNonNull(regionId, "Null regionId ID!");
Objects.requireNonNull(tenantId, "Null tenant ID!");
Objects.requireNonNull(keystoneVersion, "Null keystone version");
if (userDomainName == null) {
userDomainName = HeatBridgeConstants.OS_DEFAULT_DOMAIN_NAME;
}
if (projectDomainName == null) {
projectDomainName = HeatBridgeConstants.OS_DEFAULT_DOMAIN_NAME;
}
try {
final OpenstackAccess osAccess = // keystone URL
new OpenstackAccessBuilder().setBaseUrl(url).setUser(// keystone username
msoId).setPassword(// keystone decrypted password
CryptoUtils.decryptCloudConfigPassword(msoPass)).setRegion(// openstack region
regionId).setDomainName(userDomainName).setProjectName(projectDomainName).setTenantId(// tenantId
tenantId).build();
// Identify the Keystone version
if (keystoneVersion.equals(HeatBridgeConstants.OS_KEYSTONE_V2_KEY)) {
return openstackClientFactory.createOpenstackV2Client(osAccess);
} else if (keystoneVersion.equals(HeatBridgeConstants.OS_KEYSTONE_V3_KEY)) {
return openstackClientFactory.createOpenstackV3Client(osAccess);
}
throw new OpenstackClientException("Unsupported keystone version! " + keystoneVersion);
} catch (OpenstackClientException osClientEx) {
logger.error("Error creating OS Client", osClientEx);
throw new HeatBridgeException("Client error when authenticating with the Openstack", osClientEx);
}
}
Aggregations