Search in sources :

Example 1 with PlatformVmtypesResponse

use of com.sequenceiq.environment.api.v1.platformresource.model.PlatformVmtypesResponse in project cloudbreak by hortonworks.

the class CredentialPlatformResourceController method getVmTypesByCredential.

@Override
@CustomPermissionCheck
public PlatformVmtypesResponse getVmTypesByCredential(String credentialName, String credentialCrn, String region, String platformVariant, String availabilityZone, CdpResourceType cdpResourceType) {
    customCheckUtil.run(() -> permissionCheckByCredential(credentialName, credentialCrn));
    String accountId = getAccountId();
    PlatformResourceRequest request = platformParameterService.getPlatformResourceRequest(accountId, credentialName, credentialCrn, region, platformVariant, availabilityZone, null, new HashMap<>(), null, cdpResourceType);
    LOGGER.info("Get /platform_resources/machine_types, request: {}", request);
    CloudVmTypes cloudVmTypes = platformParameterService.getVmTypesByCredential(request);
    PlatformVmtypesResponse response = cloudVmTypesToPlatformVmTypesV1ResponseConverter.convert(cloudVmTypes);
    LOGGER.info("Resp /platform_resources/machine_types, request: {}, cloudVmTypes: {}, response: {}", request, cloudVmTypes, response);
    return response;
}
Also used : CloudVmTypes(com.sequenceiq.cloudbreak.cloud.model.CloudVmTypes) PlatformVmtypesResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformVmtypesResponse) PlatformResourceRequest(com.sequenceiq.environment.platformresource.PlatformResourceRequest) CustomPermissionCheck(com.sequenceiq.authorization.annotation.CustomPermissionCheck)

Example 2 with PlatformVmtypesResponse

use of com.sequenceiq.environment.api.v1.platformresource.model.PlatformVmtypesResponse in project cloudbreak by hortonworks.

the class SdxRecommendationServiceTest method createPlatformVmtypesResponse.

private PlatformVmtypesResponse createPlatformVmtypesResponse() {
    Map<String, VirtualMachinesResponse> vmTypes = new HashMap<>();
    VirtualMachinesResponse virtualMachinesResponse = new VirtualMachinesResponse();
    Set<VmTypeResponse> virtualMachines = new HashSet<>();
    virtualMachines.add(new VmTypeResponse("large", createVmTypeMetaJson(10, 1000.0F)));
    virtualMachines.add(new VmTypeResponse("medium", createVmTypeMetaJson(8, 800.0F)));
    virtualMachines.add(new VmTypeResponse("mediumv2", createVmTypeMetaJson(8, 1000.0F)));
    virtualMachines.add(new VmTypeResponse("small", createVmTypeMetaJson(2, 200.0F)));
    virtualMachinesResponse.setVirtualMachines(virtualMachines);
    vmTypes.put("eu-central-1", virtualMachinesResponse);
    return new PlatformVmtypesResponse(vmTypes);
}
Also used : VmTypeResponse(com.sequenceiq.environment.api.v1.platformresource.model.VmTypeResponse) HashMap(java.util.HashMap) VirtualMachinesResponse(com.sequenceiq.environment.api.v1.platformresource.model.VirtualMachinesResponse) PlatformVmtypesResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformVmtypesResponse) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) HashSet(java.util.HashSet)

Example 3 with PlatformVmtypesResponse

use of com.sequenceiq.environment.api.v1.platformresource.model.PlatformVmtypesResponse in project cloudbreak by hortonworks.

the class SdxRecommendationService method getAvailableVmTypes.

private List<VmTypeResponse> getAvailableVmTypes(String credentialCrn, String cloudPlatform, String region, String availabilityZone) {
    PlatformVmtypesResponse platformVmtypesResponse = environmentClientService.getVmTypesByCredential(credentialCrn, region, cloudPlatform, CdpResourceType.DATALAKE, availabilityZone);
    Set<com.sequenceiq.environment.api.v1.platformresource.model.VmTypeResponse> vmTypes = Collections.emptySet();
    if (platformVmtypesResponse.getVmTypes() != null && StringUtils.isNotBlank(availabilityZone)) {
        vmTypes = platformVmtypesResponse.getVmTypes().get(availabilityZone).getVirtualMachines();
    } else if (platformVmtypesResponse.getVmTypes() != null && !platformVmtypesResponse.getVmTypes().isEmpty()) {
        vmTypes = platformVmtypesResponse.getVmTypes().values().iterator().next().getVirtualMachines();
    }
    return vmTypeConverter.convert(vmTypes);
}
Also used : VmTypeResponse(com.sequenceiq.sdx.api.model.VmTypeResponse) PlatformVmtypesResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformVmtypesResponse)

Example 4 with PlatformVmtypesResponse

use of com.sequenceiq.environment.api.v1.platformresource.model.PlatformVmtypesResponse in project cloudbreak by hortonworks.

the class EnvironmentPlatformResourceController method getVmTypesByCredential.

@Override
@CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_ENVIRONMENT)
public PlatformVmtypesResponse getVmTypesByCredential(@ResourceCrn String environmentCrn, String region, String platformVariant, String availabilityZone, CdpResourceType cdpResourceType) {
    String accountId = getAccountId();
    validateEnvironmentCrnPattern(environmentCrn);
    PlatformResourceRequest request = platformParameterService.getPlatformResourceRequestByEnvironment(accountId, environmentCrn, region, platformVariant, availabilityZone, null, null, cdpResourceType);
    LOGGER.info("Get /platform_resources/machine_types, request: {}", request);
    CloudVmTypes cloudVmTypes = platformParameterService.getVmTypesByCredential(request);
    PlatformVmtypesResponse response = cloudVmTypesToPlatformVmTypesV1ResponseConverter.convert(cloudVmTypes);
    LOGGER.info("Resp /platform_resources/machine_types, request: {}, cloudVmTypes: {}, response: {}", request, cloudVmTypes, response);
    return response;
}
Also used : CloudVmTypes(com.sequenceiq.cloudbreak.cloud.model.CloudVmTypes) PlatformVmtypesResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformVmtypesResponse) PlatformResourceRequest(com.sequenceiq.environment.platformresource.PlatformResourceRequest) CheckPermissionByResourceCrn(com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)

Example 5 with PlatformVmtypesResponse

use of com.sequenceiq.environment.api.v1.platformresource.model.PlatformVmtypesResponse in project cloudbreak by hortonworks.

the class CloudVmTypesToPlatformVmTypesV1ResponseConverter method convert.

public PlatformVmtypesResponse convert(CloudVmTypes source) {
    Map<String, VirtualMachinesResponse> result = new HashMap<>();
    for (Entry<String, Set<VmType>> entry : source.getCloudVmResponses().entrySet()) {
        Set<VmTypeResponse> vmTypeRespons = new HashSet<>();
        for (VmType vmType : entry.getValue()) {
            vmTypeRespons.add(vmTypeToVmTypeV1ResponseConverter.convert(vmType));
        }
        VirtualMachinesResponse virtualMachinesResponse = new VirtualMachinesResponse();
        VmType defaultVmType = source.getDefaultCloudVmResponses().get(entry.getKey());
        if (defaultVmType != null) {
            virtualMachinesResponse.setDefaultVirtualMachine(vmTypeToVmTypeV1ResponseConverter.convert(defaultVmType));
        }
        virtualMachinesResponse.setVirtualMachines(vmTypeRespons);
        result.put(entry.getKey(), virtualMachinesResponse);
    }
    return new PlatformVmtypesResponse(result);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) VmTypeResponse(com.sequenceiq.environment.api.v1.platformresource.model.VmTypeResponse) HashMap(java.util.HashMap) VirtualMachinesResponse(com.sequenceiq.environment.api.v1.platformresource.model.VirtualMachinesResponse) VmType(com.sequenceiq.cloudbreak.cloud.model.VmType) PlatformVmtypesResponse(com.sequenceiq.environment.api.v1.platformresource.model.PlatformVmtypesResponse) HashSet(java.util.HashSet)

Aggregations

PlatformVmtypesResponse (com.sequenceiq.environment.api.v1.platformresource.model.PlatformVmtypesResponse)5 CloudVmTypes (com.sequenceiq.cloudbreak.cloud.model.CloudVmTypes)2 VirtualMachinesResponse (com.sequenceiq.environment.api.v1.platformresource.model.VirtualMachinesResponse)2 VmTypeResponse (com.sequenceiq.environment.api.v1.platformresource.model.VmTypeResponse)2 PlatformResourceRequest (com.sequenceiq.environment.platformresource.PlatformResourceRequest)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 CheckPermissionByResourceCrn (com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)1 CustomPermissionCheck (com.sequenceiq.authorization.annotation.CustomPermissionCheck)1 VmType (com.sequenceiq.cloudbreak.cloud.model.VmType)1 VmTypeResponse (com.sequenceiq.sdx.api.model.VmTypeResponse)1 Set (java.util.Set)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1