use of com.sequenceiq.freeipa.dto.Credential in project cloudbreak by hortonworks.
the class NetworkService method fetchCloudNetworks.
private CloudNetworks fetchCloudNetworks(String environmentCrn, Stack stack, String networkId, Collection<String> subnetIds) {
Credential credential = credentialService.getCredentialByEnvCrn(environmentCrn);
ExtendedCloudCredential cloudCredential = extendedCloudCredentialConverter.convert(credential);
Map<String, String> filter = getCloudNetworkFilter(stack, networkId, subnetIds);
CloudNetworks cloudNetworks = cloudParameterService.getCloudNetworks(cloudCredential, stack.getRegion(), stack.getPlatformvariant(), filter);
LOGGER.debug("Received Cloud networks for region [{}]: {}", stack.getRegion(), cloudNetworks.getCloudNetworkResponses().get(stack.getRegion()));
return cloudNetworks;
}
use of com.sequenceiq.freeipa.dto.Credential in project cloudbreak by hortonworks.
the class CredentialService method getCredentialByEnvCrn.
public Credential getCredentialByEnvCrn(String envCrn) {
CredentialResponse credentialResponse = null;
try {
credentialResponse = credentialEndpoint.getByEnvironmentCrn(envCrn);
} catch (ClientErrorException e) {
try (Response response = e.getResponse()) {
if (Response.Status.NOT_FOUND.getStatusCode() == response.getStatus()) {
throw new BadRequestException(String.format("Credential not found by environment CRN: %s", envCrn), e);
}
String errorMessage = webApplicationExceptionMessageExtractor.getErrorMessage(e);
throw new CloudbreakServiceException(String.format("Failed to get credential: %s", errorMessage), e);
}
}
SecretResponse secretResponse = credentialResponse.getAttributes();
String attributes = secretService.getByResponse(secretResponse);
return new Credential(credentialResponse.getCloudPlatform(), credentialResponse.getName(), attributes, credentialResponse.getCrn(), credentialResponse.getAccountId());
}
Aggregations