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