Search in sources :

Example 1 with VmTypeJson

use of com.sequenceiq.cloudbreak.api.model.VmTypeJson in project cloudbreak by hortonworks.

the class CloudVmTypesToPlatformVmTypesResponseConverter method convert.

@Override
public PlatformVmtypesResponse convert(CloudVmTypes source) {
    Map<String, VirtualMachinesResponse> result = new HashMap<>();
    for (Entry<String, Set<VmType>> entry : source.getCloudVmResponses().entrySet()) {
        Set<VmTypeJson> vmTypeJsons = new HashSet<>();
        for (VmType vmType : entry.getValue()) {
            vmTypeJsons.add(getConversionService().convert(vmType, VmTypeJson.class));
        }
        VmTypeJson defaultVmType = getConversionService().convert(source.getDefaultCloudVmResponses().get(entry.getKey()), VmTypeJson.class);
        VirtualMachinesResponse virtualMachinesResponse = new VirtualMachinesResponse();
        virtualMachinesResponse.setDefaultVirtualMachine(defaultVmType);
        virtualMachinesResponse.setVirtualMachines(vmTypeJsons);
        result.put(entry.getKey(), virtualMachinesResponse);
    }
    return new PlatformVmtypesResponse(result);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) VirtualMachinesResponse(com.sequenceiq.cloudbreak.api.model.VirtualMachinesResponse) VmType(com.sequenceiq.cloudbreak.cloud.model.VmType) PlatformVmtypesResponse(com.sequenceiq.cloudbreak.api.model.PlatformVmtypesResponse) VmTypeJson(com.sequenceiq.cloudbreak.api.model.VmTypeJson) HashSet(java.util.HashSet)

Example 2 with VmTypeJson

use of com.sequenceiq.cloudbreak.api.model.VmTypeJson in project cloudbreak by hortonworks.

the class PlatformRecommendationToPlatformRecommendationResponseConverter method convert.

@Override
public RecommendationResponse convert(PlatformRecommendation source) {
    Map<String, VmTypeJson> result = new HashMap<>();
    source.getRecommendations().forEach((hostGroupName, vm) -> result.put(hostGroupName, getConversionService().convert(vm, VmTypeJson.class)));
    Set<VmTypeJson> vmTypes = source.getVirtualMachines().stream().map(vmType -> getConversionService().convert(vmType, VmTypeJson.class)).collect(Collectors.toSet());
    Set<DiskResponse> diskResponses = new HashSet<>();
    for (Entry<DiskType, DisplayName> diskTypeDisplayName : source.getDiskTypes().displayNames().entrySet()) {
        for (Entry<String, VolumeParameterType> volumeParameterType : source.getDiskTypes().diskMapping().entrySet()) {
            if (diskTypeDisplayName.getKey().value().equals(volumeParameterType.getKey())) {
                DiskResponse diskResponse = new DiskResponse(diskTypeDisplayName.getKey().value(), volumeParameterType.getValue().name(), diskTypeDisplayName.getValue().value());
                diskResponses.add(diskResponse);
            }
        }
    }
    return new RecommendationResponse(result, vmTypes, diskResponses);
}
Also used : DisplayName(com.sequenceiq.cloudbreak.cloud.model.DisplayName) PlatformRecommendation(com.sequenceiq.cloudbreak.cloud.model.PlatformRecommendation) DiskType(com.sequenceiq.cloudbreak.cloud.model.DiskType) Set(java.util.Set) HashMap(java.util.HashMap) RecommendationResponse(com.sequenceiq.cloudbreak.api.model.RecommendationResponse) Collectors(java.util.stream.Collectors) DiskResponse(com.sequenceiq.cloudbreak.api.model.DiskResponse) HashSet(java.util.HashSet) Component(org.springframework.stereotype.Component) VolumeParameterType(com.sequenceiq.cloudbreak.cloud.model.VolumeParameterType) Map(java.util.Map) Entry(java.util.Map.Entry) VmTypeJson(com.sequenceiq.cloudbreak.api.model.VmTypeJson) HashMap(java.util.HashMap) VolumeParameterType(com.sequenceiq.cloudbreak.cloud.model.VolumeParameterType) VmTypeJson(com.sequenceiq.cloudbreak.api.model.VmTypeJson) DiskType(com.sequenceiq.cloudbreak.cloud.model.DiskType) RecommendationResponse(com.sequenceiq.cloudbreak.api.model.RecommendationResponse) DiskResponse(com.sequenceiq.cloudbreak.api.model.DiskResponse) DisplayName(com.sequenceiq.cloudbreak.cloud.model.DisplayName) HashSet(java.util.HashSet)

Example 3 with VmTypeJson

use of com.sequenceiq.cloudbreak.api.model.VmTypeJson in project cloudbreak by hortonworks.

the class VmTypeTests method testListAzureVMTypesForCredentialInDefaultRegion.

@Test(priority = 5, groups = "vmtypes")
public void testListAzureVMTypesForCredentialInDefaultRegion() throws Exception {
    AzureCloudProvider provider = new AzureCloudProvider(getTestParameter());
    given(CloudbreakClient.isCreated());
    given(provider.aValidCredential().withName(AZURE_CRED_NAME), "Azure credential is created");
    given(VmType.request().withPlatform(provider.getPlatform()).withRegion(provider.region()).withAvailabilityZone(provider.availabilityZone()), "Azure vm type request");
    when(VmType.getPlatformVmTypes(), "vm types are requested to Azure credential and " + provider.region() + " region.");
    then(VmType.assertThis((vmtype, t) -> {
        Set<VmTypeJson> regionVirtualMachines = vmtype.getResponse().getVmTypes().get(provider.region()).getVirtualMachines();
        Assert.assertFalse(regionVirtualMachines.isEmpty(), "Azure Virtual Machines should be present in response for default region!");
    }), "Virtual Machines should be part of the response.");
}
Also used : CloudProvider(com.sequenceiq.it.cloudbreak.newway.cloud.CloudProvider) TestParameter(com.sequenceiq.it.cloudbreak.newway.TestParameter) Logger(org.slf4j.Logger) ForbiddenException(javax.ws.rs.ForbiddenException) CloudbreakClient(com.sequenceiq.it.cloudbreak.newway.CloudbreakClient) AwsCloudProvider(com.sequenceiq.it.cloudbreak.newway.cloud.AwsCloudProvider) LoggerFactory(org.slf4j.LoggerFactory) Set(java.util.Set) Test(org.testng.annotations.Test) Credential(com.sequenceiq.it.cloudbreak.newway.Credential) GcpCloudProvider(com.sequenceiq.it.cloudbreak.newway.cloud.GcpCloudProvider) VmType(com.sequenceiq.it.cloudbreak.newway.VmType) AfterTest(org.testng.annotations.AfterTest) Assert(org.testng.Assert) AzureCloudProvider(com.sequenceiq.it.cloudbreak.newway.cloud.AzureCloudProvider) BadRequestException(javax.ws.rs.BadRequestException) CloudbreakTest(com.sequenceiq.it.cloudbreak.newway.CloudbreakTest) OpenstackCloudProvider(com.sequenceiq.it.cloudbreak.newway.cloud.OpenstackCloudProvider) VmTypeJson(com.sequenceiq.cloudbreak.api.model.VmTypeJson) Set(java.util.Set) AzureCloudProvider(com.sequenceiq.it.cloudbreak.newway.cloud.AzureCloudProvider) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest) CloudbreakTest(com.sequenceiq.it.cloudbreak.newway.CloudbreakTest)

Example 4 with VmTypeJson

use of com.sequenceiq.cloudbreak.api.model.VmTypeJson in project cloudbreak by hortonworks.

the class VmTypeToVmTypeJsonConverter method convert.

@Override
public VmTypeJson convert(VmType source) {
    VmTypeJson vmTypeJson = new VmTypeJson();
    if (source != null) {
        List<VolumeParameterConfigJson> configs = new ArrayList<>();
        convertVolumeConfig(configs, source.getMetaData().getAutoAttachedConfig());
        convertVolumeConfig(configs, source.getMetaData().getEphemeralConfig());
        convertVolumeConfig(configs, source.getMetaData().getMagneticConfig());
        convertVolumeConfig(configs, source.getMetaData().getSsdConfig());
        convertVolumeConfig(configs, source.getMetaData().getSt1Config());
        VmTypeMetaJson vmTypeMetaJson = new VmTypeMetaJson();
        vmTypeMetaJson.setProperties(source.getMetaData().getProperties());
        vmTypeMetaJson.setConfigs(configs);
        vmTypeJson.setVmTypeMetaJson(vmTypeMetaJson);
        vmTypeJson.setValue(source.value());
    }
    return vmTypeJson;
}
Also used : VmTypeMetaJson(com.sequenceiq.cloudbreak.api.model.VmTypeMetaJson) VolumeParameterConfigJson(com.sequenceiq.cloudbreak.api.model.VolumeParameterConfigJson) ArrayList(java.util.ArrayList) VmTypeJson(com.sequenceiq.cloudbreak.api.model.VmTypeJson)

Aggregations

VmTypeJson (com.sequenceiq.cloudbreak.api.model.VmTypeJson)4 Set (java.util.Set)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 DiskResponse (com.sequenceiq.cloudbreak.api.model.DiskResponse)1 PlatformVmtypesResponse (com.sequenceiq.cloudbreak.api.model.PlatformVmtypesResponse)1 RecommendationResponse (com.sequenceiq.cloudbreak.api.model.RecommendationResponse)1 VirtualMachinesResponse (com.sequenceiq.cloudbreak.api.model.VirtualMachinesResponse)1 VmTypeMetaJson (com.sequenceiq.cloudbreak.api.model.VmTypeMetaJson)1 VolumeParameterConfigJson (com.sequenceiq.cloudbreak.api.model.VolumeParameterConfigJson)1 DiskType (com.sequenceiq.cloudbreak.cloud.model.DiskType)1 DisplayName (com.sequenceiq.cloudbreak.cloud.model.DisplayName)1 PlatformRecommendation (com.sequenceiq.cloudbreak.cloud.model.PlatformRecommendation)1 VmType (com.sequenceiq.cloudbreak.cloud.model.VmType)1 VolumeParameterType (com.sequenceiq.cloudbreak.cloud.model.VolumeParameterType)1 CloudbreakClient (com.sequenceiq.it.cloudbreak.newway.CloudbreakClient)1 CloudbreakTest (com.sequenceiq.it.cloudbreak.newway.CloudbreakTest)1 Credential (com.sequenceiq.it.cloudbreak.newway.Credential)1 TestParameter (com.sequenceiq.it.cloudbreak.newway.TestParameter)1 VmType (com.sequenceiq.it.cloudbreak.newway.VmType)1