Search in sources :

Example 6 with ILocationConfiguratorPlugin

use of alien4cloud.orchestrators.plugin.ILocationConfiguratorPlugin in project alien4cloud by alien4cloud.

the class PluginArchiveIndexer method getAllExposedArchivesIdsExluding.

/**
 * Query for csars that are defined by locations.
 *
 * @return A maps of <csar_id, list of locations that uses the csar>.
 */
public Map<String, List<Location>> getAllExposedArchivesIdsExluding(Location excludedLocation) {
    // exclude a location from the search
    QueryBuilder query = QueryBuilders.boolQuery().mustNot(QueryBuilders.idsQuery(Location.class.getSimpleName().toLowerCase()).ids(excludedLocation.getId()));
    List<Location> locations = alienDAO.customFindAll(Location.class, query);
    Map<String, List<Location>> archiveIds = Maps.newHashMap();
    if (locations != null) {
        for (Location location : locations) {
            ILocationConfiguratorPlugin configuratorPlugin = getConfiguratorPlugin(location);
            List<PluginArchive> pluginArchives = configuratorPlugin.pluginArchives();
            for (PluginArchive pluginArchive : safe(pluginArchives)) {
                String archiveId = pluginArchive.getArchive().getArchive().getId();
                List<Location> locationsPerArchive = archiveIds.get(archiveId);
                if (locationsPerArchive == null) {
                    locationsPerArchive = Lists.newArrayList();
                    archiveIds.put(archiveId, locationsPerArchive);
                }
                locationsPerArchive.add(location);
            }
        }
    }
    return archiveIds;
}
Also used : ILocationConfiguratorPlugin(alien4cloud.orchestrators.plugin.ILocationConfiguratorPlugin) PluginArchive(alien4cloud.orchestrators.plugin.model.PluginArchive) ArrayList(java.util.ArrayList) List(java.util.List) QueryBuilder(org.elasticsearch.index.query.QueryBuilder) Location(alien4cloud.model.orchestrators.locations.Location)

Example 7 with ILocationConfiguratorPlugin

use of alien4cloud.orchestrators.plugin.ILocationConfiguratorPlugin in project alien4cloud by alien4cloud.

the class PluginArchiveIndexer method getArchivesToIndex.

/**
 * From all exposed plugin archives of the location, get the one that are not yet indexed
 *
 * @param orchestrator
 * @param location
 * @return an object of type {@link ArchiveToIndex} with the indexable archives and the full list of dependencies
 */
private ArchiveToIndex getArchivesToIndex(Orchestrator orchestrator, Location location) {
    Set<CSARDependency> dependencies = Sets.newHashSet();
    IOrchestratorPlugin orchestratorInstance = (IOrchestratorPlugin) orchestratorPluginService.getOrFail(orchestrator.getId());
    ILocationConfiguratorPlugin configuratorPlugin = orchestratorInstance.getConfigurator(location.getInfrastructureType());
    List<PluginArchive> allPluginArchives = configuratorPlugin.pluginArchives();
    Set<PluginArchive> archivesToIndex = Sets.newHashSet();
    for (PluginArchive pluginArchive : safe(allPluginArchives)) {
        ArchiveRoot archive = pluginArchive.getArchive();
        Csar csar = csarService.get(archive.getArchive().getName(), archive.getArchive().getVersion());
        String lastParsedHash = null;
        if (csar == null) {
            // the archive does not exist into the repository: should be indexed
            lastParsedHash = archive.getArchive().getHash();
            archivesToIndex.add(pluginArchive);
        } else {
            // Else, just take the hash
            lastParsedHash = csar.getHash();
        }
        if (archive.getArchive().getDependencies() != null) {
            dependencies.addAll(archive.getArchive().getDependencies());
        }
        dependencies.add(new CSARDependency(archive.getArchive().getName(), archive.getArchive().getVersion(), lastParsedHash));
    }
    return new ArchiveToIndex(dependencies, archivesToIndex);
}
Also used : Csar(org.alien4cloud.tosca.model.Csar) ArchiveRoot(alien4cloud.tosca.model.ArchiveRoot) ILocationConfiguratorPlugin(alien4cloud.orchestrators.plugin.ILocationConfiguratorPlugin) PluginArchive(alien4cloud.orchestrators.plugin.model.PluginArchive) CSARDependency(org.alien4cloud.tosca.model.CSARDependency) IOrchestratorPlugin(alien4cloud.orchestrators.plugin.IOrchestratorPlugin)

Aggregations

ILocationConfiguratorPlugin (alien4cloud.orchestrators.plugin.ILocationConfiguratorPlugin)7 IOrchestratorPlugin (alien4cloud.orchestrators.plugin.IOrchestratorPlugin)5 IOrchestratorPluginFactory (alien4cloud.orchestrators.plugin.IOrchestratorPluginFactory)3 PluginArchive (alien4cloud.orchestrators.plugin.model.PluginArchive)3 Orchestrator (alien4cloud.model.orchestrators.Orchestrator)2 Location (alien4cloud.model.orchestrators.locations.Location)2 LocationResourceTemplate (alien4cloud.model.orchestrators.locations.LocationResourceTemplate)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Csar (org.alien4cloud.tosca.model.Csar)2 LocationArchiveDeleteRequested (alien4cloud.events.LocationArchiveDeleteRequested)1 LocationTemplateCreated (alien4cloud.events.LocationTemplateCreated)1 Usage (alien4cloud.model.common.Usage)1 AbstractLocationResourceTemplate (alien4cloud.model.orchestrators.locations.AbstractLocationResourceTemplate)1 LocationResources (alien4cloud.model.orchestrators.locations.LocationResources)1 PolicyLocationResourceTemplate (alien4cloud.model.orchestrators.locations.PolicyLocationResourceTemplate)1 ILocationResourceAccessor (alien4cloud.orchestrators.plugin.ILocationResourceAccessor)1 OrchestratorDisabledException (alien4cloud.paas.exception.OrchestratorDisabledException)1 ArchiveRoot (alien4cloud.tosca.model.ArchiveRoot)1 CSARDependency (org.alien4cloud.tosca.model.CSARDependency)1