Search in sources :

Example 1 with ConfigSpecification

use of com.sequenceiq.cloudbreak.cloud.model.ConfigSpecification in project cloudbreak by hortonworks.

the class AwsPlatformResources method readVmTypes.

private void readVmTypes() {
    Map<String, VmType> vmTypeMap = new TreeMap<>();
    String vm = getDefinition(awsVmParameterDefinitionPath, "vm");
    String zoneVms = getDefinition(awsVmParameterDefinitionPath, "zone-vm");
    try {
        VmsSpecification oVms = JsonUtil.readValue(vm, VmsSpecification.class);
        for (VmSpecification vmSpecification : oVms.getItems()) {
            VmTypeMetaBuilder builder = VmTypeMetaBuilder.builder().withCpuAndMemory(vmSpecification.getMetaSpecification().getProperties().getCpu(), vmSpecification.getMetaSpecification().getProperties().getMemory()).withPrice(vmSpecification.getMetaSpecification().getProperties().getPrice());
            for (ConfigSpecification configSpecification : vmSpecification.getMetaSpecification().getConfigSpecification()) {
                addConfig(builder, configSpecification);
            }
            VmTypeMeta vmTypeMeta = builder.create();
            vmTypeMap.put(vmSpecification.getValue(), VmType.vmTypeWithMeta(vmSpecification.getValue(), vmTypeMeta, vmSpecification.getExtended()));
        }
        ZoneVmSpecifications zoneVmSpecifications = JsonUtil.readValue(zoneVms, ZoneVmSpecifications.class);
        for (ZoneVmSpecification zvs : zoneVmSpecifications.getItems()) {
            Set<VmType> regionVmTypes = new HashSet<>();
            for (String vmTypeString : zvs.getVmTypes()) {
                VmType vmType = vmTypeMap.get(vmTypeString);
                if (vmType != null) {
                    regionVmTypes.add(vmType);
                }
            }
            vmTypes.put(region(zvs.getZone()), regionVmTypes);
            VmType vmType = vmTypeMap.get(zvs.getDefaultVmType());
            if (vmType != null) {
                defaultVmTypes.put(region(zvs.getZone()), vmType);
            }
        }
    } catch (IOException e) {
        LOGGER.error("Cannot initialize platform parameters for aws", e);
    }
}
Also used : VmTypeMeta(com.sequenceiq.cloudbreak.cloud.model.VmTypeMeta) VmSpecification(com.sequenceiq.cloudbreak.cloud.model.VmSpecification) ZoneVmSpecification(com.sequenceiq.cloudbreak.cloud.model.ZoneVmSpecification) IOException(java.io.IOException) TreeMap(java.util.TreeMap) VmsSpecification(com.sequenceiq.cloudbreak.cloud.model.VmsSpecification) VmType(com.sequenceiq.cloudbreak.cloud.model.VmType) VmTypeMetaBuilder(com.sequenceiq.cloudbreak.cloud.model.VmTypeMeta.VmTypeMetaBuilder) ConfigSpecification(com.sequenceiq.cloudbreak.cloud.model.ConfigSpecification) ZoneVmSpecifications(com.sequenceiq.cloudbreak.cloud.model.ZoneVmSpecifications) ZoneVmSpecification(com.sequenceiq.cloudbreak.cloud.model.ZoneVmSpecification) HashSet(java.util.HashSet)

Aggregations

ConfigSpecification (com.sequenceiq.cloudbreak.cloud.model.ConfigSpecification)1 VmSpecification (com.sequenceiq.cloudbreak.cloud.model.VmSpecification)1 VmType (com.sequenceiq.cloudbreak.cloud.model.VmType)1 VmTypeMeta (com.sequenceiq.cloudbreak.cloud.model.VmTypeMeta)1 VmTypeMetaBuilder (com.sequenceiq.cloudbreak.cloud.model.VmTypeMeta.VmTypeMetaBuilder)1 VmsSpecification (com.sequenceiq.cloudbreak.cloud.model.VmsSpecification)1 ZoneVmSpecification (com.sequenceiq.cloudbreak.cloud.model.ZoneVmSpecification)1 ZoneVmSpecifications (com.sequenceiq.cloudbreak.cloud.model.ZoneVmSpecifications)1 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 TreeMap (java.util.TreeMap)1