Search in sources :

Example 51 with ArchiveRoot

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);
}
Also used : Path(java.nio.file.Path) ArchiveRoot(alien4cloud.tosca.model.ArchiveRoot) PluginArchive(alien4cloud.orchestrators.plugin.model.PluginArchive)

Example 52 with ArchiveRoot

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());
}
Also used : Path(java.nio.file.Path) ArchiveRoot(alien4cloud.tosca.model.ArchiveRoot) Test(org.junit.Test)

Example 53 with ArchiveRoot

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));
}
Also used : Path(java.nio.file.Path) ArchiveRoot(alien4cloud.tosca.model.ArchiveRoot) Test(org.junit.Test)

Example 54 with ArchiveRoot

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);
}
Also used : ArchiveRoot(alien4cloud.tosca.model.ArchiveRoot) ToscaMeta(alien4cloud.tosca.model.ToscaMeta)

Example 55 with ArchiveRoot

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);
}
Also used : ArchiveRoot(alien4cloud.tosca.model.ArchiveRoot) ToscaMeta(alien4cloud.tosca.model.ToscaMeta)

Aggregations

ArchiveRoot (alien4cloud.tosca.model.ArchiveRoot)76 Test (org.junit.Test)43 Set (java.util.Set)26 NodeType (org.alien4cloud.tosca.model.types.NodeType)26 Csar (org.alien4cloud.tosca.model.Csar)25 RelationshipType (org.alien4cloud.tosca.model.types.RelationshipType)16 CapabilityType (org.alien4cloud.tosca.model.types.CapabilityType)14 ParsingError (alien4cloud.tosca.parser.ParsingError)13 Path (java.nio.file.Path)11 PropertyDefinition (org.alien4cloud.tosca.model.definitions.PropertyDefinition)9 NodeTemplate (org.alien4cloud.tosca.model.templates.NodeTemplate)8 Node (org.yaml.snakeyaml.nodes.Node)8 PluginArchive (alien4cloud.orchestrators.plugin.model.PluginArchive)6 CSARDependency (org.alien4cloud.tosca.model.CSARDependency)6 AbstractPropertyValue (org.alien4cloud.tosca.model.definitions.AbstractPropertyValue)6 ParsingException (alien4cloud.tosca.parser.ParsingException)5 Map (java.util.Map)5 Topology (org.alien4cloud.tosca.model.templates.Topology)5 ComplexPropertyValue (org.alien4cloud.tosca.model.definitions.ComplexPropertyValue)4 ScalarPropertyValue (org.alien4cloud.tosca.model.definitions.ScalarPropertyValue)4