Search in sources :

Example 1 with PlatformResourceRequest

use of com.sequenceiq.cloudbreak.domain.PlatformResourceRequest in project cloudbreak by hortonworks.

the class PlatformResourceRequestJsonToPlatformResourceRequest method convert.

@Override
public PlatformResourceRequest convert(PlatformResourceRequestJson source) {
    PlatformResourceRequest platformResourceRequest = new PlatformResourceRequest();
    if (!Strings.isNullOrEmpty(source.getCredentialName())) {
        platformResourceRequest.setCredential(credentialService.get(source.getCredentialName(), source.getAccount()));
    } else if (source.getCredentialId() != null) {
        platformResourceRequest.setCredential(credentialService.get(source.getCredentialId()));
    } else {
        throw new BadRequestException("The credentialId or the credentialName must be specified in the request");
    }
    if (!Strings.isNullOrEmpty(source.getPlatformVariant())) {
        platformResourceRequest.setCloudPlatform(platformResourceRequest.getCredential().cloudPlatform());
    } else {
        platformResourceRequest.setPlatformVariant(Strings.isNullOrEmpty(source.getPlatformVariant()) ? platformResourceRequest.getCredential().cloudPlatform() : source.getPlatformVariant());
    }
    platformResourceRequest.setFilters(source.getFilters());
    platformResourceRequest.setRegion(source.getRegion());
    platformResourceRequest.setCloudPlatform(platformResourceRequest.getCredential().cloudPlatform());
    if (!Strings.isNullOrEmpty(source.getAvailabilityZone())) {
        platformResourceRequest.setAvailabilityZone(source.getAvailabilityZone());
    }
    return platformResourceRequest;
}
Also used : BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException) PlatformResourceRequest(com.sequenceiq.cloudbreak.domain.PlatformResourceRequest)

Example 2 with PlatformResourceRequest

use of com.sequenceiq.cloudbreak.domain.PlatformResourceRequest in project cloudbreak by hortonworks.

the class PlatformParameterV1Controller method getCloudSshKeys.

@Override
public PlatformSshKeysResponse getCloudSshKeys(PlatformResourceRequestJson resourceRequestJson) {
    resourceRequestJson = prepareAccountAndOwner(resourceRequestJson, authenticatedUserService.getCbUser());
    PlatformResourceRequest convert = conversionService.convert(resourceRequestJson, PlatformResourceRequest.class);
    CloudSshKeys cloudSshKeys = cloudParameterService.getCloudSshKeys(convert.getCredential(), convert.getRegion(), convert.getPlatformVariant(), convert.getFilters());
    return conversionService.convert(cloudSshKeys, PlatformSshKeysResponse.class);
}
Also used : CloudSshKeys(com.sequenceiq.cloudbreak.cloud.model.CloudSshKeys) PlatformResourceRequest(com.sequenceiq.cloudbreak.domain.PlatformResourceRequest)

Example 3 with PlatformResourceRequest

use of com.sequenceiq.cloudbreak.domain.PlatformResourceRequest in project cloudbreak by hortonworks.

the class PlatformParameterV1Controller method getGatewaysCredentialId.

@Override
public PlatformGatewaysResponse getGatewaysCredentialId(PlatformResourceRequestJson resourceRequestJson) {
    resourceRequestJson = prepareAccountAndOwner(resourceRequestJson, authenticatedUserService.getCbUser());
    PlatformResourceRequest convert = conversionService.convert(resourceRequestJson, PlatformResourceRequest.class);
    CloudGateWays cloudGateWays = cloudParameterService.getGateways(convert.getCredential(), convert.getRegion(), convert.getPlatformVariant(), convert.getFilters());
    return conversionService.convert(cloudGateWays, PlatformGatewaysResponse.class);
}
Also used : CloudGateWays(com.sequenceiq.cloudbreak.cloud.model.CloudGateWays) PlatformResourceRequest(com.sequenceiq.cloudbreak.domain.PlatformResourceRequest)

Example 4 with PlatformResourceRequest

use of com.sequenceiq.cloudbreak.domain.PlatformResourceRequest in project cloudbreak by hortonworks.

the class PlatformParameterV1Controller method getCloudNetworks.

@Override
public PlatformNetworksResponse getCloudNetworks(PlatformResourceRequestJson resourceRequestJson) {
    resourceRequestJson = prepareAccountAndOwner(resourceRequestJson, authenticatedUserService.getCbUser());
    PlatformResourceRequest convert = conversionService.convert(resourceRequestJson, PlatformResourceRequest.class);
    CloudNetworks cloudNetworks = cloudParameterService.getCloudNetworks(convert.getCredential(), convert.getRegion(), convert.getPlatformVariant(), convert.getFilters());
    return conversionService.convert(cloudNetworks, PlatformNetworksResponse.class);
}
Also used : CloudNetworks(com.sequenceiq.cloudbreak.cloud.model.CloudNetworks) PlatformResourceRequest(com.sequenceiq.cloudbreak.domain.PlatformResourceRequest)

Example 5 with PlatformResourceRequest

use of com.sequenceiq.cloudbreak.domain.PlatformResourceRequest in project cloudbreak by hortonworks.

the class PlatformParameterV1Controller method createRecommendation.

@Override
public RecommendationResponse createRecommendation(RecommendationRequestJson recommendationRequestJson) {
    IdentityUser cbUser = authenticatedUserService.getCbUser();
    PlatformResourceRequest resourceRequest = conversionService.convert(recommendationRequestJson, PlatformResourceRequest.class);
    if (recommendationRequestJson.getBlueprintId() == null && Strings.isNullOrEmpty(recommendationRequestJson.getBlueprintName())) {
        fieldIsNotEmpty(recommendationRequestJson.getBlueprintId(), "blueprintId");
    }
    fieldIsNotEmpty(resourceRequest.getRegion(), "region");
    fieldIsNotEmpty(resourceRequest.getAvailabilityZone(), "availabilityZone");
    PlatformRecommendation recommendedVms = cloudResourceAdvisor.createForBlueprint(recommendationRequestJson.getBlueprintName(), recommendationRequestJson.getBlueprintId(), resourceRequest, cbUser);
    return conversionService.convert(recommendedVms, RecommendationResponse.class);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) PlatformRecommendation(com.sequenceiq.cloudbreak.cloud.model.PlatformRecommendation) PlatformResourceRequest(com.sequenceiq.cloudbreak.domain.PlatformResourceRequest)

Aggregations

PlatformResourceRequest (com.sequenceiq.cloudbreak.domain.PlatformResourceRequest)10 CloudAccessConfigs (com.sequenceiq.cloudbreak.cloud.model.CloudAccessConfigs)1 CloudGateWays (com.sequenceiq.cloudbreak.cloud.model.CloudGateWays)1 CloudIpPools (com.sequenceiq.cloudbreak.cloud.model.CloudIpPools)1 CloudNetworks (com.sequenceiq.cloudbreak.cloud.model.CloudNetworks)1 CloudRegions (com.sequenceiq.cloudbreak.cloud.model.CloudRegions)1 CloudSecurityGroups (com.sequenceiq.cloudbreak.cloud.model.CloudSecurityGroups)1 CloudSshKeys (com.sequenceiq.cloudbreak.cloud.model.CloudSshKeys)1 CloudVmTypes (com.sequenceiq.cloudbreak.cloud.model.CloudVmTypes)1 PlatformRecommendation (com.sequenceiq.cloudbreak.cloud.model.PlatformRecommendation)1 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)1 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)1