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;
}
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;
}
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;
}
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);
}
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);
}
Aggregations