Search in sources :

Example 11 with DeploymentArtifact

use of org.alien4cloud.tosca.model.definitions.DeploymentArtifact in project alien4cloud by alien4cloud.

the class TopologyStepDefinitions method The_topology_should_contain_a_nodetemplate_named_with_an_artifact_with_the_specified_UID.

@Then("^The topology should contain a nodetemplate named \"([^\"]*)\" with an artifact \"([^\"]*)\" with the specified UID and name \"([^\"]*)\"$")
public void The_topology_should_contain_a_nodetemplate_named_with_an_artifact_with_the_specified_UID(String nodeTemplateName, String artifactId, String artifactName) throws Throwable {
    The_topology_should_contain_a_nodetemplate_named(nodeTemplateName);
    String topologyResponseText = Context.getInstance().getRestResponse();
    NodeTemplate nodeTemp = JsonUtil.read(topologyResponseText, TopologyDTO.class, Context.getJsonMapper()).getData().getTopology().getNodeTemplates().get(nodeTemplateName);
    Assert.assertNotNull(nodeTemp.getArtifacts());
    Assert.assertFalse(nodeTemp.getArtifacts().isEmpty());
    DeploymentArtifact deploymentArtifact = nodeTemp.getArtifacts().get(artifactId);
    Assert.assertNotNull(deploymentArtifact);
    Assert.assertNotNull(deploymentArtifact.getArtifactType());
    Assert.assertEquals(artifactName, deploymentArtifact.getArtifactName());
}
Also used : NodeTemplate(org.alien4cloud.tosca.model.templates.NodeTemplate) DeploymentArtifact(org.alien4cloud.tosca.model.definitions.DeploymentArtifact) Then(cucumber.api.java.en.Then)

Example 12 with DeploymentArtifact

use of org.alien4cloud.tosca.model.definitions.DeploymentArtifact in project alien4cloud by alien4cloud.

the class InputArtifactService method updateInputArtifact.

public void updateInputArtifact(ApplicationEnvironment environment, Topology topology, String inputArtifactId, DeploymentArtifact updatedArtifact) {
    checkInputArtifactExist(inputArtifactId, topology);
    DeploymentInputs deploymentInputs = getDeploymentInputs(environment.getTopologyVersion(), environment.getId());
    DeploymentArtifact artifact = getDeploymentArtifact(inputArtifactId, deploymentInputs);
    artifact.setArtifactName(updatedArtifact.getArtifactName());
    artifact.setArtifactRef(updatedArtifact.getArtifactRef());
    artifact.setArtifactRepository(updatedArtifact.getArtifactRepository());
    artifact.setArtifactType(updatedArtifact.getArtifactType());
    artifact.setRepositoryName(updatedArtifact.getRepositoryName());
    artifact.setRepositoryURL(updatedArtifact.getRepositoryURL());
    artifact.setRepositoryCredential(updatedArtifact.getRepositoryCredential());
    artifact.setArchiveName(updatedArtifact.getArchiveName());
    artifact.setArchiveVersion(updatedArtifact.getArchiveVersion());
    deploymentConfigurationDao.save(deploymentInputs);
}
Also used : DeploymentInputs(org.alien4cloud.alm.deployment.configuration.model.DeploymentInputs) DeploymentArtifact(org.alien4cloud.tosca.model.definitions.DeploymentArtifact)

Example 13 with DeploymentArtifact

use of org.alien4cloud.tosca.model.definitions.DeploymentArtifact in project alien4cloud by alien4cloud.

the class InputArtifactService method getDeploymentArtifact.

private DeploymentArtifact getDeploymentArtifact(String inputArtifactId, DeploymentInputs inputs) {
    Map<String, DeploymentArtifact> artifacts = inputs.getInputArtifacts();
    if (artifacts == null) {
        artifacts = new HashMap<>();
        inputs.setInputArtifacts(artifacts);
    }
    DeploymentArtifact artifact = artifacts.get(inputArtifactId);
    if (artifact == null) {
        artifact = new DeploymentArtifact();
        artifacts.put(inputArtifactId, artifact);
    } else if (ArtifactRepositoryConstants.ALIEN_ARTIFACT_REPOSITORY.equals(artifact.getArtifactRepository())) {
        artifactRepository.deleteFile(artifact.getArtifactRef());
    }
    return artifact;
}
Also used : DeploymentArtifact(org.alien4cloud.tosca.model.definitions.DeploymentArtifact)

Example 14 with DeploymentArtifact

use of org.alien4cloud.tosca.model.definitions.DeploymentArtifact in project alien4cloud by alien4cloud.

the class ArtifactProcessorService method processDeploymentArtifacts.

private void processDeploymentArtifacts(PaaSTopologyDeploymentContext deploymentContext) {
    if (deploymentContext.getDeploymentTopology().getNodeTemplates() != null) {
        // Artifact which comes from the archive or from internal repository
        getDeploymentArtifactStream(deploymentContext).filter(deploymentArtifact -> !isArtifactFromTopologyEditor(deploymentArtifact)).forEach(this::processArtifact);
        // Artifact which does not come from the archive, which comes from topology's edition
        getDeploymentArtifactStream(deploymentContext).filter(this::isArtifactFromTopologyEditor).forEach(deploymentArtifact -> {
            Path artifactPath = editorRepositoryService.resolveArtifact(deploymentContext.getDeploymentTopology().getInitialTopologyId(), deploymentArtifact.getArtifactRef());
            deploymentArtifact.setArtifactPath(artifactPath.toString());
        });
    }
}
Also used : URL(java.net.URL) PaaSTopologyDeploymentContext(alien4cloud.paas.model.PaaSTopologyDeploymentContext) PaaSRelationshipTemplate(alien4cloud.paas.model.PaaSRelationshipTemplate) PaaSNodeTemplate(alien4cloud.paas.model.PaaSNodeTemplate) AlienUtils.safe(alien4cloud.utils.AlienUtils.safe) StandardCopyOption(java.nio.file.StandardCopyOption) Value(org.springframework.beans.factory.annotation.Value) IFileRepository(alien4cloud.component.repository.IFileRepository) Map(java.util.Map) Interface(org.alien4cloud.tosca.model.definitions.Interface) FileUtil(alien4cloud.utils.FileUtil) Path(java.nio.file.Path) ArtifactRepositoryConstants(alien4cloud.component.repository.ArtifactRepositoryConstants) DeploymentArtifact(org.alien4cloud.tosca.model.definitions.DeploymentArtifact) EditorRepositoryService(org.alien4cloud.tosca.editor.EditorRepositoryService) MalformedURLException(java.net.MalformedURLException) Files(java.nio.file.Files) UnresolvableArtifactException(alien4cloud.deployment.exceptions.UnresolvableArtifactException) Resource(javax.annotation.Resource) IOException(java.io.IOException) CsarFileRepository(org.alien4cloud.tosca.catalog.repository.CsarFileRepository) AbstractArtifact(org.alien4cloud.tosca.model.definitions.AbstractArtifact) NotFoundException(alien4cloud.exception.NotFoundException) RepositoryService(alien4cloud.repository.services.RepositoryService) Component(org.springframework.stereotype.Component) Slf4j(lombok.extern.slf4j.Slf4j) Stream(java.util.stream.Stream) FilenameUtils(org.apache.commons.io.FilenameUtils) InputStream(java.io.InputStream) Path(java.nio.file.Path)

Example 15 with DeploymentArtifact

use of org.alien4cloud.tosca.model.definitions.DeploymentArtifact in project alien4cloud by alien4cloud.

the class InputArtifactService method updateInputArtifact.

/**
 * Update an input artifact value in the deployment topology
 *
 * @param environment The environment for which to update the input artifact.
 * @param topology The topology for which to update the artifact.
 * @param inputArtifactId The id of the input artifact to update.
 * @param artifactFile The file
 * @throws IOException
 */
public void updateInputArtifact(ApplicationEnvironment environment, Topology topology, String inputArtifactId, MultipartFile artifactFile) throws IOException {
    checkInputArtifactExist(inputArtifactId, topology);
    DeploymentInputs deploymentInputs = getDeploymentInputs(environment.getTopologyVersion(), environment.getId());
    // FIXME ensure that deployment inputs are up-to date
    DeploymentArtifact artifact = getDeploymentArtifact(inputArtifactId, deploymentInputs);
    try (InputStream artifactStream = artifactFile.getInputStream()) {
        String artifactFileId = artifactRepository.storeFile(artifactStream);
        artifact.setArtifactName(artifactFile.getOriginalFilename());
        artifact.setArtifactRef(artifactFileId);
        artifact.setArtifactRepository(ArtifactRepositoryConstants.ALIEN_ARTIFACT_REPOSITORY);
        artifact.setRepositoryName(null);
        artifact.setRepositoryURL(null);
        deploymentConfigurationDao.save(deploymentInputs);
    }
}
Also used : DeploymentInputs(org.alien4cloud.alm.deployment.configuration.model.DeploymentInputs) InputStream(java.io.InputStream) DeploymentArtifact(org.alien4cloud.tosca.model.definitions.DeploymentArtifact)

Aggregations

DeploymentArtifact (org.alien4cloud.tosca.model.definitions.DeploymentArtifact)25 NodeTemplate (org.alien4cloud.tosca.model.templates.NodeTemplate)10 NotFoundException (alien4cloud.exception.NotFoundException)6 Map (java.util.Map)5 DeploymentInputs (org.alien4cloud.alm.deployment.configuration.model.DeploymentInputs)5 Topology (org.alien4cloud.tosca.model.templates.Topology)5 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 ApplicationEnvironment (alien4cloud.model.application.ApplicationEnvironment)3 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 ArtifactRepositoryConstants (alien4cloud.component.repository.ArtifactRepositoryConstants)2 IFileRepository (alien4cloud.component.repository.IFileRepository)2 ArchiveRoot (alien4cloud.tosca.model.ArchiveRoot)2 AlienUtils.safe (alien4cloud.utils.AlienUtils.safe)2 Path (java.nio.file.Path)2 Entry (java.util.Map.Entry)2 Set (java.util.Set)2 Resource (javax.annotation.Resource)2 Interface (org.alien4cloud.tosca.model.definitions.Interface)2