use of org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud in project iobserve-analysis by research-iobserve.
the class MigrateActionScript method getDescription.
@Override
public String getDescription() {
final ResourceContainerCloud sourceContainer = this.getResourceContainerCloud(this.action.getSourceAllocationContext().getResourceContainer_AllocationContext());
final ResourceContainerCloud targetContainer = this.getResourceContainerCloud(this.action.getNewAllocationContext().getResourceContainer_AllocationContext());
final StringBuilder builder = new StringBuilder();
builder.append("Migrate Action: Migrate 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(" 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 execute.
@Override
public void execute() throws RunScriptOnNodesException {
final ResourceContainer container = this.action.getSourceResourceContainer();
final ResourceContainerCloud cloudContainer = this.getResourceContainerCloud(container);
final ComputeService client = this.getComputeServiceForContainer(cloudContainer);
// If the container group has already been terminated, do nothing
if (!this.data.getTerminatedGroups().contains(ModelHelper.getGroupName(cloudContainer))) {
client.runScriptOnNodesMatching(node -> node.getGroup().equals(cloudContainer.getGroupName()), this.getScript(AdaptationData.NODE_PRE_TERMINATE_SCRIPT_NAME));
client.destroyNodesMatching(node -> node.getGroup().equals(cloudContainer.getGroupName()));
this.data.getTerminatedGroups().add(cloudContainer.getGroupName());
}
}
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
* model handling error
*/
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 ModelTransformer method clearCloudResourcesFromResourceEnv.
private void clearCloudResourcesFromResourceEnv() {
final ResourceEnvironment environment = this.resourceEnvironmentModel;
final List<ResourceContainer> resourceContainers = environment.getResourceContainer_ResourceEnvironment();
for (final Iterator<ResourceContainer> iter = resourceContainers.iterator(); iter.hasNext(); ) {
final ResourceContainer container = iter.next();
if (container instanceof ResourceContainerCloud) {
iter.remove();
}
}
final LinkingResource linkingResource = ModelHelper.getInternetLinkingResource(environment);
linkingResource.getConnectedResourceContainers_LinkingResource().clear();
}
use of org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud in project iobserve-analysis by research-iobserve.
the class ResourceEnvironmentCloudFactory method createResourceContainer.
/**
* Create a {@link ResourceContainerCloud} with the given name, without checking if it already
* exists.
*
* @param model
* resource environment model
* @param name
* name of the new container
* @return builder
*/
public static ResourceContainerCloud createResourceContainer(final ResourceEnvironment model, final String name) {
final ResourceContainerCloud resContainer = ResourceenvironmentcloudFactory.eINSTANCE.createResourceContainerCloud();
resContainer.setEntityName(name);
model.getResourceContainer_ResourceEnvironment().add(resContainer);
return resContainer;
}
Aggregations