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);
}
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);
}
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.");
}
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;
}
Aggregations