// set instance type eg: m1.large
templateBuilder.hardwareId(iaas.getProperty("instanceType"));
}
// build the Template
Template template = templateBuilder.build();
// if you wish to auto assign IPs, instance spawning call should be
// blocking, but if you
// wish to assign IPs manually, it can be non-blocking.
// is auto-assign-ip mode or manual-assign-ip mode?
boolean blockUntilRunning = Boolean.parseBoolean(iaas
.getProperty("autoAssignIp"));
template.getOptions().as(TemplateOptions.class)
.blockUntilRunning(blockUntilRunning);
// this is required in order to avoid creation of additional security
// groups by jclouds.
template.getOptions().as(TemplateOptions.class)
.inboundPorts(new int[] {});
// set EC2 specific options
if (iaas.getProperty("subnetId") != null) {
template.getOptions().as(AWSEC2TemplateOptions.class)
.subnetId(iaas.getProperty("subnetId"));
}
if (iaas.getProperty("availabilityZone") != null) {
template.getOptions().as(AWSEC2TemplateOptions.class)
.placementGroup(iaas.getProperty("availabilityZone"));
}
if (iaas.getProperty("securityGroups") != null) {
template.getOptions()
.as(AWSEC2TemplateOptions.class)
.securityGroups(
iaas.getProperty("securityGroups").split(
CloudControllerConstants.ENTRY_SEPARATOR));
}
if (iaas.getProperty(CloudControllerConstants.PAYLOAD_FOLDER) != null) {
template.getOptions()
.as(AWSEC2TemplateOptions.class)
.userData(
ComputeServiceBuilderUtil.getUserData(CarbonUtils
.getCarbonHome()
+ File.separator
+ iaas.getProperty(CloudControllerConstants.PAYLOAD_FOLDER)));
}
if (iaas.getProperty("keyPair") != null) {
template.getOptions().as(AWSEC2TemplateOptions.class)
.keyPair(iaas.getProperty("keyPair"));
}
// set Template
iaas.setTemplate(template);