use of alien4cloud.topology.task.TaskCode 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.TaskCode in project alien4cloud by alien4cloud.
the class TopologyService method searchForNodeTypes.
/**
* Search for nodeTypes given some filters. Apply AND filter strategy when multiple values for a filter key.
*/
public List<SuggestionsTask> searchForNodeTypes(String workspace, Map<String, Map<String, Set<String>>> nodeTemplatesToFilters, Map<String, NodeType> toExcludeIndexedNodeTypes, boolean excludeAbstract) throws IOException {
if (nodeTemplatesToFilters == null || nodeTemplatesToFilters.isEmpty()) {
return null;
}
List<SuggestionsTask> toReturnTasks = Lists.newArrayList();
for (Map.Entry<String, Map<String, Set<String>>> nodeTemplatesToFiltersEntry : nodeTemplatesToFilters.entrySet()) {
Map<String, String[]> formattedFilters = Maps.newHashMap();
Map<String, FilterValuesStrategy> filterValueStrategy = Maps.newHashMap();
NodeType[] data = null;
if (nodeTemplatesToFiltersEntry.getValue() != null) {
for (Map.Entry<String, Set<String>> filterEntry : nodeTemplatesToFiltersEntry.getValue().entrySet()) {
formattedFilters.put(filterEntry.getKey(), filterEntry.getValue().toArray(new String[filterEntry.getValue().size()]));
// AND strategy if multiple values
filterValueStrategy.put(filterEntry.getKey(), FilterValuesStrategy.AND);
}
// retrieve only non abstract components
if (excludeAbstract) {
formattedFilters.put("abstract", ArrayUtils.toArray(String.valueOf("false")));
}
// use topology workspace + global workspace
formattedFilters.put("workspace", ArrayUtils.toArray(workspace, "ALIEN_GLOBAL_WORKSPACE"));
GetMultipleDataResult<NodeType> searchResult = alienDAO.search(NodeType.class, null, formattedFilters, filterValueStrategy, 20);
data = getIndexedNodeTypesFromSearchResponse(searchResult, toExcludeIndexedNodeTypes.get(nodeTemplatesToFiltersEntry.getKey()));
}
TaskCode taskCode = ArrayUtils.isEmpty(data) ? TaskCode.IMPLEMENT : TaskCode.REPLACE;
SuggestionsTask task = new SuggestionsTask();
task.setNodeTemplateName(nodeTemplatesToFiltersEntry.getKey());
task.setComponent(toExcludeIndexedNodeTypes.get(nodeTemplatesToFiltersEntry.getKey()));
task.setCode(taskCode);
task.setSuggestedNodeTypes(data);
toReturnTasks.add(task);
}
return toReturnTasks;
}
Aggregations