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