Search in sources :

Example 21 with LocationResourceTemplate

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

the class DefaultNodeMatcherTest method setUp.

@Before
public void setUp() throws Exception {
    this.nodeMatcher = new DefaultNodeMatcher();
    this.computeNodeType = nodeType("org.alien4cloud.nodes.mock.aws.Compute", "tosca.nodes.Compute");
    this.computeNodeTemplate = nodeTemplate("org.alien4cloud.nodes.mock.aws.Compute");
    NodeType mongoDbNodeType = nodeType("alien.service.MongoDB", "", "tosca.service.ServiceType", "test.nodes.DB");
    NodeTemplate mongoDbNodeTemplate = nodeTemplate("alien.service.MongoDB");
    LocationResourceTemplate mongoDbLocationTemplate = locationResourceTemplate(mongoDbNodeTemplate);
    mongoDbLocationTemplate.setService(true);
    locationResources = new LocationResources();
    // 
    locationResources.setNodeTemplates(// 
    Arrays.asList(// 
    locationResourceTemplate(computeNodeTemplate), // 
    mongoDbLocationTemplate));
    // 
    locationResources.setNodeTypes(// 
    ImmutableMap.of(// 
    computeNodeType.getElementId(), // 
    computeNodeType, // 
    mongoDbNodeType.getElementId(), // 
    mongoDbNodeType));
}
Also used : NodeTemplate(org.alien4cloud.tosca.model.templates.NodeTemplate) LocationResources(alien4cloud.model.orchestrators.locations.LocationResources) LocationResourceTemplate(alien4cloud.model.orchestrators.locations.LocationResourceTemplate) NodeType(org.alien4cloud.tosca.model.types.NodeType) Before(org.junit.Before)

Example 22 with LocationResourceTemplate

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

the class DefaultNodeMatcherTest method abstract_template_should_be_matched_if_service_is_available.

@Test
public void abstract_template_should_be_matched_if_service_is_available() throws Exception {
    // Given
    Map<String, MatchingConfiguration> emptyMatchingConfigurations = new HashMap<>();
    // When
    NodeTemplate wantedNodeTemplate = nodeTemplate("test.nodes.DB");
    NodeType wantedNodeType = new NodeType();
    wantedNodeType.setAbstract(true);
    List<LocationResourceTemplate> proposition = nodeMatcher.matchNode(wantedNodeTemplate, wantedNodeType, locationResources, emptyMatchingConfigurations);
    // Then
    assertThat(proposition).hasSize(1);
    assertThat(proposition.get(0).isService()).isTrue();
}
Also used : NodeTemplate(org.alien4cloud.tosca.model.templates.NodeTemplate) LocationResourceTemplate(alien4cloud.model.orchestrators.locations.LocationResourceTemplate) HashMap(java.util.HashMap) MatchingConfiguration(alien4cloud.model.deployment.matching.MatchingConfiguration) NodeType(org.alien4cloud.tosca.model.types.NodeType) Test(org.junit.Test)

Example 23 with LocationResourceTemplate

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

the class DefaultNodeMatcherTest method locationResourceTemplate.

private LocationResourceTemplate locationResourceTemplate(NodeTemplate nodeTemplate) {
    LocationResourceTemplate locationResourceTemplate = new LocationResourceTemplate();
    locationResourceTemplate.setTemplate(nodeTemplate);
    return locationResourceTemplate;
}
Also used : LocationResourceTemplate(alien4cloud.model.orchestrators.locations.LocationResourceTemplate)

Example 24 with LocationResourceTemplate

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

the class LocationResourceServiceTest method getResourcesOfTypeForUnconfiguredTypeShouldReturnEmptyList.

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

Example 25 with LocationResourceTemplate

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

the class LocationResourceServiceTest method initLocation.

private void initLocation(String locationId) {
    Location location = new Location();
    location.setId(LOCATION_ID);
    alienDAO.save(location);
    location.setId(UNCONFIGURED_LOCATION_ID);
    alienDAO.save(location);
    for (int i = 0; i < 5; i++) {
        for (int j = 0; j < TYPE_CONFIGURED_ELEMENTS; j++) {
            String type = i == 0 ? CONFIGURED_TYPE : CONFIGURED_TYPE + "." + i;
            NodeTemplate template = new NodeTemplate();
            template.setType(type);
            template.setName("template_" + i + "_" + j);
            LocationResourceTemplate lrt = new LocationResourceTemplate();
            lrt.setId(UUID.randomUUID().toString());
            lrt.setLocationId(locationId);
            lrt.setGenerated(false);
            lrt.setEnabled(true);
            lrt.setService(false);
            lrt.setTemplate(template);
            lrt.setTypes(Lists.newArrayList(template.getType()));
            alienDAO.save(lrt);
        }
    }
}
Also used : NodeTemplate(org.alien4cloud.tosca.model.templates.NodeTemplate) LocationResourceTemplate(alien4cloud.model.orchestrators.locations.LocationResourceTemplate) Location(alien4cloud.model.orchestrators.locations.Location)

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