use of alien4cloud.paas.model.PaaSNodeTemplate in project alien4cloud by alien4cloud.
the class TopologyTreeBuilderService method processRelationship.
private void processRelationship(PaaSNodeTemplate paaSNodeTemplate, Map<String, PaaSNodeTemplate> nodeTemplates) {
PaaSRelationshipTemplate hostedOnRelationship = getPaaSRelationshipTemplateFromType(paaSNodeTemplate, NormativeRelationshipConstants.HOSTED_ON);
if (hostedOnRelationship != null) {
String target = hostedOnRelationship.getTemplate().getTarget();
PaaSNodeTemplate parent = nodeTemplates.get(target);
parent.getChildren().add(paaSNodeTemplate);
paaSNodeTemplate.setParent(parent);
}
// Relationships are defined from sources to target. We have to make sure that target node also has the relationship injected.
List<PaaSRelationshipTemplate> allRelationships = getPaaSRelationshipsTemplateFromType(paaSNodeTemplate, NormativeRelationshipConstants.ROOT);
for (PaaSRelationshipTemplate relationship : allRelationships) {
// inject the relationship in it's target.
String target = relationship.getTemplate().getTarget();
nodeTemplates.get(target).getRelationshipTemplates().add(relationship);
}
}
use of alien4cloud.paas.model.PaaSNodeTemplate in project alien4cloud by alien4cloud.
the class TopologyTreeBuilderService method processBlockStorage.
private void processBlockStorage(PaaSNodeTemplate paaSNodeTemplate, Map<String, PaaSNodeTemplate> nodeTemplates) {
PaaSRelationshipTemplate attachTo = getPaaSRelationshipTemplateFromType(paaSNodeTemplate, NormativeRelationshipConstants.ATTACH_TO);
if (attachTo != null) {
String target = attachTo.getTemplate().getTarget();
PaaSNodeTemplate parent = nodeTemplates.get(target);
parent.getStorageNodes().add(paaSNodeTemplate);
paaSNodeTemplate.setParent(parent);
}
}
use of alien4cloud.paas.model.PaaSNodeTemplate in project alien4cloud by alien4cloud.
the class TopologyTreeBuilderService method processOperationsOutputs.
/**
* For every templates (nodes and relationship), check the attributes and interfaces operations input parameters for usage of the get_operation_output
* function.
* if found, register the referenced output on the related operation
*
* @param paaSNodeTemplates
*/
private void processOperationsOutputs(final Map<String, PaaSNodeTemplate> paaSNodeTemplates) {
// TODO: try to cache already processed nodes
for (PaaSNodeTemplate paaSNodeTemplate : paaSNodeTemplates.values()) {
processAttributesForOperationOutputs(paaSNodeTemplate, paaSNodeTemplates);
processOperationsInputsForOperationOutputs(paaSNodeTemplate, paaSNodeTemplates);
// do the same for the relationships
for (PaaSRelationshipTemplate paaSRelationshipTemplate : paaSNodeTemplate.getRelationshipTemplates()) {
processAttributesForOperationOutputs(paaSRelationshipTemplate, paaSNodeTemplates);
processOperationsInputsForOperationOutputs(paaSRelationshipTemplate, paaSNodeTemplates);
}
}
}
use of alien4cloud.paas.model.PaaSNodeTemplate in project alien4cloud by alien4cloud.
the class TopologyTreeBuilderService method processNetwork.
private void processNetwork(PaaSNodeTemplate paaSNodeTemplate, Map<String, PaaSNodeTemplate> nodeTemplates) {
List<PaaSRelationshipTemplate> networkRelationships = getPaaSRelationshipsTemplateFromType(paaSNodeTemplate, NormativeRelationshipConstants.NETWORK);
List<PaaSNodeTemplate> networks = Lists.newArrayList();
if (networkRelationships != null && !networkRelationships.isEmpty()) {
for (PaaSRelationshipTemplate networkRelationship : networkRelationships) {
String target = networkRelationship.getTemplate().getTarget();
PaaSNodeTemplate network = nodeTemplates.get(target);
networks.add(network);
network.setParent(paaSNodeTemplate);
}
}
paaSNodeTemplate.setNetworkNodes(networks);
}
use of alien4cloud.paas.model.PaaSNodeTemplate in project alien4cloud by alien4cloud.
the class TopologyTreeBuilderService method buildPaaSNodeTemplates.
/**
* Fetch information from the repository to complete the topology node template informations with additional data such as artifacts paths etc.
*
* @param topology The topology for which to build PaaSNodeTemplate map.
* @return A map of PaaSNodeTemplate that match the one of the NodeTempaltes in the given topology (and filled with artifact paths etc.).
*/
public Map<String, PaaSNodeTemplate> buildPaaSNodeTemplates(Topology topology) {
Map<String, PaaSNodeTemplate> nodeTemplates = Maps.newHashMap();
// Fill in PaaSNodeTemplate by fetching node types and CSAR path from the repositories.
if (topology.getNodeTemplates() != null) {
for (Entry<String, NodeTemplate> templateEntry : topology.getNodeTemplates().entrySet()) {
NodeTemplate template = templateEntry.getValue();
PaaSNodeTemplate paaSNodeTemplate = new PaaSNodeTemplate(templateEntry.getKey(), template);
fillType(topology, template, paaSNodeTemplate, NodeType.class);
mergeInterfaces(paaSNodeTemplate, template);
if (template.getRelationships() != null) {
for (Map.Entry<String, RelationshipTemplate> relationshipEntry : template.getRelationships().entrySet()) {
RelationshipTemplate relationshipTemplate = relationshipEntry.getValue();
PaaSRelationshipTemplate paaSRelationshipTemplate = new PaaSRelationshipTemplate(relationshipEntry.getKey(), relationshipTemplate, paaSNodeTemplate.getId());
fillType(topology, relationshipTemplate, paaSRelationshipTemplate, RelationshipType.class);
mergeInterfaces(paaSRelationshipTemplate, relationshipTemplate);
paaSNodeTemplate.getRelationshipTemplates().add(paaSRelationshipTemplate);
}
}
Capability scalableCapability = TopologyUtils.getScalableCapability(topology, templateEntry.getKey(), false);
if (scalableCapability != null) {
ScalingPolicy scalingPolicy = TopologyUtils.getScalingPolicy(scalableCapability);
// A node with a scaling policy 1, 1, 1 is a simple node and so do not set scaling policy
if (!ScalingPolicy.NOT_SCALABLE_POLICY.equals(scalingPolicy)) {
paaSNodeTemplate.setScalingPolicy(scalingPolicy);
}
}
if (topology.getGroups() != null) {
Set<String> nodeGroups = Sets.newHashSet();
for (Map.Entry<String, NodeGroup> groupEntry : topology.getGroups().entrySet()) {
if (groupEntry.getValue().getMembers() != null && groupEntry.getValue().getMembers().contains(templateEntry.getKey())) {
nodeGroups.add(groupEntry.getKey());
}
}
paaSNodeTemplate.setGroups(nodeGroups);
}
nodeTemplates.put(templateEntry.getKey(), paaSNodeTemplate);
}
}
return nodeTemplates;
}
Aggregations