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);
}
}
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;
}
Aggregations