Search in sources :

Example 1 with TemplateOptions

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
}
Also used : NodeMetadata(org.jclouds.compute.domain.NodeMetadata) ResourceContainerCloud(org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud) VMType(org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.VMType) Statement(org.jclouds.scriptbuilder.domain.Statement) TemplateBuilder(org.jclouds.compute.domain.TemplateBuilder) TemplateOptions(org.jclouds.compute.options.TemplateOptions) ComputeService(org.jclouds.compute.ComputeService) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer) Template(org.jclouds.compute.domain.Template)

Example 2 with TemplateOptions

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();
}
Also used : TemplateBuilder(org.jclouds.compute.domain.TemplateBuilder) AdminAccess(org.jclouds.scriptbuilder.statements.login.AdminAccess) TemplateOptions(org.jclouds.compute.options.TemplateOptions) ComputeService(org.jclouds.compute.ComputeService)

Aggregations

ComputeService (org.jclouds.compute.ComputeService)2 TemplateBuilder (org.jclouds.compute.domain.TemplateBuilder)2 TemplateOptions (org.jclouds.compute.options.TemplateOptions)2 NodeMetadata (org.jclouds.compute.domain.NodeMetadata)1 Template (org.jclouds.compute.domain.Template)1 Statement (org.jclouds.scriptbuilder.domain.Statement)1 AdminAccess (org.jclouds.scriptbuilder.statements.login.AdminAccess)1 VMType (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.VMType)1 ResourceContainerCloud (org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud)1 ResourceContainer (org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)1