Search in sources :

Example 16 with Credential

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;
}
Also used : ExtendedCloudCredential(com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential) ExtendedCloudCredential(com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential) Credential(com.sequenceiq.freeipa.dto.Credential) CloudNetworks(com.sequenceiq.cloudbreak.cloud.model.CloudNetworks)

Example 17 with Credential

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());
}
Also used : Response(javax.ws.rs.core.Response) SecretResponse(com.sequenceiq.cloudbreak.service.secret.model.SecretResponse) CredentialResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse) SecretResponse(com.sequenceiq.cloudbreak.service.secret.model.SecretResponse) Credential(com.sequenceiq.freeipa.dto.Credential) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) ClientErrorException(javax.ws.rs.ClientErrorException) BadRequestException(javax.ws.rs.BadRequestException) CredentialResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse)

Aggregations

Credential (com.sequenceiq.freeipa.dto.Credential)17 Stack (com.sequenceiq.freeipa.entity.Stack)9 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)7 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)5 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)4 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)4 CredentialService (com.sequenceiq.freeipa.service.CredentialService)4 Optional (java.util.Optional)4 Collectors (java.util.stream.Collectors)4 Inject (javax.inject.Inject)4 CloudNetworks (com.sequenceiq.cloudbreak.cloud.model.CloudNetworks)3 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)3 ExtendedCloudCredential (com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential)3 Location (com.sequenceiq.cloudbreak.cloud.model.Location)3 MDCBuilder (com.sequenceiq.cloudbreak.logger.MDCBuilder)3 FlowParameters (com.sequenceiq.flow.core.FlowParameters)3 FreeIpaRecommendationResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.FreeIpaRecommendationResponse)3 VmTypeResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.VmTypeResponse)3 CredentialToCloudCredentialConverter (com.sequenceiq.freeipa.converter.cloud.CredentialToCloudCredentialConverter)3 ResourceToCloudResourceConverter (com.sequenceiq.freeipa.converter.cloud.ResourceToCloudResourceConverter)3