Search in sources :

Example 6 with ResourceContainer

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));
}
Also used : ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer) Test(org.junit.Test)

Example 7 with ResourceContainer

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());
        }
    }
}
Also used : AllocationContext(org.palladiosimulator.pcm.allocation.AllocationContext) AssemblyContext(org.palladiosimulator.pcm.core.composition.AssemblyContext) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 8 with ResourceContainer

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;
}
Also used : AcquireAction(org.iobserve.planning.systemadaptation.AcquireAction) ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) SystemadaptationFactory(org.iobserve.planning.systemadaptation.SystemadaptationFactory) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 9 with ResourceContainer

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;
}
Also used : ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 10 with ResourceContainer

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
}
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)

Aggregations

ResourceContainer (org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)35 ResourceEnvironment (org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment)16 LinkingResource (org.palladiosimulator.pcm.resourceenvironment.LinkingResource)8 Test (org.junit.Test)7 AllocationContext (org.palladiosimulator.pcm.allocation.AllocationContext)7 ResourceContainerCloud (org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud)6 ComputeService (org.jclouds.compute.ComputeService)5 Allocation (org.palladiosimulator.pcm.allocation.Allocation)5 AssemblyContext (org.palladiosimulator.pcm.core.composition.AssemblyContext)5 URL (java.net.URL)3 ContainerAllocationEvent (org.iobserve.common.record.ContainerAllocationEvent)3 UnknownObjectException (java.rmi.activation.UnknownObjectException)2 ArrayList (java.util.ArrayList)2 SystemadaptationFactory (org.iobserve.planning.systemadaptation.SystemadaptationFactory)2 ProcessingResourceSpecification (org.palladiosimulator.pcm.resourceenvironment.ProcessingResourceSpecification)2 System (org.palladiosimulator.pcm.system.System)2 File (java.io.File)1 URI (org.eclipse.emf.common.util.URI)1 DDiagramElement (org.eclipse.sirius.diagram.DDiagramElement)1 DEdge (org.eclipse.sirius.diagram.DEdge)1