Search in sources :

Example 1 with LocationMatch

use of alien4cloud.model.deployment.matching.LocationMatch in project alien4cloud by alien4cloud.

the class DefaultLocationMatcher method match.

@Override
public List<ILocationMatch> match(Topology topology) throws LocationMatchingException {
    List<ILocationMatch> matched = Lists.newArrayList();
    try {
        // get all enabled orchestrators
        List<Orchestrator> enabledOrchestrators = orchestratorService.getAll();
        if (CollectionUtils.isEmpty(enabledOrchestrators)) {
            return matched;
        }
        Map<String, Orchestrator> orchestratorMap = AlienUtils.fromListToMap(enabledOrchestrators, "id", true);
        List<Location> locations = locationService.getOrchestratorsLocations(orchestratorMap.keySet());
        for (Location location : locations) {
            matched.add(new LocationMatch(location, orchestratorMap.get(location.getOrchestratorId()), null));
        }
        // filter on supported artifacts
        locationMatchNodeFilter.filter(matched, topology);
        return matched;
    } catch (Exception e) {
        throw new LocationMatchingException("Failed to match topology <" + topology.getId() + "> against locations. ", e);
    }
}
Also used : LocationMatch(alien4cloud.model.deployment.matching.LocationMatch) ILocationMatch(alien4cloud.model.deployment.matching.ILocationMatch) ILocationMatch(alien4cloud.model.deployment.matching.ILocationMatch) LocationMatchingException(alien4cloud.paas.exception.LocationMatchingException) Orchestrator(alien4cloud.model.orchestrators.Orchestrator) LocationMatchingException(alien4cloud.paas.exception.LocationMatchingException) Location(alien4cloud.model.orchestrators.locations.Location)

Example 2 with LocationMatch

use of alien4cloud.model.deployment.matching.LocationMatch in project alien4cloud by alien4cloud.

the class MockLocationMatcher method match.

@Override
public List<ILocationMatch> match(Topology topology) throws LocationMatchingException {
    log.info("Mock location matcher <" + this.getClass().getName() + "> called!");
    List<ILocationMatch> matched = Lists.newArrayList();
    // get all enabled orchestrators
    try {
        List<Orchestrator> enabledOrchestrators = orchestratorService.getAllEnabledOrchestrators();
        if (CollectionUtils.isEmpty(enabledOrchestrators)) {
            return matched;
        }
        Map<String, Orchestrator> orchestratorMap = AlienUtils.fromListToMap(enabledOrchestrators, "id", true);
        List<Location> locations = locationService.getOrchestratorsLocations(orchestratorMap.keySet());
        for (Location location : locations) {
            matched.add(new LocationMatch(location, orchestratorMap.get(location.getOrchestratorId()), null));
        }
        new MockLocationMatchOrchestratorFilter(selfContext).filter(matched, topology);
        return matched;
    } catch (Exception e) {
        throw new LocationMatchingException("Failed to match topology <" + topology.getId() + "> against locations. ", e);
    }
}
Also used : LocationMatch(alien4cloud.model.deployment.matching.LocationMatch) ILocationMatch(alien4cloud.model.deployment.matching.ILocationMatch) ILocationMatch(alien4cloud.model.deployment.matching.ILocationMatch) LocationMatchingException(alien4cloud.paas.exception.LocationMatchingException) Orchestrator(alien4cloud.model.orchestrators.Orchestrator) LocationMatchingException(alien4cloud.paas.exception.LocationMatchingException) Location(alien4cloud.model.orchestrators.locations.Location)

Example 3 with LocationMatch

use of alien4cloud.model.deployment.matching.LocationMatch in project alien4cloud by alien4cloud.

the class LocationMatchingStepDefinitions method assertLocationMatches.

private static void assertLocationMatches(List<LocationMatch> matches, int expectedCount, List<String> expectedNames) {
    if (CollectionUtils.isEmpty(matches)) {
        matches = Lists.newArrayList();
    }
    assertEquals(matches.size(), expectedCount);
    Set<String> names = Sets.newHashSet();
    for (LocationMatch locationMatch : matches) {
        names.add(locationMatch.getLocation().getName());
    }
    assertTrue(SetUtils.isEqualSet(names, expectedNames));
}
Also used : LocationMatch(alien4cloud.model.deployment.matching.LocationMatch)

Aggregations

LocationMatch (alien4cloud.model.deployment.matching.LocationMatch)3 ILocationMatch (alien4cloud.model.deployment.matching.ILocationMatch)2 Orchestrator (alien4cloud.model.orchestrators.Orchestrator)2 Location (alien4cloud.model.orchestrators.locations.Location)2 LocationMatchingException (alien4cloud.paas.exception.LocationMatchingException)2