use of org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud in project iobserve-analysis by research-iobserve.
the class ReplicateActionScript method getDescription.
@Override
public String getDescription() {
final ResourceContainerCloud sourceContainer = this.getResourceContainerCloud(this.action.getSourceResourceContainer());
final ResourceContainerCloud targetContainer = this.getResourceContainerCloud(this.action.getNewResourceContainer());
final StringBuilder builder = new StringBuilder();
builder.append("Replicate Action: Replicate container from 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(" to container from provider '");
builder.append(targetContainer.getInstanceType().getProvider().getName());
builder.append("' of type '");
builder.append(targetContainer.getInstanceType());
builder.append("' in location '");
builder.append(targetContainer.getInstanceType().getLocation());
builder.append("' with name '");
builder.append(ModelHelper.getGroupName(targetContainer));
return builder.toString();
}
use of org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud in project iobserve-analysis by research-iobserve.
the class TerminateActionScript method getDescription.
@Override
public String getDescription() {
final ResourceContainerCloud container = this.getResourceContainerCloud(this.action.getSourceResourceContainer());
final StringBuilder builder = new StringBuilder();
builder.append("Terminate Action: Terminate container group 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("' with name '");
builder.append(ModelHelper.getGroupName(container));
return builder.toString();
}
use of org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud in project iobserve-analysis by research-iobserve.
the class ModelHelper method getResourceContainerFromHostname.
/**
* Creates a cloud container from the given hostname with the information provided by the model
* providers in the resource environment provided by the model providers.
*
* If the hostname is not a valid cloud container hostname or if no matching VMType could be
* found, the method returns null.
*
* @param modelProviders
* the model providers to use
* @param hostname
* the hostname to convert
* @return the new cloud container or null in case of a problem
* @throws ModelHandlingErrorException
* modeling handlign issue
*/
public static ResourceContainerCloud getResourceContainerFromHostname(final PCMModelHandler modelProviders, final String hostname) throws ModelHandlingErrorException {
final String[] nameParts = hostname.split("_");
VMType vmType = null;
// ContainerId_AllocationGroupName_ProviderName_Location_InstanceType
if (nameParts.length == 5) {
final String groupName = nameParts[1];
final String providerName = nameParts[2];
final String location = nameParts[3];
final String instanceType = nameParts[4];
vmType = ModelHelper.getVMType(modelProviders.getCloudProfileModel(), providerName, location, instanceType);
if (vmType != null) {
final ResourceEnvironment environment = modelProviders.getResourceEnvironmentModel();
final CostRepository costRepository = modelProviders.getCostModel();
final ResourceContainerCloud cloudContainer = ModelHelper.createResourceContainerFromVMType(environment, costRepository, vmType, hostname);
cloudContainer.setGroupName(groupName);
return cloudContainer;
}
}
return null;
}
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;
}
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
* when something when wrong with the model handling
*/
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;
}
Aggregations