Search in sources :

Example 1 with CostRepository

use of de.uka.ipd.sdq.pcm.cost.CostRepository 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 2 with CostRepository

use of de.uka.ipd.sdq.pcm.cost.CostRepository in project iobserve-analysis by research-iobserve.

the class CostModelFactory method createCostRepository.

/**
 * Create a new cost repository with the given interest rate and the specified time period.
 *
 * @param interest
 *            the interest rate
 * @param timePeriodYears
 *            the time period in years
 * @return the new cost repository
 */
public static CostRepository createCostRepository(final double interest, final int timePeriodYears) {
    final CostRepository repository = costFactory.eINSTANCE.createCostRepository();
    repository.setInterest(interest);
    repository.setTimePeriodYears(timePeriodYears);
    return repository;
}
Also used : CostRepository(de.uka.ipd.sdq.pcm.cost.CostRepository)

Example 3 with CostRepository

use of de.uka.ipd.sdq.pcm.cost.CostRepository 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 CostRepository

use of de.uka.ipd.sdq.pcm.cost.CostRepository 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)

Example 5 with CostRepository

use of de.uka.ipd.sdq.pcm.cost.CostRepository 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 error
 */
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

CostRepository (de.uka.ipd.sdq.pcm.cost.CostRepository)6 VMType (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.VMType)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 ResourceContainerCloud (org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud)3 CostModelHandler (org.iobserve.model.provider.file.CostModelHandler)2 ResourceEnvironmentModelHandler (org.iobserve.model.provider.file.ResourceEnvironmentModelHandler)2