use of org.alien4cloud.tosca.model.definitions.DeploymentArtifact in project alien4cloud by alien4cloud.
the class InputArtifactService method onCopyConfiguration.
@EventListener
@Order(11)
public void onCopyConfiguration(OnDeploymentConfigCopyEvent onDeploymentConfigCopyEvent) {
ApplicationEnvironment source = onDeploymentConfigCopyEvent.getSourceEnvironment();
ApplicationEnvironment target = onDeploymentConfigCopyEvent.getTargetEnvironment();
DeploymentInputs deploymentInputs = deploymentConfigurationDao.findById(DeploymentInputs.class, AbstractDeploymentConfig.generateId(source.getTopologyVersion(), source.getId()));
if (deploymentInputs == null || MapUtils.isEmpty(deploymentInputs.getInputArtifacts())) {
// Nothing to copy
return;
}
Topology topology = topologyServiceCore.getOrFail(Csar.createId(target.getApplicationId(), target.getTopologyVersion()));
if (MapUtils.isNotEmpty(topology.getInputArtifacts())) {
Map<String, DeploymentArtifact> inputsArtifactsDefinitions = topology.getInputArtifacts();
// Copy only artifacts which exists in the new topology's definition
Map<String, DeploymentArtifact> inputsArtifactsToCopy = deploymentInputs.getInputArtifacts().entrySet().stream().filter(inputEntry -> inputsArtifactsDefinitions.containsKey(inputEntry.getKey())).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
if (MapUtils.isNotEmpty(inputsArtifactsToCopy)) {
// There's something to copy
DeploymentInputs targetDeploymentInputs = deploymentConfigurationDao.findById(DeploymentInputs.class, AbstractDeploymentConfig.generateId(target.getTopologyVersion(), target.getId()));
if (targetDeploymentInputs == null) {
targetDeploymentInputs = new DeploymentInputs(target.getTopologyVersion(), target.getId());
}
targetDeploymentInputs.setInputArtifacts(inputsArtifactsToCopy);
deploymentConfigurationDao.save(targetDeploymentInputs);
}
}
}
use of org.alien4cloud.tosca.model.definitions.DeploymentArtifact in project alien4cloud by alien4cloud.
the class SetNodeArtifactAsInputProcessor method processNodeOperation.
@Override
protected void processNodeOperation(Csar csar, Topology topology, SetNodeArtifactAsInputOperation operation, NodeTemplate nodeTemplate) {
if (safe(nodeTemplate.getArtifacts()).get(operation.getArtifactName()) == null) {
throw new NotFoundException("The artifact <" + operation.getArtifactName() + "> cannot be found on node <" + operation.getNodeName() + ">");
}
DeploymentArtifact artifact = nodeTemplate.getArtifacts().get(operation.getArtifactName());
if (!safe(topology.getInputArtifacts()).containsKey(operation.getInputName())) {
// we have to create the artifact
operation.setNewArtifact(true);
DeploymentArtifact inputArtifact = new DeploymentArtifact();
inputArtifact.setArchiveName(artifact.getArchiveName());
inputArtifact.setArchiveVersion(artifact.getArchiveVersion());
inputArtifact.setArtifactType(artifact.getArtifactType());
Map<String, DeploymentArtifact> inputArtifacts = topology.getInputArtifacts();
if (inputArtifacts == null) {
inputArtifacts = Maps.newHashMap();
topology.setInputArtifacts(inputArtifacts);
}
inputArtifacts.put(operation.getInputName(), inputArtifact);
}
InputArtifactUtil.setInputArtifact(artifact, operation.getInputName());
}
use of org.alien4cloud.tosca.model.definitions.DeploymentArtifact in project alien4cloud by alien4cloud.
the class DeleteFileProcessor method process.
@Override
public void process(Csar csar, Topology topology, DeleteFileOperation operation) {
if (csar.getYamlFilePath().equals(operation.getPath())) {
throw new InvalidPathException("Topology yaml file cannot be removed.");
}
TreeNode target = FileProcessorHelper.getFileTreeNode(operation.getPath());
target.getParent().getChildren().remove(target);
for (NodeTemplate nodeTemplate : safe(topology.getNodeTemplates()).values()) {
for (DeploymentArtifact artifact : safe(nodeTemplate.getArtifacts()).values()) {
resetRemovedArtifact(artifact, operation.getPath());
}
cleanupInterfaces(nodeTemplate.getInterfaces(), operation.getPath());
for (RelationshipTemplate relationshipTemplate : safe(nodeTemplate.getRelationships()).values()) {
cleanupInterfaces(relationshipTemplate.getInterfaces(), operation.getPath());
}
}
}
use of org.alien4cloud.tosca.model.definitions.DeploymentArtifact in project alien4cloud by alien4cloud.
the class UpdateNodeDeploymentArtifactProcessor method process.
@Override
public void process(Csar csar, Topology topology, UpdateNodeDeploymentArtifactOperation operation) {
// Get the node template's artifacts to update
Map<String, NodeTemplate> nodeTemplates = TopologyUtils.getNodeTemplates(topology);
NodeTemplate nodeTemplate = TopologyUtils.getNodeTemplate(topology.getId(), operation.getNodeName(), nodeTemplates);
DeploymentArtifact artifact = nodeTemplate.getArtifacts() == null ? null : nodeTemplate.getArtifacts().get(operation.getArtifactName());
if (artifact == null) {
throw new NotFoundException("Artifact with key [" + operation.getArtifactName() + "] do not exist");
}
if (operation.getArtifactRepository() == null) {
// this is an archive file, ensure that the file exists within the archive
FileProcessorHelper.getFileTreeNode(operation.getArtifactReference());
artifact.setArtifactRepository(ArtifactRepositoryConstants.ALIEN_TOPOLOGY_REPOSITORY);
artifact.setRepositoryName(null);
artifact.setRepositoryURL(null);
} else {
artifact.setArtifactRepository(operation.getArtifactRepository());
artifact.setRepositoryName(operation.getRepositoryName());
artifact.setRepositoryURL(operation.getRepositoryUrl());
}
artifact.setArtifactRef(operation.getArtifactReference());
artifact.setArchiveName(operation.getArchiveName());
artifact.setArchiveVersion(operation.getArchiveVersion());
}
use of org.alien4cloud.tosca.model.definitions.DeploymentArtifact in project alien4cloud by alien4cloud.
the class ToscaSerializerUtilsTest method createArtifact.
private DeploymentArtifact createArtifact() {
DeploymentArtifact deploymentArtifact = new DeploymentArtifact();
deploymentArtifact.setArchiveName("test");
deploymentArtifact.setArchiveVersion("1.0");
return deploymentArtifact;
}
Aggregations