Search in sources :

Example 11 with Orchestrator

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

Example 12 with Orchestrator

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());
        }
    }
}
Also used : NodeTemplate(org.alien4cloud.tosca.model.templates.NodeTemplate) RelationshipTemplate(org.alien4cloud.tosca.model.templates.RelationshipTemplate) LocationPolicyTask(alien4cloud.topology.task.LocationPolicyTask) DeploymentMatchingConfiguration(org.alien4cloud.alm.deployment.configuration.model.DeploymentMatchingConfiguration) Orchestrator(alien4cloud.model.orchestrators.Orchestrator)

Example 13 with Orchestrator

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.");
}
Also used : PluginConfiguration(alien4cloud.plugin.model.PluginConfiguration) Orchestrator(alien4cloud.model.orchestrators.Orchestrator) Plugin(alien4cloud.plugin.Plugin)

Example 14 with Orchestrator

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);
    }
}
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 15 with Orchestrator

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);
}
Also used : GetMultipleDataResult(alien4cloud.dao.model.GetMultipleDataResult) Orchestrator(alien4cloud.model.orchestrators.Orchestrator) Then(cucumber.api.java.en.Then)

Aggregations

Orchestrator (alien4cloud.model.orchestrators.Orchestrator)28 IOrchestratorPluginFactory (alien4cloud.orchestrators.plugin.IOrchestratorPluginFactory)7 Location (alien4cloud.model.orchestrators.locations.Location)6 IOrchestratorPlugin (alien4cloud.orchestrators.plugin.IOrchestratorPlugin)5 ApiOperation (io.swagger.annotations.ApiOperation)4 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 OrchestratorConfiguration (alien4cloud.model.orchestrators.OrchestratorConfiguration)3 LocationResourceTemplate (alien4cloud.model.orchestrators.locations.LocationResourceTemplate)3 Test (org.junit.Test)3 Audit (alien4cloud.audit.annotation.Audit)2 GetMultipleDataResult (alien4cloud.dao.model.GetMultipleDataResult)2 ILocationMatch (alien4cloud.model.deployment.matching.ILocationMatch)2 LocationMatch (alien4cloud.model.deployment.matching.LocationMatch)2 AbstractLocationResourceTemplate (alien4cloud.model.orchestrators.locations.AbstractLocationResourceTemplate)2 LocationResources (alien4cloud.model.orchestrators.locations.LocationResources)2 PolicyLocationResourceTemplate (alien4cloud.model.orchestrators.locations.PolicyLocationResourceTemplate)2 ILocationConfiguratorPlugin (alien4cloud.orchestrators.plugin.ILocationConfiguratorPlugin)2 LocationMatchingException (alien4cloud.paas.exception.LocationMatchingException)2 LocationPolicyTask (alien4cloud.topology.task.LocationPolicyTask)2