Search in sources :

Example 6 with LocationResourceTemplate

use of alien4cloud.model.orchestrators.locations.LocationResourceTemplate in project alien4cloud by alien4cloud.

the class LocationResourceServiceTest method getResourcesForUnconfiguredLocationShouldReturnEmptyList.

@Test
public void getResourcesForUnconfiguredLocationShouldReturnEmptyList() {
    ILocationResourceAccessor accessor = locationResourceService.accessor(UNCONFIGURED_LOCATION_ID);
    List<LocationResourceTemplate> resources = accessor.getResources();
    Assert.assertEquals(0, resources.size());
}
Also used : LocationResourceTemplate(alien4cloud.model.orchestrators.locations.LocationResourceTemplate) ILocationResourceAccessor(alien4cloud.orchestrators.plugin.ILocationResourceAccessor) Test(org.junit.Test)

Example 7 with LocationResourceTemplate

use of alien4cloud.model.orchestrators.locations.LocationResourceTemplate in project alien4cloud by alien4cloud.

the class LocationResourceServiceTest method getResourcesOfType.

@Test
public void getResourcesOfType() {
    ILocationResourceAccessor accessor = locationResourceService.accessor(LOCATION_ID);
    List<LocationResourceTemplate> resources = accessor.getResources(CONFIGURED_TYPE);
    Assert.assertEquals(TYPE_CONFIGURED_ELEMENTS, resources.size());
}
Also used : LocationResourceTemplate(alien4cloud.model.orchestrators.locations.LocationResourceTemplate) ILocationResourceAccessor(alien4cloud.orchestrators.plugin.ILocationResourceAccessor) Test(org.junit.Test)

Example 8 with LocationResourceTemplate

use of alien4cloud.model.orchestrators.locations.LocationResourceTemplate in project alien4cloud by alien4cloud.

the class LocationResourceService method addResourceTemplate.

private LocationResourceTemplate addResourceTemplate(Location location, String resourceName, String resourceTypeName) {
    NodeType resourceType = csarRepoSearchService.getRequiredElementInDependencies(NodeType.class, resourceTypeName, location.getDependencies());
    NodeTemplate nodeTemplate = templateBuilder.buildNodeTemplate(location.getDependencies(), resourceType);
    LocationResourceTemplate locationResourceTemplate = new LocationResourceTemplate();
    locationResourceTemplate.setGenerated(false);
    fillAndSaveLocationResourceTemplate(location, resourceName, locationResourceTemplate, resourceType, nodeTemplate);
    return locationResourceTemplate;
}
Also used : NodeTemplate(org.alien4cloud.tosca.model.templates.NodeTemplate) PolicyLocationResourceTemplate(alien4cloud.model.orchestrators.locations.PolicyLocationResourceTemplate) AbstractLocationResourceTemplate(alien4cloud.model.orchestrators.locations.AbstractLocationResourceTemplate) LocationResourceTemplate(alien4cloud.model.orchestrators.locations.LocationResourceTemplate) NodeType(org.alien4cloud.tosca.model.types.NodeType)

Example 9 with LocationResourceTemplate

use of alien4cloud.model.orchestrators.locations.LocationResourceTemplate in project alien4cloud by alien4cloud.

the class LocationResourceService method getLocationResourcesFromOrchestrator.

/*
     * (non-Javadoc)
     * 
     * @see
     * alien4cloud.orchestrators.locations.services.ILocationResourceService#getLocationResourcesFromOrchestrator(alien4cloud.model.orchestrators.locations.
     * Location)
     */
@Override
public LocationResources getLocationResourcesFromOrchestrator(Location location) {
    LocationResources locationResources = new LocationResources();
    Orchestrator orchestrator = orchestratorService.getOrFail(location.getOrchestratorId());
    IOrchestratorPlugin orchestratorInstance = orchestratorPluginService.getOrFail(orchestrator.getId());
    ILocationConfiguratorPlugin configuratorPlugin = orchestratorInstance.getConfigurator(location.getInfrastructureType());
    fillLocationResourceTypes(configuratorPlugin.getResourcesTypes(), locationResources, location.getDependencies());
    fillPoliciesLocationResourceTypes(configuratorPlugin.getPoliciesTypes(), locationResources, location.getDependencies());
    // add LocationResourceTemplate
    List<LocationResourceTemplate> locationResourceTemplates = getResourcesTemplates(location.getId());
    setLocationRessource(locationResourceTemplates, locationResources);
    // add PolicyLocationResourceTemplate
    locationResources.getPolicyTemplates().addAll(getPoliciesResourcesTemplates(location.getId()));
    return locationResources;
}
Also used : LocationResources(alien4cloud.model.orchestrators.locations.LocationResources) ILocationConfiguratorPlugin(alien4cloud.orchestrators.plugin.ILocationConfiguratorPlugin) PolicyLocationResourceTemplate(alien4cloud.model.orchestrators.locations.PolicyLocationResourceTemplate) AbstractLocationResourceTemplate(alien4cloud.model.orchestrators.locations.AbstractLocationResourceTemplate) LocationResourceTemplate(alien4cloud.model.orchestrators.locations.LocationResourceTemplate) Orchestrator(alien4cloud.model.orchestrators.Orchestrator) IOrchestratorPlugin(alien4cloud.orchestrators.plugin.IOrchestratorPlugin)

Example 10 with LocationResourceTemplate

use of alien4cloud.model.orchestrators.locations.LocationResourceTemplate in project alien4cloud by alien4cloud.

the class LocationResourceService method getLocationResources.

/*
     * (non-Javadoc)
     *
     * @see alien4cloud.orchestrators.locations.services.ILocationResourceService#getLocationResources(alien4cloud.model.orchestrators.locations.Location)
     */
@Override
public LocationResources getLocationResources(Location location) {
    Orchestrator orchestrator = orchestratorService.get(location.getOrchestratorId());
    Optional<LocationResources> locationResourcesFromOrchestrator = Optional.empty();
    if (orchestrator != null && orchestratorPluginService.get(orchestrator.getId()) != null) {
        locationResourcesFromOrchestrator = Optional.ofNullable(getLocationResourcesFromOrchestrator(location));
    }
    // Also get resource templates from outside of the orchestrator definition - eg custom resources
    List<LocationResourceTemplate> locationResourceTemplates = getResourcesTemplates(location.getId());
    LocationResources locationResources = new LocationResources(getLocationResourceTypes(locationResourceTemplates));
    // process policies types also
    List<PolicyLocationResourceTemplate> policyLocationResourceTemplates = getPoliciesResourcesTemplates(location.getId());
    locationResources.addFrom(getPoliciesLocationResourceTypes(policyLocationResourceTemplates));
    /*
         * If the orchestrator is present, take node types computed from the resources template
         * as "Custom resources types". If not, consider this is an orchestrator-free location.
         */
    locationResourcesFromOrchestrator.ifPresent(orchestratorResources -> {
        locationResources.getCapabilityTypes().putAll(orchestratorResources.getCapabilityTypes());
        locationResources.getConfigurationTypes().putAll(orchestratorResources.getConfigurationTypes());
        locationResources.getNodeTypes().putAll(orchestratorResources.getNodeTypes());
        locationResources.getProvidedTypes().addAll(orchestratorResources.getNodeTypes().keySet());
        locationResources.getAllNodeTypes().putAll(orchestratorResources.getAllNodeTypes());
        locationResources.getOnDemandTypes().putAll(orchestratorResources.getOnDemandTypes());
        locationResources.getPolicyTypes().putAll(orchestratorResources.getPolicyTypes());
    });
    setLocationRessource(locationResourceTemplates, locationResources);
    locationResources.getPolicyTemplates().addAll(policyLocationResourceTemplates);
    return locationResources;
}
Also used : LocationResources(alien4cloud.model.orchestrators.locations.LocationResources) PolicyLocationResourceTemplate(alien4cloud.model.orchestrators.locations.PolicyLocationResourceTemplate) AbstractLocationResourceTemplate(alien4cloud.model.orchestrators.locations.AbstractLocationResourceTemplate) LocationResourceTemplate(alien4cloud.model.orchestrators.locations.LocationResourceTemplate) Orchestrator(alien4cloud.model.orchestrators.Orchestrator) PolicyLocationResourceTemplate(alien4cloud.model.orchestrators.locations.PolicyLocationResourceTemplate)

Aggregations

LocationResourceTemplate (alien4cloud.model.orchestrators.locations.LocationResourceTemplate)27 NodeType (org.alien4cloud.tosca.model.types.NodeType)14 NodeTemplate (org.alien4cloud.tosca.model.templates.NodeTemplate)11 Test (org.junit.Test)11 MatchingConfiguration (alien4cloud.model.deployment.matching.MatchingConfiguration)6 PolicyLocationResourceTemplate (alien4cloud.model.orchestrators.locations.PolicyLocationResourceTemplate)6 ILocationResourceAccessor (alien4cloud.orchestrators.plugin.ILocationResourceAccessor)6 HashMap (java.util.HashMap)6 AbstractLocationResourceTemplate (alien4cloud.model.orchestrators.locations.AbstractLocationResourceTemplate)5 Location (alien4cloud.model.orchestrators.locations.Location)4 Orchestrator (alien4cloud.model.orchestrators.Orchestrator)3 LocationResources (alien4cloud.model.orchestrators.locations.LocationResources)3 CSARDependency (org.alien4cloud.tosca.model.CSARDependency)3 ServiceResource (alien4cloud.model.service.ServiceResource)2 ILocationConfiguratorPlugin (alien4cloud.orchestrators.plugin.ILocationConfiguratorPlugin)2 IOrchestratorPlugin (alien4cloud.orchestrators.plugin.IOrchestratorPlugin)2 List (java.util.List)2 CapabilityDefinition (org.alien4cloud.tosca.model.definitions.CapabilityDefinition)2 CapabilityType (org.alien4cloud.tosca.model.types.CapabilityType)2 DeploymentTopologyDTO (alien4cloud.deployment.DeploymentTopologyDTO)1