use of org.palladiosimulator.pcm.resourceenvironment.ResourceContainer in project iobserve-analysis by research-iobserve.
the class ResourceEnvironmentModelProviderTest method createThenReadContaining.
@Override
@Test
public void createThenReadContaining() {
final ModelProvider<ResourceEnvironment> modelProvider = new ModelProvider<>(ResourceEnvironmentModelProviderTest.graph);
final ResourceEnvironment writtenModel = new TestModelBuilder().getResourceEnvironment();
final ResourceContainer writtenContainer = writtenModel.getResourceContainer_ResourceEnvironment().get(0);
final ResourceEnvironment readModel;
modelProvider.createComponent(writtenModel);
readModel = (ResourceEnvironment) modelProvider.readOnlyContainingComponentById(ResourceContainer.class, writtenContainer.getId());
Assert.assertTrue(this.equalityHelper.equals(writtenModel, readModel));
}
use of org.palladiosimulator.pcm.resourceenvironment.ResourceContainer in project iobserve-analysis by research-iobserve.
the class GraphFactory method extractAllocations.
private void extractAllocations(final Allocation allocationModel) {
final EList<AllocationContext> allocationContexts = allocationModel.getAllocationContexts_Allocation();
for (final AllocationContext allocationContext : allocationContexts) {
final ResourceContainer resContainer = allocationContext.getResourceContainer_AllocationContext();
final AssemblyContext assemblyContext = allocationContext.getAssemblyContext_AllocationContext();
this.assemblyID2allocID.put(assemblyContext.getId(), allocationContext.getId());
boolean correctIDs = true;
final String resContainerID = resContainer.getId();
if (!this.resourceContainers.containsKey(resContainerID)) {
if (GraphFactory.LOGGER.isErrorEnabled()) {
GraphFactory.LOGGER.error("A unknown ResourceContainer (ID: " + resContainer.getId() + ") was found during allocation context analysis.\n");
}
correctIDs = false;
}
final String assemblyContextID = assemblyContext.getId();
if (!this.assemblyContexts.containsKey(assemblyContextID)) {
if (GraphFactory.LOGGER.isErrorEnabled()) {
GraphFactory.LOGGER.error("An unknown AssemblyContext (ID: " + assemblyContext.getId() + ") was found during allocation context analysis.\n");
}
correctIDs = false;
}
if (correctIDs) {
this.ac2rcMap.put(assemblyContext.getId(), resContainer.getId());
}
}
}
use of org.palladiosimulator.pcm.resourceenvironment.ResourceContainer in project iobserve-analysis by research-iobserve.
the class ResourceContainerActionFactory method createAcquireAction.
/**
* Create a acquire action.
*
* @param reDeploymentServer
* the node where components can be deployed on
* @return the action
*/
public static AcquireAction createAcquireAction(final DeploymentNode reDeploymentServer) {
final SystemadaptationFactory factory = SystemadaptationFactory.eINSTANCE;
final AcquireAction action = factory.createAcquireAction();
final ResourceEnvironment reDeplResEnvModel = ActionFactory.getRedeploymentModels().getResourceEnvironmentModel();
final ResourceContainer resourceContainer = ActionFactory.getResourceContainer(reDeploymentServer.getResourceContainerID(), reDeplResEnvModel);
action.setSourceResourceContainer(resourceContainer);
return action;
}
use of org.palladiosimulator.pcm.resourceenvironment.ResourceContainer in project iobserve-analysis by research-iobserve.
the class ResourceContainerActionFactory method setSourceResourceContainer.
private static ResourceContainerAction setSourceResourceContainer(final ResourceContainerAction action, final String resourceContainerID) {
final ResourceEnvironment resEnvModel = ActionFactory.getRuntimeModels().getResourceEnvironmentModel();
final ResourceContainer resourceContainer = ActionFactory.getResourceContainer(resourceContainerID, resEnvModel);
action.setSourceResourceContainer(resourceContainer);
return action;
}
use of org.palladiosimulator.pcm.resourceenvironment.ResourceContainer 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
}
Aggregations