summaryrefslogtreecommitdiffstats
path: root/appc-dg/appc-dg-shared/appc-dg-dependency-model/src
diff options
context:
space:
mode:
authorPatrick Brady <pb071s@att.com>2017-07-28 11:29:23 -0700
committerPatrick Brady <pb071s@att.com>2017-08-02 15:43:44 +0000
commit38713207b817ed4700f630748c681116338d32f0 (patch)
tree9eb2097cee8d85ac14f17e3a280ae8aefb69d9de /appc-dg/appc-dg-shared/appc-dg-dependency-model/src
parent771ac55e29d099d8bbf783612de975047d75ab12 (diff)
Merging in bug fixes
Change-Id: I85da90b9ba0d03149f42035a820c76ef0285e413 Signed-off-by: Patrick Brady <pb071s@att.com> Issue: APPC-100
Diffstat (limited to 'appc-dg/appc-dg-shared/appc-dg-dependency-model/src')
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/openecomp/appc/dg/dependencymanager/helper/DependencyModelParser.java25
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/openecomp/appc/dg/objects/VnfcDependencyModel.java2
2 files changed, 17 insertions, 10 deletions
diff --git a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/openecomp/appc/dg/dependencymanager/helper/DependencyModelParser.java b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/openecomp/appc/dg/dependencymanager/helper/DependencyModelParser.java
index 222e3a02a..c06841251 100644
--- a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/openecomp/appc/dg/dependencymanager/helper/DependencyModelParser.java
+++ b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/openecomp/appc/dg/dependencymanager/helper/DependencyModelParser.java
@@ -68,7 +68,6 @@ public class DependencyModelParser {
String prefix = "org.openecomp.resource.vfc."+vnfType+".abstract.nodes.";
try {
ObjectNode root = (ObjectNode) mapper.readTree(vnfModel);
- logger.debug("VNF Model after parsing: " + root);
if(root.get(TOPOLOGY_TEMPLATE) == null || root.get(TOPOLOGY_TEMPLATE).get("node_templates") == null) {
throw new InvalidDependencyModel("Dependency model is missing 'topology_template' or 'node_templates' elements");
@@ -79,7 +78,8 @@ public class DependencyModelParser {
Iterator<Map.Entry<String, JsonNode>> itretor = nodeTemplateNode.fields();
for (JsonNode yamlNode : nodeTemplateNode) {
logger.debug("Processing node: " + yamlNode);
- String vnfcType = itretor.next().getKey();
+ String fullvnfcType = itretor.next().getValue().get("type").textValue();
+ String vnfcType= getQualifiedVnfcType(fullvnfcType);
String type = yamlNode.get("type").textValue();
type = type.substring(0,type.lastIndexOf(".")+1);
if(type.concat(vnfcType).toLowerCase().startsWith(prefix.concat(vnfcType).toLowerCase())) {
@@ -95,7 +95,7 @@ public class DependencyModelParser {
}else {
mandatory = yamlNode.get(PROPERTIES).findValue(MANDATORY).booleanValue();
}
- String[] parentList = getDependencyArray(yamlNode);
+ String[] parentList = getDependencyArray(yamlNode,nodeTemplateNode);
Node<Vnfc> vnfcNode = getNode(dependencies, vnfcType);
if (vnfcNode != null) {
logger.debug("Dependency node already exists for vnfc Type: " + vnfcType);
@@ -126,6 +126,10 @@ public class DependencyModelParser {
return new VnfcDependencyModel(dependencies);
}
+ private String getQualifiedVnfcType(String fullvnfcType) {
+ return fullvnfcType.substring(fullvnfcType.lastIndexOf(".")+1,fullvnfcType.length());
+ }
+
private void addDependencies(Set<Node<Vnfc>> nodes, Node node, String[] parentList) {
for (String type : parentList) {
String parentType = getVnfcType(type);
@@ -143,15 +147,18 @@ public class DependencyModelParser {
}
}
- private String[] getDependencyArray(JsonNode node) {
+ private String[] getDependencyArray(JsonNode node, JsonNode nodeTemplateNode) {
JsonNode requirementsNode = node.get("requirements");
List<String> dependencyList = new ArrayList();
if(requirementsNode!=null) {
for (JsonNode internalNode : requirementsNode) {
- if (nodeNullCheck(internalNode) &&"tosca.capabilities.Node".equalsIgnoreCase(internalNode.get("capability").asText())
- && "tosca.relationships.DependsOn".equalsIgnoreCase(internalNode.get("relationship").asText())) {
- if(internalNode.get("node") != null) {
- dependencyList.add(internalNode.get("node").asText());
+ //TODO : In this release we are supporting both relationship = tosca.capabilities.Node and relationship =tosca.relationships.DependsOn we need to remove one of them in next release post confirming with SDC team
+ if (nodeNullCheck(internalNode) &&"tosca.capabilities.Node".equalsIgnoreCase(internalNode.findValue("capability").asText())
+ && ("tosca.relationships.DependsOn".equalsIgnoreCase(internalNode.findValue("relationship").asText()) || "tosca.capabilities.Node".equalsIgnoreCase(internalNode.findValue("relationship").asText()))) {
+ if(internalNode.findValue("node") != null) {
+ String nodeName = internalNode.findValue("node").asText();
+ String fullVnfcName = nodeTemplateNode.get(nodeName).get("type").asText();
+ dependencyList.add(getQualifiedVnfcType(fullVnfcName));
}else{
throw new InvalidDependencyModel("Error parsing dependency model. " + "Dependent Node not found for "+ node.get("type"));
}
@@ -164,7 +171,7 @@ public class DependencyModelParser {
}
private boolean nodeNullCheck(JsonNode internalNode) {
- return internalNode.get("dependency") != null && internalNode.get("capability") != null && internalNode.get("relationship") != null;
+ return internalNode.get("dependency") != null && internalNode.findValue("capability") != null && internalNode.findValue("relationship") != null;
}
private Node<Vnfc> getNode(Set<Node<Vnfc>> nodes, String vnfcType) {
diff --git a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/openecomp/appc/dg/objects/VnfcDependencyModel.java b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/openecomp/appc/dg/objects/VnfcDependencyModel.java
index 0eb11bf20..f8b0d0381 100644
--- a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/openecomp/appc/dg/objects/VnfcDependencyModel.java
+++ b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/openecomp/appc/dg/objects/VnfcDependencyModel.java
@@ -46,6 +46,6 @@ public class VnfcDependencyModel {
for(Node node:dependencies){
stringBuilder.append(node.toString()).append(", ");
}
- return super.toString();
+ return stringBuilder.toString();
}
}