use of alien4cloud.orchestrators.plugin.model.PluginArchive in project yorc-a4c-plugin by ystia.
the class AbstractLocationConfigurer method addToAchive.
protected void addToAchive(List<PluginArchive> archives, String path) throws ParsingException {
Path archivePath = selfContext.getPluginPath().resolve(path);
// Parse the archives
ParsingResult<ArchiveRoot> result = archiveParser.parseDir(archivePath, AlienConstants.GLOBAL_WORKSPACE_ID);
PluginArchive pluginArchive = new PluginArchive(result.getResult(), archivePath);
archives.add(pluginArchive);
}
use of alien4cloud.orchestrators.plugin.model.PluginArchive in project alien4cloud by alien4cloud.
the class MockAmazonLocationConfigurer method addToAchive.
private void addToAchive(List<PluginArchive> archives, String path) throws ParsingException {
Path archivePath = selfContext.getPluginPath().resolve(path);
// Parse the archives
ParsingResult<ArchiveRoot> result = archiveParser.parseDir(archivePath, AlienConstants.GLOBAL_WORKSPACE_ID);
PluginArchive pluginArchive = new PluginArchive(result.getResult(), archivePath);
archives.add(pluginArchive);
}
use of alien4cloud.orchestrators.plugin.model.PluginArchive in project alien4cloud by alien4cloud.
the class ArchiveProviderPluginCallBack method deleteArchives.
private Map<Csar, List<Usage>> deleteArchives(Collection<PluginArchive> pluginArchives) {
Map<Csar, List<Usage>> usages = Maps.newHashMap();
for (PluginArchive pluginArchive : safe(pluginArchives)) {
Csar csar = pluginArchive.getArchive().getArchive();
List<Usage> csarUsage = csarService.deleteCsarWithElements(csar);
// TODO push delete event
if (CollectionUtils.isNotEmpty(csarUsage)) {
usages.put(csar, csarUsage);
}
}
return usages.isEmpty() ? null : usages;
}
use of alien4cloud.orchestrators.plugin.model.PluginArchive in project alien4cloud by alien4cloud.
the class PluginArchiveIndexer method deleteArchives.
/**
* Delete all archives related to a location, if not exposed or used by another location
*
* @param location
* @return Map of usages per archives if found (that means the deletion wasn't performed successfully), null if everything went well.
*/
public Map<Csar, List<Usage>> deleteArchives(Orchestrator orchestrator, Location location) {
ILocationConfiguratorPlugin configuratorPlugin = getConfiguratorPlugin(location);
IOrchestratorPluginFactory orchestratorFactory = orchestratorService.getPluginFactory(orchestrator);
List<PluginArchive> pluginArchives = configuratorPlugin.pluginArchives();
// abort if no archive is exposed by this location
if (CollectionUtils.isEmpty(pluginArchives)) {
return null;
}
Map<String, List<Location>> allExposedArchivesIds = getAllExposedArchivesIdsExluding(location);
Map<Csar, List<Usage>> usages = Maps.newHashMap();
for (PluginArchive pluginArchive : pluginArchives) {
Csar csar = pluginArchive.getArchive().getArchive();
List<Location> locationsExposingArchive = allExposedArchivesIds.get(csar.getId());
LocationArchiveDeleteRequested e = new LocationArchiveDeleteRequested(this);
e.setCsar(csar);
e.setLocation(location);
e.setOrchestratorFactory(orchestratorFactory);
e.setLocationsExposingArchive(locationsExposingArchive);
// only delete if no other location exposed this archive
if (locationsExposingArchive == null) {
List<Usage> csarUsage = csarService.deleteCsarWithElements(csar);
if (CollectionUtils.isNotEmpty(csarUsage)) {
usages.put(csar, csarUsage);
}
e.setDeleted(true);
} else {
e.setDeleted(false);
}
applicationContext.publishEvent(e);
}
return usages.isEmpty() ? null : usages;
}
use of alien4cloud.orchestrators.plugin.model.PluginArchive 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;
}
Aggregations