Search in sources :

Example 1 with CloudProvider

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

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

the class AbstractActionScript method getComputeServiceForContainer.

/**
 * Returns a compute service client to use for further queries to the cloud provider.
 *
 * @param container
 *            the resource container for which to get the compute service
 * @return the corresponding compute service
 */
protected ComputeService getComputeServiceForContainer(final ResourceContainerCloud container) {
    final CloudProvider provider = container.getInstanceType().getProvider();
    final ComputeServiceContext context = ContextBuilder.newBuilder(provider.getName()).credentials(provider.getIdentity(), provider.getCredential()).modules(// NOCS
    ImmutableSet.<Module>of(new SLF4JLoggingModule(), new SshjSshClientModule())).buildView(ComputeServiceContext.class);
    final ComputeService client = context.getComputeService();
    return client;
}
Also used : SLF4JLoggingModule(org.jclouds.logging.slf4j.config.SLF4JLoggingModule) CloudProvider(org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudProvider) SshjSshClientModule(org.jclouds.sshj.config.SshjSshClientModule) ComputeServiceContext(org.jclouds.compute.ComputeServiceContext) Module(com.google.inject.Module) SLF4JLoggingModule(org.jclouds.logging.slf4j.config.SLF4JLoggingModule) SshjSshClientModule(org.jclouds.sshj.config.SshjSshClientModule) ComputeService(org.jclouds.compute.ComputeService)

Example 3 with CloudProvider

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

Example 4 with CloudProvider

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

the class ModelTransformer method createResourcesAndReplicationDegrees.

private void createResourcesAndReplicationDegrees(final AllocationGroup allocationGroup) throws ModelHandlingErrorException {
    final CloudProfile profile = this.cloudProfileModel;
    final ResourceEnvironment environment = this.resourceEnvironmentModel;
    final CostRepository costs = this.costModel;
    // Get resource container that represents the instances this allocation
    // group is currently deployed on
    final ResourceContainerCloud representingContainer = allocationGroup.getRepresentingResourceContainer();
    if (representingContainer == null) {
        throw new IllegalArgumentException(String.format("Could not find a cloud container for allocation group '%s'. Check your model.", allocationGroup.getName()));
    }
    // Set group name of the representing container and add it to the
    // resource environment
    representingContainer.setGroupName(allocationGroup.getName());
    representingContainer.setEntityName(allocationGroup.getName());
    ModelHelper.addResourceContainerToEnvironment(environment, representingContainer);
    final int nrOfCurrentReplicas = allocationGroup.getAllocationContexts().size();
    // Upper bound for number of replicas for one resource
    // container type should be sufficiently high
    final int toNrOfReplicas = (nrOfCurrentReplicas + PlanningData.POSSIBLE_REPLICAS_OFFSET) * PlanningData.POSSIBLE_REPLICAS_FACTOR;
    // representing container create only replication degree
    for (final CloudProvider provider : profile.getCloudProviders()) {
        for (final CloudResourceType cloudResource : provider.getCloudResources()) {
            if (cloudResource instanceof VMType) {
                final VMType cloudVM = (VMType) cloudResource;
                final String degreeName;
                final ResourceContainerCloud createdContainer;
                if (this.isSameVMType(cloudVM, representingContainer)) {
                    createdContainer = representingContainer;
                    degreeName = String.format("%s_ReplicationDegree", allocationGroup.getName());
                } else {
                    final String containerName = AllocationGroup.getAllocationGroupName(allocationGroup.getComponentName(), ModelHelper.getResourceContainerIdentifier(cloudVM));
                    createdContainer = ModelHelper.createResourceContainerFromVMType(environment, costs, cloudVM, containerName);
                    degreeName = String.format("%s_ReplicationDegree", containerName);
                }
                DesignDecisionModelFactory.createReplicationDegree(this.decisionSpace, degreeName, createdContainer, 1, toNrOfReplicas);
            }
        }
    }
}
Also used : CloudProfile(org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudProfile) ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) CloudResourceType(org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudResourceType) ResourceContainerCloud(org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud) VMType(org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.VMType) CostRepository(de.uka.ipd.sdq.pcm.cost.CostRepository) CloudProvider(org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudProvider)

Aggregations

CloudProvider (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudProvider)4 CostRepository (de.uka.ipd.sdq.pcm.cost.CostRepository)3 CloudProfile (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudProfile)3 CloudResourceType (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.CloudResourceType)3 VMType (org.palladiosimulator.pcm.cloud.pcmcloud.cloudprofile.VMType)3 ResourceEnvironment (org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment)3 CostModelHandler (org.iobserve.model.provider.file.CostModelHandler)2 ResourceEnvironmentModelHandler (org.iobserve.model.provider.file.ResourceEnvironmentModelHandler)2 Module (com.google.inject.Module)1 ComputeService (org.jclouds.compute.ComputeService)1 ComputeServiceContext (org.jclouds.compute.ComputeServiceContext)1 SLF4JLoggingModule (org.jclouds.logging.slf4j.config.SLF4JLoggingModule)1 SshjSshClientModule (org.jclouds.sshj.config.SshjSshClientModule)1 ResourceContainerCloud (org.palladiosimulator.pcm.cloud.pcmcloud.resourceenvironmentcloud.ResourceContainerCloud)1