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