Search in sources :

Example 1 with UnavailableLocationTask

use of alien4cloud.topology.task.UnavailableLocationTask in project alien4cloud by alien4cloud.

the class DeploymentSetupValidationStepDefinitions method thereShouldBeADisabledLocationPolicyTask.

@And("^there should be an unavailable location task with code \"([^\"]*)\" and the following orchestrators and locations$$")
public void thereShouldBeADisabledLocationPolicyTask(String taskCodeStr, Map<String, String> orchLocationCouple) throws Throwable {
    TaskCode taskCode = TaskCode.valueOf(taskCodeStr);
    TopologyValidationResult topologyValidationResult = JsonUtil.read(Context.getInstance().getRestResponse(), DeploymentTopologyDTO.class, Context.getJsonMapper()).getData().getValidation();
    for (Entry<String, String> expectedEntry : orchLocationCouple.entrySet()) {
        boolean missingFound = topologyValidationResult.getTaskList().stream().anyMatch(task -> task instanceof UnavailableLocationTask && task.getCode().equals(taskCode) && Objects.equals(((UnavailableLocationTask) task).getOrchestratorName(), expectedEntry.getKey()) && Objects.equals(((UnavailableLocationTask) task).getLocationName(), expectedEntry.getValue()));
        Assert.assertTrue(" Expected a task " + taskCode + " for the deployment setup", missingFound);
    }
}
Also used : TopologyValidationResult(alien4cloud.topology.TopologyValidationResult) TaskCode(alien4cloud.topology.task.TaskCode) UnavailableLocationTask(alien4cloud.topology.task.UnavailableLocationTask) And(cucumber.api.java.en.And)

Example 2 with UnavailableLocationTask

use of alien4cloud.topology.task.UnavailableLocationTask in project alien4cloud by alien4cloud.

the class LocationPolicyValidationService method validateLocationPolicies.

public List<LocationPolicyTask> validateLocationPolicies(DeploymentMatchingConfiguration matchingConfiguration) {
    List<LocationPolicyTask> tasks = Lists.newArrayList();
    Location location = null;
    Orchestrator orchestrator = null;
    // TODO change this later, as now we only support one location policy and only for _A4C_ALL group
    String locationId = safe(matchingConfiguration.getLocationIds()).get(AlienConstants.GROUP_ALL);
    if (StringUtils.isBlank(locationId)) {
        tasks.add(new LocationPolicyTask());
    } else {
        location = locationService.getOrFail(locationId);
        orchestrator = orchestratorService.getOrFail(location.getOrchestratorId());
        try {
            // if a location already exists, then check the rigths on it
            locationSecurityService.checkAuthorisation(location, matchingConfiguration.getEnvironmentId());
            if (!Objects.equals(orchestrator.getState(), OrchestratorState.CONNECTED)) {
                UnavailableLocationTask task = new UnavailableLocationTask(location.getName(), orchestrator.getName());
                task.setCode(TaskCode.LOCATION_DISABLED);
                tasks.add(task);
            }
        } catch (AccessDeniedException e) {
            UnavailableLocationTask task = new UnavailableLocationTask(location.getName(), orchestrator.getName());
            task.setCode(TaskCode.LOCATION_UNAUTHORIZED);
            tasks.add(task);
        }
    }
    return tasks;
}
Also used : AccessDeniedException(org.springframework.security.access.AccessDeniedException) LocationPolicyTask(alien4cloud.topology.task.LocationPolicyTask) UnavailableLocationTask(alien4cloud.topology.task.UnavailableLocationTask) Orchestrator(alien4cloud.model.orchestrators.Orchestrator) Location(alien4cloud.model.orchestrators.locations.Location)

Aggregations

UnavailableLocationTask (alien4cloud.topology.task.UnavailableLocationTask)2 Orchestrator (alien4cloud.model.orchestrators.Orchestrator)1 Location (alien4cloud.model.orchestrators.locations.Location)1 TopologyValidationResult (alien4cloud.topology.TopologyValidationResult)1 LocationPolicyTask (alien4cloud.topology.task.LocationPolicyTask)1 TaskCode (alien4cloud.topology.task.TaskCode)1 And (cucumber.api.java.en.And)1 AccessDeniedException (org.springframework.security.access.AccessDeniedException)1