use of org.jclouds.compute.options.TemplateOptions in project iobserve-analysis by research-iobserve.
the class AcquireActionScript method execute.
@Override
public void execute() throws RunNodesException {
final ResourceContainer container = this.action.getSourceResourceContainer();
final ResourceContainerCloud cloudContainer = this.getResourceContainerCloud(container);
final ComputeService client = this.getComputeServiceForContainer(cloudContainer);
final TemplateBuilder templateBuilder = client.templateBuilder();
final VMType instanceType = cloudContainer.getInstanceType();
templateBuilder.hardwareId(instanceType.getName());
templateBuilder.locationId(instanceType.getLocation());
// TODO maybe make this configurable
templateBuilder.osFamily(OsFamily.UBUNTU);
final Statement setupAdminInstructions = AdminAccess.standard();
// Necessary to set hostname to allow mapping for later events
final TemplateOptions options = Builder.runScript(setupAdminInstructions).runScript(AcquireActionScript.getChangeHostnameScript(cloudContainer)).runScript(this.getStartupScript());
templateBuilder.options(options);
final Template template = templateBuilder.build();
final String groupName = ModelHelper.getGroupName(cloudContainer);
final NodeMetadata node = Iterables.getOnlyElement(client.createNodesInGroup(groupName, 1, template));
AcquireActionScript.LOGGER.info(String.format("Acquired node for resource container '%s'. NodeID: %s, Hostname: %s, Adresses: %s", cloudContainer.getEntityName(), node.getId(), node.getHostname(), Iterables.concat(node.getPrivateAddresses(), node.getPublicAddresses())));
// TODO write resource container to original model to enable mapping
}
use of org.jclouds.compute.options.TemplateOptions in project fabric8 by jboss-fuse.
the class ToTemplate method apply.
public static Template apply(CreateJCloudsContainerOptions options) {
ComputeService service = options.getComputeService();
TemplateOptions templateOptions = service.templateOptions();
TemplateBuilder builder = service.templateBuilder().any();
applyInstanceType(builder, options);
applyImageType(builder, options);
applyLocation(builder, options);
applyProviderSpecificOptions(templateOptions, options);
Optional<AdminAccess> adminAccess = ToAdminAccess.apply(options);
if (adminAccess.isPresent()) {
templateOptions.runScript(adminAccess.get());
}
builder = builder.options(templateOptions);
return builder.build();
}
Aggregations