use of alien4cloud.tosca.model.ArchiveRoot 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.tosca.model.ArchiveRoot in project alien4cloud by alien4cloud.
the class ArchiveImageLoaderTest method importToscaElementImages.
@Test
public void importToscaElementImages() throws IOException, ParsingException {
Path csarFileForTesting = Paths.get(CSAR_OUTPUT_FOLDER.toString(), tmpArchiveName);
// Zip the csarSourceFolder and write it to csarFileForTesting
FileUtil.zip(PATH_TOSCA_BASE_TYPES, csarFileForTesting);
Path imagesPath = Paths.get("target/alien/images");
if (!Files.exists(imagesPath)) {
Files.createDirectories(imagesPath);
}
// Parse the archive for definitions
ParsingResult<ArchiveRoot> result = parser.parse(csarFileForTesting, AlienConstants.GLOBAL_WORKSPACE_ID);
imageLoader.importImages(csarFileForTesting, result.getResult(), result.getContext().getParsingErrors());
Assert.assertFalse(result.hasError(ParsingErrorLevel.ERROR));
Assert.assertFalse(result.hasError(ParsingErrorLevel.WARNING));
checkImages(result.getResult().getNodeTypes());
}
use of alien4cloud.tosca.model.ArchiveRoot in project alien4cloud by alien4cloud.
the class ArchiveImageLoaderTest method importToscaElementWithBadImageUri.
@Test
public void importToscaElementWithBadImageUri() throws IOException, ParsingException {
Path csarFileForTesting = Paths.get(CSAR_OUTPUT_FOLDER.toString(), tmpArchiveNameWithError);
// Zip the csarSourceFolder and write it to csarFileForTesting
FileUtil.zip(PATH_TOSCA_BASE_TYPES_ERROR, csarFileForTesting);
// Parse the archive for definitions
ParsingResult<ArchiveRoot> result = parser.parse(csarFileForTesting, AlienConstants.GLOBAL_WORKSPACE_ID);
imageLoader.importImages(csarFileForTesting, result.getResult(), result.getContext().getParsingErrors());
// we expect to have warning issues due to missing files or invalid formats.
Assert.assertFalse(result.hasError(ParsingErrorLevel.ERROR));
Assert.assertTrue(result.hasError(ParsingErrorLevel.WARNING));
}
use of alien4cloud.tosca.model.ArchiveRoot in project alien4cloud by alien4cloud.
the class ToscaArchiveParser method parseFromToscaMeta.
private ParsingResult<ArchiveRoot> parseFromToscaMeta(FileSystem csarFS) throws ParsingException {
YamlSimpleParser<ToscaMeta> parser = new YamlSimpleParser<ToscaMeta>(toscaMetaMapping.getParser());
ParsingResult<ToscaMeta> parsingResult = parser.parseFile(csarFS.getPath(TOSCA_META_FILE_LOCATION));
// FIXME shouldn't we check here if the meta parsing went well?
ArchiveRoot archiveRoot = initFromToscaMeta(parsingResult);
return parseFromToscaMeta(csarFS, parsingResult.getResult(), TOSCA_META_FILE_LOCATION, archiveRoot, toscaParser);
}
use of alien4cloud.tosca.model.ArchiveRoot in project alien4cloud by alien4cloud.
the class ToscaArchiveParser method parseFromToscaMeta.
private ParsingResult<ArchiveRoot> parseFromToscaMeta(Path csarPath) throws ParsingException {
YamlSimpleParser<ToscaMeta> parser = new YamlSimpleParser<ToscaMeta>(toscaMetaMapping.getParser());
ParsingResult<ToscaMeta> parsingResult = parser.parseFile(csarPath.resolve(TOSCA_META_FILE_LOCATION));
ArchiveRoot archiveRoot = initFromToscaMeta(parsingResult);
return parseFromToscaMeta(csarPath, parsingResult.getResult(), TOSCA_META_FILE_LOCATION, archiveRoot);
}
Aggregations