use of alien4cloud.model.orchestrators.Orchestrator 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;
}
use of alien4cloud.model.orchestrators.Orchestrator in project alien4cloud by alien4cloud.
the class CfyMultirelationshipErrorModifier method process.
@Override
public void process(Topology topology, FlowExecutionContext context) {
// Check if orchestrator is cloudify
Optional<DeploymentMatchingConfiguration> configurationOptional = context.getConfiguration(DeploymentMatchingConfiguration.class, LocationMatchingModifier.class.getSimpleName());
if (!configurationOptional.isPresent()) {
context.log().error(new LocationPolicyTask());
return;
}
DeploymentMatchingConfiguration matchingConfiguration = configurationOptional.get();
Orchestrator orchestrator = orchestratorService.getOrFail(matchingConfiguration.getOrchestratorId());
if (!orchestrator.getPluginId().contains("cloudify")) {
return;
}
// For every node check that there is not two relationships defined
for (Entry<String, NodeTemplate> nodeTemplateEntry : safe(topology.getNodeTemplates()).entrySet()) {
// Keep track of the relationship id
Set<String> relationshipTargets = Sets.newHashSet();
for (Entry<String, RelationshipTemplate> relationshipTemplateEntry : safe(nodeTemplateEntry.getValue().getRelationships()).entrySet()) {
if (relationshipTargets.contains(relationshipTemplateEntry.getValue().getTarget())) {
context.log().error(TaskCode.CFY_MULTI_RELATIONS, "Cloudify orchestrator does not support multiple relationships between the same source and target nodes. Topology defines more than one between " + nodeTemplateEntry.getKey() + " and " + relationshipTemplateEntry.getValue().getTarget() + ".");
return;
}
relationshipTargets.add(relationshipTemplateEntry.getValue().getTarget());
}
}
}
use of alien4cloud.model.orchestrators.Orchestrator in project alien4cloud by alien4cloud.
the class ApplicationBootstrap method migration.
/**
* Performs data migration for 1.3.1 version where plugin ids are not generated using the version anymore.
*/
private void migration() {
log.debug("Initializing plugin id migrations");
int count = 0;
// This code updates the ids of plugin configurations and plugins in elasticsearch to remove the version reference.
GetMultipleDataResult<Plugin> pluginResult = alienDAO.buildQuery(Plugin.class).prepareSearch().search(0, Integer.MAX_VALUE);
for (Plugin plugin : pluginResult.getData()) {
if (plugin.getEsId().contains(":")) {
PluginConfiguration pluginConfiguration = alienDAO.findById(PluginConfiguration.class, plugin.getEsId());
if (pluginConfiguration != null) {
pluginConfiguration.setPluginId(plugin.getId());
alienDAO.save(pluginConfiguration);
alienDAO.delete(PluginConfiguration.class, plugin.getEsId());
}
alienDAO.save(plugin);
alienDAO.delete(Plugin.class, plugin.getEsId());
count++;
}
}
if (count > 0) {
log.info("{} plugins migrated", count);
}
count = 0;
// This code updates the plugin id in the orchestrators.
GetMultipleDataResult<Orchestrator> orchestratorResult = alienDAO.buildQuery(Orchestrator.class).prepareSearch().search(0, Integer.MAX_VALUE);
for (Orchestrator orchestrator : orchestratorResult.getData()) {
if (orchestrator.getPluginId().contains(":")) {
orchestrator.setPluginId(orchestrator.getPluginId().split(":")[0]);
alienDAO.save(orchestrator);
count++;
}
}
if (count > 0) {
log.info("Orchestrator migrated: {}.", count);
}
log.debug("plugin id migration done.");
}
use of alien4cloud.model.orchestrators.Orchestrator 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);
}
}
use of alien4cloud.model.orchestrators.Orchestrator in project alien4cloud by alien4cloud.
the class OrchestratorsDefinitionsSteps method Response_should_contains_an_orchestrator_with_name.
@Then("^Response should contains an orchestrator with name \"([^\"]*)\"$")
public void Response_should_contains_an_orchestrator_with_name(String name) throws Throwable {
RestResponse<GetMultipleDataResult> response = JsonUtil.read(Context.getInstance().getRestResponse(), GetMultipleDataResult.class);
boolean contains = false;
for (Object cloudAsMap : response.getData().getData()) {
Orchestrator orchestrator = JsonUtil.readObject(JsonUtil.toString(cloudAsMap), Orchestrator.class);
if (name.equals(orchestrator.getName())) {
contains = true;
}
}
Assert.assertTrue(contains);
}
Aggregations