Search in sources :

Example 1 with VirtualMachinesResponse

use of com.sequenceiq.cloudbreak.api.model.VirtualMachinesResponse 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)

Aggregations

PlatformVmtypesResponse (com.sequenceiq.cloudbreak.api.model.PlatformVmtypesResponse)1 VirtualMachinesResponse (com.sequenceiq.cloudbreak.api.model.VirtualMachinesResponse)1 VmTypeJson (com.sequenceiq.cloudbreak.api.model.VmTypeJson)1 VmType (com.sequenceiq.cloudbreak.cloud.model.VmType)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1