use of alien4cloud.model.deployment.matching.MatchingConfiguration in project yorc-a4c-plugin by ystia.
the class AbstractLocationConfigurer method getMatchingConfigurations.
public Map<String, MatchingConfiguration> getMatchingConfigurations(String matchingConfigRelativePath) {
Path matchingConfigPath = selfContext.getPluginPath().resolve(matchingConfigRelativePath);
MatchingConfigurations matchingConfigurations = null;
try {
matchingConfigurations = matchingConfigurationsParser.parseFile(matchingConfigPath).getResult();
} catch (ParsingException e) {
return Maps.newHashMap();
}
Map<String, MatchingConfiguration> ret = matchingConfigurations.getMatchingConfigurations();
printMatchingConfigurations(ret);
return ret;
}
use of alien4cloud.model.deployment.matching.MatchingConfiguration in project alien4cloud by alien4cloud.
the class DefaultNodeMatcherTest method unknown_type_from_topology_should_not_match_any_location_resource.
@Test
public void unknown_type_from_topology_should_not_match_any_location_resource() throws Exception {
// Given
Map<String, MatchingConfiguration> emptyMatchingConfigurations = new HashMap<>();
// When
NodeTemplate wantedNodeTemplate = nodeTemplate("tosca.nodes.Unknown");
NodeType wantedNodeType = new NodeType();
List<LocationResourceTemplate> proposition = nodeMatcher.matchNode(wantedNodeTemplate, wantedNodeType, locationResources, emptyMatchingConfigurations);
// Then
assertThat(proposition).hasSize(0);
}
use of alien4cloud.model.deployment.matching.MatchingConfiguration in project alien4cloud by alien4cloud.
the class DefaultNodeMatcherTest method real_world_location_resource_compute_should_be_able_to_match_an_abstract_compute_from_topology.
@Test
public void real_world_location_resource_compute_should_be_able_to_match_an_abstract_compute_from_topology() throws Exception {
// Given
Map<String, MatchingConfiguration> emptyMatchingConfigurations = new HashMap<>();
// When
NodeTemplate wantedNodeTemplate = nodeTemplate("tosca.nodes.Compute");
NodeType wantedNodeType = new NodeType();
List<LocationResourceTemplate> proposition = nodeMatcher.matchNode(wantedNodeTemplate, wantedNodeType, locationResources, emptyMatchingConfigurations);
// Then
assertThat(proposition).hasSize(1);
}
use of alien4cloud.model.deployment.matching.MatchingConfiguration in project alien4cloud by alien4cloud.
the class DefaultNodeMatcherTest method abstract_template_should_be_matched_if_service_is_available_2.
@Test
public void abstract_template_should_be_matched_if_service_is_available_2() throws Exception {
// Given
Map<String, MatchingConfiguration> emptyMatchingConfigurations = new HashMap<>();
// When
NodeTemplate wantedNodeTemplate = nodeTemplate("alien.service.MongoDB");
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();
}
use of alien4cloud.model.deployment.matching.MatchingConfiguration in project alien4cloud by alien4cloud.
the class NodeMatcherService method match.
public Map<String, List<LocationResourceTemplate>> match(Map<String, NodeType> nodesTypes, Map<String, NodeTemplate> nodesToMatch, Location location, String environmentId) {
Map<String, List<LocationResourceTemplate>> matchingResult = Maps.newHashMap();
// fetch location resources
LocationResources locationResources = locationResourceService.getLocationResources(location);
// Authorization filtering of location resources
filterOnAuthorization(locationResources.getNodeTemplates(), environmentId);
// fetch service resources
List<ServiceResource> services = serviceResourceService.searchByLocation(location.getId());
// self filtering: remove managed service linked to this location
filterSelfManagedService(services, environmentId);
// Authorization filtering of location resources
filterOnAuthorization(services, environmentId);
// from serviceResource to locationResource
populateLocationResourcesWithServiceResource(locationResources, services, location.getId());
Map<String, MatchingConfiguration> matchingConfigurations = locationMatchingConfigurationService.getMatchingConfiguration(location);
Set<String> typesManagedByLocation = Sets.newHashSet();
for (NodeType nodeType : locationResources.getNodeTypes().values()) {
typesManagedByLocation.add(nodeType.getElementId());
typesManagedByLocation.addAll(nodeType.getDerivedFrom());
}
INodeMatcherPlugin nodeMatcherPlugin = getNodeMatcherPlugin();
for (Map.Entry<String, NodeTemplate> nodeTemplateEntry : nodesToMatch.entrySet()) {
String nodeTemplateId = nodeTemplateEntry.getKey();
NodeTemplate nodeTemplate = nodeTemplateEntry.getValue();
if (typesManagedByLocation.contains(nodeTemplate.getType())) {
NodeType nodeTemplateType = nodesTypes.get(nodeTemplate.getType());
if (nodeTemplateType == null) {
throw new InvalidArgumentException("The given node types map must contain the type of the node template");
}
matchingResult.put(nodeTemplateId, nodeMatcherPlugin.matchNode(nodeTemplate, nodeTemplateType, locationResources, matchingConfigurations));
}
}
return matchingResult;
}
Aggregations