Search in sources :

Example 36 with CSARDependency

use of org.alien4cloud.tosca.model.CSARDependency in project alien4cloud by alien4cloud.

the class CsarDependencyLoader method buildDependencyBean.

@Override
@ToscaContextual
public CSARDependency buildDependencyBean(String name, String version) {
    CSARDependency newDependency = new CSARDependency(name, version);
    Csar csar = ToscaContext.get().getArchive(name, version);
    if (csar != null) {
        newDependency.setHash(csar.getHash());
    }
    return newDependency;
}
Also used : Csar(org.alien4cloud.tosca.model.Csar) CSARDependency(org.alien4cloud.tosca.model.CSARDependency) ToscaContextual(alien4cloud.tosca.context.ToscaContextual)

Example 37 with CSARDependency

use of org.alien4cloud.tosca.model.CSARDependency in project alien4cloud by alien4cloud.

the class ArchiveIndexer method indexTopology.

private void indexTopology(final ArchiveRoot archiveRoot, List<ParsingError> parsingErrors, String archiveName, String archiveVersion) {
    Topology topology = archiveRoot.getTopology();
    if (topology == null || topology.isEmpty()) {
        return;
    }
    topology.setTags(archiveRoot.getArchive().getTags());
    if (archiveRoot.hasToscaTypes()) {
        // The archive contains types, we assume those types are used in the embedded topology so we add the dependency to this CSAR
        CSARDependency selfDependency = new CSARDependency(archiveRoot.getArchive().getName(), archiveRoot.getArchive().getVersion(), archiveRoot.getArchive().getHash());
        topology.getDependencies().add(selfDependency);
    }
    // init the workflows
    TopologyContext topologyContext = workflowBuilderService.buildCachedTopologyContext(new TopologyContext() {

        @Override
        public String getDSLVersion() {
            return archiveRoot.getArchive().getToscaDefinitionsVersion();
        }

        @Override
        public Topology getTopology() {
            return topology;
        }

        @Override
        public <T extends AbstractToscaType> T findElement(Class<T> clazz, String elementId) {
            return ToscaContext.get(clazz, elementId);
        }
    });
    workflowBuilderService.initWorkflows(topologyContext);
    parsingErrors.add(new ParsingError(ParsingErrorLevel.INFO, ErrorCode.TOPOLOGY_DETECTED, "", null, "A topology template has been detected", null, archiveName));
    topologyServiceCore.saveTopology(topology);
    topologySubstitutionService.updateSubstitutionType(topology, archiveRoot.getArchive());
}
Also used : ParsingError(alien4cloud.tosca.parser.ParsingError) Topology(org.alien4cloud.tosca.model.templates.Topology) TopologyContext(alien4cloud.paas.wf.TopologyContext) CSARDependency(org.alien4cloud.tosca.model.CSARDependency)

Example 38 with CSARDependency

use of org.alien4cloud.tosca.model.CSARDependency in project alien4cloud by alien4cloud.

the class ChangeDependencyVersionProcessor method process.

@Override
public void process(Csar csar, Topology topology, ChangeDependencyVersionOperation operation) {
    CSARDependency newDependency = new CSARDependency(operation.getDependencyName(), operation.getDependencyVersion());
    // Check for missing type and update the topology's dependencies
    topologyService.updateDependencies(EditionContextManager.get(), newDependency);
    topologyService.recover(topology, newDependency);
}
Also used : CSARDependency(org.alien4cloud.tosca.model.CSARDependency)

Example 39 with CSARDependency

use of org.alien4cloud.tosca.model.CSARDependency in project alien4cloud by alien4cloud.

the class EditorTopologyRecoveryHelperService method getUpdatedDependencyIfNeeded.

/**
 * Update a dependency according to what is currently in the repository
 *
 * @param initialDependency
 * @return
 */
private CSARDependency getUpdatedDependencyIfNeeded(CSARDependency initialDependency) {
    CSARDependency updatedDependency = null;
    Csar csar = csarService.getOrFail(initialDependency.getName(), initialDependency.getVersion());
    if ((StringUtils.isNotBlank(initialDependency.getHash()) || StringUtils.isNotBlank(csar.getHash())) && !Objects.equals(initialDependency.getHash(), csar.getHash())) {
        updatedDependency = new CSARDependency(csar.getName(), csar.getVersion(), csar.getHash());
    }
    return updatedDependency;
}
Also used : Csar(org.alien4cloud.tosca.model.Csar) CSARDependency(org.alien4cloud.tosca.model.CSARDependency)

Example 40 with CSARDependency

use of org.alien4cloud.tosca.model.CSARDependency in project alien4cloud by alien4cloud.

the class EditorTopologyRecoveryHelperService method getUpdatedDependencies.

/**
 * Return a Set of updated {@link CSARDependency} that have changed since last added in a given topology
 *
 * @param topology
 * @return
 */
public Set<CSARDependency> getUpdatedDependencies(Topology topology) {
    Set<CSARDependency> dependencies = topology.getDependencies();
    Set<CSARDependency> updatedDependencies = Sets.newHashSet();
    for (CSARDependency csarDependency : dependencies) {
        CSARDependency updatedDependency = getUpdatedDependencyIfNeeded(csarDependency);
        if (updatedDependency != null) {
            updatedDependencies.add(updatedDependency);
        }
    }
    return updatedDependencies;
}
Also used : CSARDependency(org.alien4cloud.tosca.model.CSARDependency)

Aggregations

CSARDependency (org.alien4cloud.tosca.model.CSARDependency)50 Csar (org.alien4cloud.tosca.model.Csar)16 Test (org.junit.Test)11 NodeTemplate (org.alien4cloud.tosca.model.templates.NodeTemplate)8 Set (java.util.Set)7 ArchiveRoot (alien4cloud.tosca.model.ArchiveRoot)6 CapabilityType (org.alien4cloud.tosca.model.types.CapabilityType)6 ServiceResource (alien4cloud.model.service.ServiceResource)5 Capability (org.alien4cloud.tosca.model.templates.Capability)5 Topology (org.alien4cloud.tosca.model.templates.Topology)5 NodeType (org.alien4cloud.tosca.model.types.NodeType)5 NotFoundException (alien4cloud.exception.NotFoundException)4 ParsingError (alien4cloud.tosca.parser.ParsingError)4 HashSet (java.util.HashSet)4 CsarDependenciesBean (org.alien4cloud.tosca.model.CsarDependenciesBean)4 LocationResourceTemplate (alien4cloud.model.orchestrators.locations.LocationResourceTemplate)3 ParsingException (alien4cloud.tosca.parser.ParsingException)3 VersionConflictException (alien4cloud.exception.VersionConflictException)2 DeploymentTopology (alien4cloud.model.deployment.DeploymentTopology)2 Location (alien4cloud.model.orchestrators.locations.Location)2