Search in sources :

Example 6 with ResourceContainerCloud

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();
}
Also used : ResourceContainerCloud(org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud)

Example 7 with ResourceContainerCloud

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());
    }
}
Also used : ResourceContainerCloud(org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud) ComputeService(org.jclouds.compute.ComputeService) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 8 with ResourceContainerCloud

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;
}
Also used : ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) VMType(org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.VMType) ResourceContainerCloud(org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud) CostRepository(de.uka.ipd.sdq.pcm.cost.CostRepository)

Example 9 with ResourceContainerCloud

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

Example 10 with ResourceContainerCloud

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;
}
Also used : ResourceContainerCloud(org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud)

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