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
}
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();
}
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();
}
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);
}
}
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);
}
}
Aggregations