Search in sources :

Example 16 with ResourceContainerCloud

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

the class AbstractActionScript method getResourceContainerCloud.

/**
 * Checks whether the given resource container is a cloud container and returns it as such.
 *
 * @param container
 *            the container to check
 * @return the cloud resource container
 * @throws IllegalArgumentException
 *             if the container was not a valid cloud container
 */
protected ResourceContainerCloud getResourceContainerCloud(final ResourceContainer container) throws IllegalArgumentException {
    if (!(container instanceof ResourceContainerCloud)) {
        final String error = String.format("ResourceContainer '%s' was not a cloud container, therefore no action is possible on it!", container.getEntityName());
        AbstractActionScript.LOG.error(error);
        throw new IllegalArgumentException(error);
    }
    final ResourceContainerCloud cloudContainer = (ResourceContainerCloud) container;
    return cloudContainer;
}
Also used : ResourceContainerCloud(org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud)

Example 17 with ResourceContainerCloud

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

the class AllocateActionScript method execute.

@Override
public void execute() throws RunScriptOnNodesException, IOException {
    final ResourceContainer container = this.action.getNewAllocationContext().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.getAllocatedContexts().contains(assemblyContextName)) {
        client.runScriptOnNodesMatching(node -> node.getGroup().equals(cloudContainer.getGroupName()), this.getAllocateScript(this.action.getSourceAssemblyContext()));
        this.data.getAllocatedContexts().add(assemblyContextName);
    // TODO add possibility to open up ports defined in a config file
    }
}
Also used : ResourceContainerCloud(org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud) ComputeService(org.jclouds.compute.ComputeService) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 18 with ResourceContainerCloud

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

the class DeallocateActionScript method getDescription.

@Override
public String getDescription() {
    final ResourceContainerCloud sourceContainer = this.getResourceContainerCloud(this.action.getOldAllocationContext().getResourceContainer_AllocationContext());
    final StringBuilder builder = new StringBuilder();
    builder.append("Deallocate Action: Deallocate assembly context '");
    builder.append(this.action.getSourceAssemblyContext().getEntityName());
    builder.append("' from 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 19 with ResourceContainerCloud

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

the class ModelHelper method createResourceContainerFromVMType.

/**
 * Creates a new resource container from a specific {@link VMType}, including an entry in the
 * cost repository.
 *
 * @param environment
 *            the resource environment in which to create the container
 * @param costRepository
 *            the cost repository in which to create the costs for the container
 * @param cloudVM
 *            the type of vm this container is an instance of
 * @param containerName
 *            the name of this container
 * @return the newly created resource container
 * @throws ModelHandlingErrorException
 *             model handling error
 */
public static ResourceContainerCloud createResourceContainerFromVMType(final ResourceEnvironment environment, final CostRepository costRepository, final VMType cloudVM, final String containerName) throws ModelHandlingErrorException {
    final ResourceContainerCloud container = ResourceEnvironmentCloudFactory.createResourceContainer(environment, containerName);
    container.setId(EcoreUtil.generateUUID());
    container.setResourceEnvironment_ResourceContainer(environment);
    container.setInstanceType(cloudVM);
    // Connect container to internet
    final LinkingResource linkingResource = ModelHelper.getInternetLinkingResource(environment);
    linkingResource.getConnectedResourceContainers_LinkingResource().add(container);
    final int nrOfCores = ModelHelper.getNrOfCores(cloudVM);
    final float processingRate = ModelHelper.getProcessingRate(cloudVM);
    // Create processing resource and costs
    final ProcessingResourceSpecification processor = ResourceEnvironmentCloudFactory.createProcessingResource(nrOfCores, processingRate, container);
    container.getActiveResourceSpecifications_ResourceContainer().add(processor);
    // TODO HDD is not used by peropteryx?
    CostModelFactory.createFixedProcessingResourceCost(costRepository, 0.0, cloudVM.getPricePerHour(), processor);
    return container;
}
Also used : ResourceContainerCloud(org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud) LinkingResource(org.palladiosimulator.pcm.resourceenvironment.LinkingResource) ProcessingResourceSpecification(org.palladiosimulator.pcm.resourceenvironment.ProcessingResourceSpecification)

Example 20 with ResourceContainerCloud

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

the class ModelHelper method getResourceContainerIdentifier.

/**
 * Returns the identifier for a resource container.
 *
 * If the resource container is a cloud container, the returned identifier contains the
 * provider, location and the type of this container. For other containers, the entity name is
 * returned.
 *
 * @param allocationContainer
 *            the container for which to retrieve the identifier
 * @return the identifier
 */
public static String getResourceContainerIdentifier(final ResourceContainer allocationContainer) {
    String identifier = "";
    if (allocationContainer instanceof ResourceContainerCloud) {
        final ResourceContainerCloud cloudContainer = (ResourceContainerCloud) allocationContainer;
        final VMType type = cloudContainer.getInstanceType();
        identifier = String.format("%s_%s_%s", type.getProvider().getName(), type.getLocation(), type.getName());
    } else {
        identifier = allocationContainer.getEntityName();
    }
    return identifier;
}
Also used : ResourceContainerCloud(org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud) VMType(org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.VMType)

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