JcloudsLocationConfig.HARDWARE_ID,
JcloudsLocationConfig.MIN_RAM,
JcloudsLocationConfig.MIN_CORES,
JcloudsLocationConfig.MIN_DISK);
Map<String, Object> existingConfigOptions = location.getAllConfig(true);
TemplateBuilder template = (TemplateBuilder) flags.get(JcloudsLocationConfig.TEMPLATE_BUILDER.getName());
boolean overrideImageChoice = true;
for (ConfigKey<?> key : imageChoiceToRespect) {
if (existingConfigOptions.get(key.getName()) != null || flags.get(key.getName()) != null) {
overrideImageChoice = false;
break;
}
}
boolean overrideHardwareChoice = true;
for (ConfigKey<?> key : hardwareChoiceToRespect) {
if (existingConfigOptions.get(key.getName()) != null || flags.get(key.getName()) != null) {
overrideHardwareChoice = false;
break;
}
}
if (overrideImageChoice) {
LOG.debug("Customising image choice for {}", this);
template = new PortableTemplateBuilder();
if (isJcloudsLocation(location, GoogleComputeEngineConstants.GCE_PROVIDER_NAME)) {
template.osFamily(OsFamily.CENTOS).osVersionMatches("6");
} else {
template.osFamily(OsFamily.UBUNTU).osVersionMatches("12.04");
}
template.os64Bit(true);
flags.put(JcloudsLocationConfig.TEMPLATE_BUILDER.getName(), template);
} else {
LOG.debug("Not modifying existing image configuration for {}", this);
}
if (overrideHardwareChoice) {
LOG.debug("Customising hardware choice for {}", this);
if (template != null) {
template.minRam(2048);
} else {
flags.put(JcloudsLocationConfig.MIN_RAM.getName(), 2048);
}
} else {
LOG.debug("Not modifying existing hardware configuration for {}", this);