Search in sources :

Example 1 with ResourceContainerCloud

use of org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud 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 ResourceContainerCloud

use of org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud in project iobserve-analysis by research-iobserve.

the class AcquireActionScript method getDescription.

@Override
public String getDescription() {
    final ResourceContainerCloud container = this.getResourceContainerCloud(this.action.getSourceResourceContainer());
    final StringBuilder builder = new StringBuilder();
    builder.append("Acquire Action: Acquire container from provider '");
    builder.append(container.getInstanceType().getProvider().getName());
    builder.append("' of type '");
    builder.append(container.getInstanceType());
    builder.append("' in location '");
    builder.append(container.getInstanceType().getLocation());
    builder.append('\'');
    return builder.toString();
}
Also used : ResourceContainerCloud(org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud)

Example 3 with ResourceContainerCloud

use of org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud in project iobserve-analysis by research-iobserve.

the class AllocateActionScript method getDescription.

@Override
public String getDescription() {
    final ResourceContainerCloud sourceContainer = this.getResourceContainerCloud(this.action.getNewAllocationContext().getResourceContainer_AllocationContext());
    final StringBuilder builder = new StringBuilder();
    builder.append("Allocate Action: Allocate assembly context '");
    builder.append(this.action.getSourceAssemblyContext().getEntityName());
    builder.append("' to container of provider '");
    builder.append(sourceContainer.getInstanceType().getProvider().getName());
    builder.append("' of type '");
    builder.append(sourceContainer.getInstanceType());
    builder.append("' in location '");
    builder.append(sourceContainer.getInstanceType().getLocation());
    builder.append("' with name '");
    builder.append(ModelHelper.getGroupName(sourceContainer));
    builder.append('\'');
    return builder.toString();
}
Also used : ResourceContainerCloud(org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud)

Example 4 with ResourceContainerCloud

use of org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud in project iobserve-analysis by research-iobserve.

the class DeallocateActionScript method execute.

@Override
public void execute() throws RunScriptOnNodesException, IOException {
    final ResourceContainer container = this.action.getOldAllocationContext().getResourceContainer_AllocationContext();
    final ResourceContainerCloud cloudContainer = this.getResourceContainerCloud(container);
    final ComputeService client = this.getComputeServiceForContainer(cloudContainer);
    final String assemblyContextName = this.action.getSourceAssemblyContext().getEntityName();
    // nothing
    if (!this.data.getDeallocatedContexts().contains(assemblyContextName)) {
        client.runScriptOnNodesMatching(node -> node.getGroup().equals(cloudContainer.getGroupName()), this.getDeallocateScript(this.action.getSourceAssemblyContext()));
        this.data.getDeallocatedContexts().add(assemblyContextName);
    }
}
Also used : ResourceContainerCloud(org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud) ComputeService(org.jclouds.compute.ComputeService) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 5 with ResourceContainerCloud

use of org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud in project iobserve-analysis by research-iobserve.

the class MigrateActionScript method execute.

@Override
public void execute() throws RunScriptOnNodesException {
    final ResourceContainer sourceContainer = this.action.getSourceAllocationContext().getResourceContainer_AllocationContext();
    final ResourceContainer targetContainer = this.action.getNewAllocationContext().getResourceContainer_AllocationContext();
    final ResourceContainerCloud sourceCloudContainer = this.getResourceContainerCloud(sourceContainer);
    final ResourceContainerCloud targetCloudContainer = this.getResourceContainerCloud(targetContainer);
    final ComputeService client = this.getComputeServiceForContainer(sourceCloudContainer);
    final String assemblyContextName = this.action.getSourceAssemblyContext().getEntityName();
    // If the assembly context has already been migrated, do nothing
    if (!this.data.getMigratedContexts().contains(assemblyContextName)) {
        client.runScriptOnNodesMatching(node -> node.getGroup().equals(sourceCloudContainer.getGroupName()), this.getScript(AdaptationData.PRE_MIGRATE_SCRIPT_NAME, this.action.getSourceAssemblyContext()));
        client.runScriptOnNodesMatching(node -> node.getGroup().equals(targetCloudContainer.getGroupName()), this.getScript(AdaptationData.POST_MIGRATE_SCRIPT_NAME, this.action.getSourceAssemblyContext()));
        // TODO add possibility to open up ports defined in a config file
        this.data.getMigratedContexts().add(assemblyContextName);
    }
}
Also used : ResourceContainerCloud(org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud) ComputeService(org.jclouds.compute.ComputeService) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Aggregations

ResourceContainerCloud (org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud)21 VMType (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.VMType)6 ResourceContainer (org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)6 ComputeService (org.jclouds.compute.ComputeService)5 ResourceEnvironment (org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment)4 CostRepository (de.uka.ipd.sdq.pcm.cost.CostRepository)3 LinkingResource (org.palladiosimulator.pcm.resourceenvironment.LinkingResource)3 ProcessingResourceSpecification (org.palladiosimulator.pcm.resourceenvironment.ProcessingResourceSpecification)2 NodeMetadata (org.jclouds.compute.domain.NodeMetadata)1 Template (org.jclouds.compute.domain.Template)1 TemplateBuilder (org.jclouds.compute.domain.TemplateBuilder)1 TemplateOptions (org.jclouds.compute.options.TemplateOptions)1 Statement (org.jclouds.scriptbuilder.domain.Statement)1 CloudProfile (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudProfile)1 CloudProvider (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudProvider)1 CloudResourceType (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudResourceType)1