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());
}
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);
}
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;
}
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());
});
}
}
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);
}
}
Aggregations