Search in sources :

Example 1 with VMType

use of org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.VMType in project iobserve-analysis by research-iobserve.

the class AcquireActionScript method execute.

@Override
public void execute() throws RunNodesException {
    final ResourceContainer container = this.action.getSourceResourceContainer();
    final ResourceContainerCloud cloudContainer = this.getResourceContainerCloud(container);
    final ComputeService client = this.getComputeServiceForContainer(cloudContainer);
    final TemplateBuilder templateBuilder = client.templateBuilder();
    final VMType instanceType = cloudContainer.getInstanceType();
    templateBuilder.hardwareId(instanceType.getName());
    templateBuilder.locationId(instanceType.getLocation());
    // TODO maybe make this configurable
    templateBuilder.osFamily(OsFamily.UBUNTU);
    final Statement setupAdminInstructions = AdminAccess.standard();
    // Necessary to set hostname to allow mapping for later events
    final TemplateOptions options = Builder.runScript(setupAdminInstructions).runScript(AcquireActionScript.getChangeHostnameScript(cloudContainer)).runScript(this.getStartupScript());
    templateBuilder.options(options);
    final Template template = templateBuilder.build();
    final String groupName = ModelHelper.getGroupName(cloudContainer);
    final NodeMetadata node = Iterables.getOnlyElement(client.createNodesInGroup(groupName, 1, template));
    AcquireActionScript.LOGGER.info(String.format("Acquired node for resource container '%s'. NodeID: %s, Hostname: %s, Adresses: %s", cloudContainer.getEntityName(), node.getId(), node.getHostname(), Iterables.concat(node.getPrivateAddresses(), node.getPublicAddresses())));
// TODO write resource container to original model to enable mapping
}
Also used : NodeMetadata(org.jclouds.compute.domain.NodeMetadata) ResourceContainerCloud(org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud) VMType(org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.VMType) Statement(org.jclouds.scriptbuilder.domain.Statement) TemplateBuilder(org.jclouds.compute.domain.TemplateBuilder) TemplateOptions(org.jclouds.compute.options.TemplateOptions) ComputeService(org.jclouds.compute.ComputeService) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer) Template(org.jclouds.compute.domain.Template)

Example 2 with VMType

use of org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.VMType 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 3 with VMType

use of org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.VMType 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;
}
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 4 with VMType

use of org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.VMType 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)

Example 5 with VMType

use of org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.VMType in project iobserve-analysis by research-iobserve.

the class ModelHelper method fillResourceEnvironmentFromCloudProfile.

/**
 * Creates resource containers and their associated costs from the cloud profile given in the
 * model provider.
 *
 * The created resource containers are of the type {@link ResourceContainerCloud} and are
 * connected via an Internet linking resource
 * ({@link #getInternetLinkingResource(ResourceEnvironment)}. For every vm type in the cloud
 * profile, this method creates one resource container representing an instance of this specific
 * vm type. The model is saved after the creation of containers is completed.
 *
 * @param writeURI
 *            location where all files are stored
 * @param modelHandler
 *            the model providers with an initialized resource environment, cost model and cloud
 *            profile
 * @throws ModelHandlingErrorException
 *             model handling issue
 */
public static void fillResourceEnvironmentFromCloudProfile(final org.eclipse.emf.common.util.URI writeURI, final PCMModelHandler modelHandler) throws ModelHandlingErrorException {
    final ResourceEnvironment environment = modelHandler.getResourceEnvironmentModel();
    final CloudProfile cloudProfileModel = modelHandler.getCloudProfileModel();
    final CostRepository costRepositoryModel = modelHandler.getCostModel();
    for (final CloudProvider provider : cloudProfileModel.getCloudProviders()) {
        for (final CloudResourceType cloudResource : provider.getCloudResources()) {
            if (cloudResource instanceof VMType) {
                final VMType cloudVM = (VMType) cloudResource;
                ModelHelper.createResourceContainerFromVMType(environment, costRepositoryModel, cloudVM, cloudVM.getName());
            }
        }
    }
    new ResourceEnvironmentModelHandler().save(writeURI.appendFileExtension(PCMModelHandler.RESOURCE_ENVIRONMENT_SUFFIX), environment);
    new CostModelHandler().save(writeURI.appendFileExtension(PCMModelHandler.COST_SUFFIX), costRepositoryModel);
}
Also used : CloudProfile(org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudProfile) ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) CloudResourceType(org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudResourceType) VMType(org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.VMType) CostRepository(de.uka.ipd.sdq.pcm.cost.CostRepository) CostModelHandler(org.iobserve.model.provider.file.CostModelHandler) CloudProvider(org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudProvider) ResourceEnvironmentModelHandler(org.iobserve.model.provider.file.ResourceEnvironmentModelHandler)

Aggregations

VMType (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.VMType)8 ResourceContainerCloud (org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud)6 CostRepository (de.uka.ipd.sdq.pcm.cost.CostRepository)5 ResourceEnvironment (org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment)5 CloudProfile (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudProfile)3 CloudProvider (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudProvider)3 CloudResourceType (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudResourceType)3 CostModelHandler (org.iobserve.model.provider.file.CostModelHandler)2 ResourceEnvironmentModelHandler (org.iobserve.model.provider.file.ResourceEnvironmentModelHandler)2 ComputeService (org.jclouds.compute.ComputeService)1 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 ResourceContainer (org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)1