use of alien4cloud.orchestrators.plugin.model.PluginArchive 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);
}
use of alien4cloud.orchestrators.plugin.model.PluginArchive in project alien4cloud by alien4cloud.
the class PluginArchiveIndexer method indexOrchestratorArchives.
/**
* Index archives defined at the orchestrator level by a plugin.
*
* @param orchestratorFactory The orchestrator factory.
* @param orchestratorInstance The instance of the orchestrator (created by the factory).
*/
public void indexOrchestratorArchives(IOrchestratorPluginFactory<IOrchestratorPlugin<?>, ?> orchestratorFactory, IOrchestratorPlugin<Object> orchestratorInstance) {
for (PluginArchive pluginArchive : orchestratorInstance.pluginArchives()) {
try {
archiveIndexer.importArchive(pluginArchive.getArchive(), CSARSource.ORCHESTRATOR, pluginArchive.getArchiveFilePath(), Lists.<ParsingError>newArrayList());
publishLocationTypeIndexedEvent(pluginArchive.getArchive().getNodeTypes().values(), orchestratorFactory, null);
} catch (AlreadyExistException e) {
log.debug("Skipping orchestrator archive import as the released version already exists in the repository. " + e.getMessage());
} catch (CSARUsedInActiveDeployment e) {
log.debug("Skipping orchestrator archive import as it is used in an active deployment. " + e.getMessage());
} catch (ToscaTypeAlreadyDefinedInOtherCSAR e) {
log.debug("Skipping orchestrator archive import, it's archive contain's a tosca type already defined in an other archive." + e.getMessage());
}
}
}
use of alien4cloud.orchestrators.plugin.model.PluginArchive in project alien4cloud by alien4cloud.
the class AbstractPluginArchiveService method parse.
/**
* Parse an archive given a path relative to the plugin
*
* @param archiveRelativePath Relative path where the archive is in the plugin
* @return The parsed archive as a @{@link PluginArchive}
* @throws PluginArchiveException
*/
public PluginArchive parse(String archiveRelativePath) throws PluginArchiveException {
String archiveErrorMsge = "Archive in path: [ " + archiveRelativePath + " ]";
// Parse the archives
ParsingResult<ArchiveRoot> result;
Path archivePath = selfContext.getPluginPath().resolve(archiveRelativePath);
try {
result = this.archiveParser.parseDir(archivePath, AlienConstants.GLOBAL_WORKSPACE_ID);
} catch (ParsingException e) {
throw new PluginArchiveException("Failed to parse " + archiveErrorMsge, e);
}
if (result.getContext().getParsingErrors() != null && !result.getContext().getParsingErrors().isEmpty()) {
log.error("Parsing errors for" + archiveErrorMsge);
for (ParsingError parsingError : result.getContext().getParsingErrors()) {
log.error(parsingError.toString());
}
throw new PluginArchiveException(archiveErrorMsge + " is invalid");
}
return new PluginArchive(result.getResult(), archivePath);
}
use of alien4cloud.orchestrators.plugin.model.PluginArchive in project alien4cloud by alien4cloud.
the class MockOpenStackLocationConfigurer 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 yorc-a4c-plugin by ystia.
the class PluginArchiveService method parsePluginArchives.
public PluginArchive parsePluginArchives(String archiveRelativePath) {
// Parse the archives
ParsingResult<ArchiveRoot> result;
Path archivePath = selfContext.getPluginPath().resolve(archiveRelativePath);
try {
result = this.archiveParser.parseDir(archivePath, AlienConstants.GLOBAL_WORKSPACE_ID);
} catch (ParsingException e) {
log.error("Failed to parse archive, plugin won't work", e);
throw new RuntimeException("Failed to parse archive, plugin won't work", e);
}
if (result.getContext().getParsingErrors() != null && !result.getContext().getParsingErrors().isEmpty()) {
log.error("Parsing errors for " + archiveRelativePath);
for (ParsingError parsingError : result.getContext().getParsingErrors()) {
log.error(parsingError.toString());
}
throw new RuntimeException("Plugin archive is invalid, plugin won't work");
}
return new PluginArchive(result.getResult(), archivePath);
}
Aggregations