summaryrefslogtreecommitdiffstats
path: root/nokiav2/driver/src/main/java/org/onap/vfc
diff options
context:
space:
mode:
Diffstat (limited to 'nokiav2/driver/src/main/java/org/onap/vfc')
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapAbstractVnfdBuilder.java83
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapR1VnfdBuilder.java (renamed from nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfdBuilder.java)126
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapR2VnfdBuilder.java117
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfPackageBuilder.java (renamed from nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapR1VnfPackageBuilder.java)6
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/ConverterApi.java4
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java1
6 files changed, 117 insertions, 220 deletions
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapAbstractVnfdBuilder.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapAbstractVnfdBuilder.java
index f7f247a0..5e9be7f6 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapAbstractVnfdBuilder.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapAbstractVnfdBuilder.java
@@ -21,6 +21,7 @@ import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
+import java.util.HashMap;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
@@ -33,9 +34,9 @@ import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.childElem
import static org.slf4j.LoggerFactory.getLogger;
/**
- * Transforms a CBAM package into an ONAP package
+ * Generic non ONAP version dependent package conversion
*/
-public class OnapAbstractVnfdBuilder {
+abstract class OnapAbstractVnfdBuilder {
public static final String DESCRIPTION = "description";
public static final String PROPERTIES = "properties";
public static final String REQUIREMENTS = "requirements";
@@ -63,7 +64,7 @@ public class OnapAbstractVnfdBuilder {
return null;
}
- private JsonElement get(String name, Set<Map.Entry<String, JsonElement>> nodes) {
+ protected JsonElement get(String name, Set<Map.Entry<String, JsonElement>> nodes) {
for (Map.Entry<String, JsonElement> node : nodes) {
if (name.equals(node.getKey())) {
return node.getValue();
@@ -71,4 +72,80 @@ public class OnapAbstractVnfdBuilder {
}
throw new NoSuchElementException("The VNFD does not have a node called " + name + " but required by an other node");
}
+
+ protected String buildEcp(String name, JsonElement ecp, Set<Map.Entry<String, JsonElement>> nodes) {
+ if (ecp.getAsJsonObject().has(REQUIREMENTS)) {
+ String icpName = getRequirement(ecp.getAsJsonObject().get(REQUIREMENTS).getAsJsonArray(), "internal_connection_point");
+ if (icpName != null) {
+ return buildEcpInternal(name, icpName, nodes);
+ } else {
+ logger.warn("The {} ecp does not have an internal connection point", name);
+ }
+ } else {
+ logger.warn("The {} ecp does not have an requirements section", name);
+ }
+ return "";
+ }
+
+ private String buildEcpInternal(String ecpName, String icpName, Set<Map.Entry<String, JsonElement>> nodes) {
+ JsonObject icpNode = get(icpName, nodes).getAsJsonObject();
+ if (icpNode.has(REQUIREMENTS)) {
+ String vdu = getRequirement(icpNode.getAsJsonObject().get(REQUIREMENTS).getAsJsonArray(), "virtual_binding");
+ //internal connection point is bound to VDU
+ if (vdu != null) {
+ return buildVduCpd(ecpName, vdu, child(icpNode, PROPERTIES));
+ } else {
+ logger.warn("The {} internal connection point of the {} ecp does not have a VDU", icpName, ecpName);
+ }
+ } else {
+ logger.warn("The {} internal connection point of the {} ecp does not have a requirements section", icpName, ecpName);
+ }
+ return "";
+ }
+
+ /**
+ * @param cbamVnfd the CBAM VNFD
+ * @return the converted ONAP VNFD
+ */
+ public String toOnapVnfd(String cbamVnfd) {
+ JsonObject root = new Gson().toJsonTree(new Yaml().load(cbamVnfd)).getAsJsonObject();
+ JsonObject topologyTemplate = child(root, "topology_template");
+ JsonObject substitution_mappings = child(topologyTemplate, "substitution_mappings");
+ Map<String, JsonElement> virtualLinks = new HashMap<>();
+ if (topologyTemplate.has("node_templates")) {
+ Set<Map.Entry<String, JsonElement>> nodeTemplates = child(topologyTemplate, "node_templates").entrySet();
+ StringBuilder body = new StringBuilder();
+ for (Map.Entry<String, JsonElement> node : nodeTemplates) {
+ String type = childElement(node.getValue().getAsJsonObject(), "type").getAsString();
+ if ("tosca.nodes.nfv.VDU".equals(type)) {
+ body.append(buildVdu(node.getKey(), substitution_mappings, node.getValue().getAsJsonObject(), nodeTemplates));
+ } else if ("tosca.nodes.nfv.VirtualStorage".equals(type)) {
+ body.append(buildVolume(node.getKey(), node.getValue().getAsJsonObject()));
+ } else if ("tosca.nodes.nfv.VL".equals(type)) {
+ virtualLinks.put(node.getKey(), node.getValue());
+ body.append(buildVl(node.getValue().getAsJsonObject().get(PROPERTIES).getAsJsonObject(), node.getKey()));
+ } else if ("tosca.nodes.nfv.ICP".equals(type)) {
+ body.append(buildIcp(node.getKey(), node.getValue().getAsJsonObject()));
+ } else if ("tosca.nodes.nfv.ECP".equals(type)) {
+ body.append(buildEcp(node.getKey(), node.getValue(), nodeTemplates));
+ } else {
+ logger.warn("The {} type is not converted", type);
+ }
+ }
+ return buildHeader(topologyTemplate, virtualLinks) + body.toString();
+ }
+ return buildHeader(topologyTemplate, virtualLinks);
+ }
+
+ abstract protected String buildHeader(JsonObject toplogyTemplate, Map<String, JsonElement> virtualLinks);
+
+ abstract protected String buildVduCpd(String name, String vdu, JsonObject properties);
+
+ abstract protected String buildVdu(String name, JsonObject vnf, JsonObject vdu, Set<Map.Entry<String, JsonElement>> nodes);
+
+ abstract protected String buildIcp(String name, JsonObject icp);
+
+ abstract protected String buildVolume(String nodeName, JsonObject volume);
+
+ abstract protected String buildVl(JsonObject vlProperties, String name);
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfdBuilder.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapR1VnfdBuilder.java
index b5dd9616..4e0fbb0b 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfdBuilder.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapR1VnfdBuilder.java
@@ -16,90 +16,33 @@
package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer;
-import com.google.common.annotations.VisibleForTesting;
-import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.Map;
-import java.util.NoSuchElementException;
import java.util.Set;
-import java.util.regex.Pattern;
import org.slf4j.Logger;
-import org.yaml.snakeyaml.Yaml;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.child;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.childElement;
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager.ETSI_CONFIG;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Transforms a CBAM package into an ONAP package
*/
-public class OnapVnfdBuilder {
- public static final String DESCRIPTION = "description";
- public static final String PROPERTIES = "properties";
- public static final String REQUIREMENTS = "requirements";
- private static Logger logger = getLogger(OnapVnfdBuilder.class);
-
- @VisibleForTesting
- static String indent(String content, int prefixSize) {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < prefixSize; i++) {
- sb.append(" ");
- }
- Pattern pattern = Pattern.compile("^(.*)$", Pattern.MULTILINE);
- return pattern.matcher(content).replaceAll(sb.toString() + "$1");
- }
+public class OnapR1VnfdBuilder extends OnapAbstractVnfdBuilder {
+ private static Logger logger = getLogger(OnapR1VnfdBuilder.class);
private static String trimUnit(String data) {
- //FIXME the unit should not be trimmed VF-C bug
+ //The R1 templates in Amsterdam release can not handle the scalar-unit types in Tosca
+ //templates, so that the MB, GB, ... units need to be removed even though the created
+ //Tosca template will be invalid
return data.trim().replaceAll("[^0-9]", "");
}
- public static String getRequirement(JsonArray requirements, String key) {
- for (int i = 0; i < requirements.size(); i++) {
- JsonElement requirement = requirements.get(i);
- Map.Entry<String, JsonElement> next = requirement.getAsJsonObject().entrySet().iterator().next();
- String s = next.getKey();
- if (key.equals(s)) {
- return next.getValue().getAsString();
- }
- }
- return null;
- }
-
- /**
- * @param cbamVnfd the CBAM VNFD
- * @return the converted ONAP VNFD
- */
- public String toOnapVnfd(String cbamVnfd) {
- JsonObject root = new Gson().toJsonTree(new Yaml().load(cbamVnfd)).getAsJsonObject();
- JsonObject topologyTemplate = child(root, "topology_template");
- if (topologyTemplate.has("node_templates")) {
- Set<Map.Entry<String, JsonElement>> nodeTemplates = child(topologyTemplate, "node_templates").entrySet();
- StringBuilder body = new StringBuilder();
- for (Map.Entry<String, JsonElement> node : nodeTemplates) {
- String type = childElement(node.getValue().getAsJsonObject(), "type").getAsString();
- if ("tosca.nodes.nfv.VDU".equals(type)) {
- body.append(buildVdu(node.getKey(), node.getValue().getAsJsonObject(), nodeTemplates));
- } else if ("tosca.nodes.nfv.VirtualStorage".equals(type)) {
- body.append(buildVolume(node.getKey(), node.getValue().getAsJsonObject()));
- } else if ("tosca.nodes.nfv.VL".equals(type)) {
- body.append(buildVl(node.getKey()));
- } else if ("tosca.nodes.nfv.ICP".equals(type)) {
- body.append(buildIcp(node.getKey(), node.getValue().getAsJsonObject()));
- } else if ("tosca.nodes.nfv.ECP".equals(type)) {
- body.append(buildEcp(node.getKey(), node.getValue(), nodeTemplates));
- } else {
- logger.warn("The {} type is not converted", type);
- }
- }
- return buildHeader(topologyTemplate) + body.toString();
- }
- return buildHeader(topologyTemplate);
- }
-
- private String buildHeader(JsonObject toplogyTemplate) {
+ @Override
+ protected String buildHeader(JsonObject toplogyTemplate, Map<String, JsonElement> virtualLinks) {
JsonObject properties = child(child(toplogyTemplate, "substitution_mappings"), PROPERTIES);
String descriptorVersion = properties.get("descriptor_version").getAsString();
return "tosca_definitions_version: tosca_simple_yaml_1_0\n" +
@@ -115,22 +58,14 @@ public class OnapVnfdBuilder {
" vnfdVersion: " + descriptorVersion + "\n\n" +
"topology_template:\n" +
" inputs:\n" +
- " etsi_config:\n" +
+ " " + ETSI_CONFIG + ":\n" +
" type: string\n" +
" description: The ETSI configuration\n" +
" node_templates:\n";
}
- private JsonElement get(String name, Set<Map.Entry<String, JsonElement>> nodes) {
- for (Map.Entry<String, JsonElement> node : nodes) {
- if (name.equals(node.getKey())) {
- return node.getValue();
- }
- }
- throw new NoSuchElementException("The VNFD does not have a node called " + name + " but required by an other node");
- }
-
- private String buildVdu(String name, JsonObject vdu, Set<Map.Entry<String, JsonElement>> nodes) {
+ @Override
+ protected String buildVdu(String name, JsonObject vnf, JsonObject vdu, Set<Map.Entry<String, JsonElement>> nodes) {
String memorySize = "";
String cpuCount = "";
StringBuilder body = new StringBuilder();
@@ -167,37 +102,7 @@ public class OnapVnfdBuilder {
return header + body.toString();
}
- private String buildEcp(String name, JsonElement ecp, Set<Map.Entry<String, JsonElement>> nodes) {
- if (ecp.getAsJsonObject().has(REQUIREMENTS)) {
- String icpName = getRequirement(ecp.getAsJsonObject().get(REQUIREMENTS).getAsJsonArray(), "internal_connection_point");
- if (icpName != null) {
- return buildEcpInternal(name, icpName, nodes);
- } else {
- logger.warn("The {} ecp does not have an internal connection point", name);
- }
- } else {
- logger.warn("The {} ecp does not have an requirements section", name);
- }
- return "";
- }
-
- private String buildEcpInternal(String ecpName, String icpName, Set<Map.Entry<String, JsonElement>> nodes) {
- JsonObject icpNode = get(icpName, nodes).getAsJsonObject();
- if (icpNode.has(REQUIREMENTS)) {
- String vdu = getRequirement(icpNode.getAsJsonObject().get(REQUIREMENTS).getAsJsonArray(), "virtual_binding");
- //internal connection point is bound to VDU
- if (vdu != null) {
- return buildVduCpd(ecpName, vdu, child(icpNode, PROPERTIES));
- } else {
- logger.warn("The {} internal connection point of the {} ecp does not have a VDU", icpName, ecpName);
- }
- } else {
- logger.warn("The {} internal connection point of the {} ecp does not have a requirements section", icpName, ecpName);
- }
- return "";
- }
-
- private String buildIcp(String name, JsonObject icp) {
+ protected String buildIcp(String name, JsonObject icp) {
if (icp.has(REQUIREMENTS)) {
JsonArray requirements = icp.get(REQUIREMENTS).getAsJsonArray();
String vdu = getRequirement(requirements, "virtual_binding");
@@ -224,7 +129,7 @@ public class OnapVnfdBuilder {
return "";
}
- private String buildVduCpd(String name, String vdu, JsonObject properties) {
+ protected String buildVduCpd(String name, String vdu, JsonObject properties) {
return indent(name + ":\n" +
" type: tosca.nodes.nfv.VduCpd\n" +
" " + PROPERTIES + ":\n" +
@@ -236,7 +141,7 @@ public class OnapVnfdBuilder {
" - virtual_binding: " + vdu + "\n", 2);
}
- private String buildVolume(String nodeName, JsonObject volume) {
+ protected String buildVolume(String nodeName, JsonObject volume) {
return indent(nodeName + ":\n" +
" type: tosca.nodes.nfv.VDU.VirtualStorage\n" +
" properties:\n" +
@@ -245,7 +150,8 @@ public class OnapVnfdBuilder {
" size_of_storage: " + trimUnit(childElement(child(volume, PROPERTIES), "size_of_storage").getAsString()) + "\n", 2);
}
- private String buildVl(String name) {
+ @Override
+ protected String buildVl(JsonObject vlProperties, String name) {
return indent(name + ":\n" +
" type: tosca.nodes.nfv.VnfVirtualLinkDesc\n" +
" properties:\n" +
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapR2VnfdBuilder.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapR2VnfdBuilder.java
index 099f641c..e242284c 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapR2VnfdBuilder.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapR2VnfdBuilder.java
@@ -16,97 +16,39 @@
package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer;
-import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
-import java.util.HashMap;
import java.util.Map;
-import java.util.NoSuchElementException;
import java.util.Set;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManager;
import org.slf4j.Logger;
-import org.yaml.snakeyaml.Yaml;
-import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer.OnapVnfdBuilder.getRequirement;
-import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer.OnapVnfdBuilder.indent;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.child;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.childElement;
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager.ETSI_CONFIG;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Transforms a CBAM package into an ONAP package
*/
-public class OnapR2VnfdBuilder {
- public static final String DESCRIPTION = "description";
- public static final String PROPERTIES = "properties";
- public static final String REQUIREMENTS = "requirements";
+public class OnapR2VnfdBuilder extends OnapAbstractVnfdBuilder {
private static Logger logger = getLogger(OnapR2VnfdBuilder.class);
- private static String trimUnit(String data) {
- //FIXME the unit should not be trimmed VF-C bug
- return data;
- //data.trim().replaceAll("[^0-9]", "");
- }
-
- /**
- * @param cbamVnfd the CBAM VNFD
- * @return the converted ONAP VNFD
- */
- public String toOnapVnfd(String cbamVnfd) {
- JsonObject root = new Gson().toJsonTree(new Yaml().load(cbamVnfd)).getAsJsonObject();
- JsonObject topologyTemplate = child(root, "topology_template");
- JsonObject substitution_mappings = child(topologyTemplate, "substitution_mappings");
- Map<String, JsonElement> virtualLinks = new HashMap<>();
- if (topologyTemplate.has("node_templates")) {
- Set<Map.Entry<String, JsonElement>> nodeTemplates = child(topologyTemplate, "node_templates").entrySet();
-
- StringBuilder body = new StringBuilder();
- for (Map.Entry<String, JsonElement> node : nodeTemplates) {
- String type = childElement(node.getValue().getAsJsonObject(), "type").getAsString();
- if ("tosca.nodes.nfv.VDU".equals(type)) {
- body.append(buildVdu(node.getKey(), substitution_mappings, node.getValue().getAsJsonObject(), nodeTemplates));
- } else if ("tosca.nodes.nfv.VirtualStorage".equals(type)) {
- body.append(buildVolume(node.getKey(), node.getValue().getAsJsonObject()));
- } else if ("tosca.nodes.nfv.VL".equals(type)) {
- virtualLinks.put(node.getKey(), node.getValue());
- body.append(buildVl(node.getValue().getAsJsonObject().get(PROPERTIES).getAsJsonObject(), node.getKey()));
- } else if ("tosca.nodes.nfv.ICP".equals(type)) {
- body.append(buildIcp(node.getKey(), node.getValue().getAsJsonObject()));
- } else if ("tosca.nodes.nfv.ECP".equals(type)) {
- body.append(buildEcp(node.getKey(), node.getValue(), nodeTemplates));
- } else {
- logger.warn("The {} type is not converted", type);
- }
- }
- return buildHeader(topologyTemplate, virtualLinks) + body.toString();
- }
- return buildHeader(topologyTemplate, virtualLinks);
- }
-
- private String buildHeader(JsonObject toplogyTemplate, Map<String, JsonElement> virtualLinks) {
+ protected String buildHeader(JsonObject toplogyTemplate, Map<String, JsonElement> virtualLinks) {
JsonObject substitution_mappings = child(toplogyTemplate, "substitution_mappings");
String vnfContent = buildVnf(substitution_mappings, virtualLinks);
return "tosca_definitions_version: tosca_simple_profile_yaml_1_1\n" +
"\n" +
"topology_template:\n" +
" inputs:\n" +
- " etsi_config:\n" +
+ " " + ETSI_CONFIG + ":\n" +
" type: string\n" +
" description: The ETSI configuration\n" +
" node_templates:\n" + vnfContent;
}
- private JsonElement get(String name, Set<Map.Entry<String, JsonElement>> nodes) {
- for (Map.Entry<String, JsonElement> node : nodes) {
- if (name.equals(node.getKey())) {
- return node.getValue();
- }
- }
- throw new NoSuchElementException("The VNFD does not have a node called " + name + " but required by an other node");
- }
-
- private String buildVdu(String name, JsonObject vnf, JsonObject vdu, Set<Map.Entry<String, JsonElement>> nodes) {
+ protected String buildVdu(String name, JsonObject vnf, JsonObject vdu, Set<Map.Entry<String, JsonElement>> nodes) {
String memorySize = "";
String cpuCount = "";
StringBuilder body = new StringBuilder();
@@ -118,7 +60,7 @@ public class OnapR2VnfdBuilder {
if ("virtual_compute".equals(s)) {
JsonObject virtualCompute = get(next.getValue().getAsString(), nodes).getAsJsonObject();
cpuCount = childElement(child(child(virtualCompute, PROPERTIES), "virtual_cpu"), "num_virtual_cpu").getAsString();
- memorySize = trimUnit(childElement(child(child(virtualCompute, PROPERTIES), "virtual_memory"), "virtual_mem_size").getAsString());
+ memorySize = childElement(child(child(virtualCompute, PROPERTIES), "virtual_memory"), "virtual_mem_size").getAsString();
} else if ("virtual_storage".equals(s)) {
String item = indent(
"- virtual_storage:\n" +
@@ -144,27 +86,13 @@ public class OnapR2VnfdBuilder {
indent(
"properties:\n" +
" virtual_memory:\n" +
- " virtual_mem_size: " + trimUnit(memorySize) + "\n" +
+ " virtual_mem_size: " + memorySize + "\n" +
" virtual_cpu:\n" +
" num_virtual_cpu: " + cpuCount + "\n", 3) +
" " + REQUIREMENTS + ":\n", 2);
return header + body.toString();
}
- private String buildEcp(String name, JsonElement ecp, Set<Map.Entry<String, JsonElement>> nodes) {
- if (ecp.getAsJsonObject().has(REQUIREMENTS)) {
- String icpName = getRequirement(ecp.getAsJsonObject().get(REQUIREMENTS).getAsJsonArray(), "internal_connection_point");
- if (icpName != null) {
- return buildEcpInternal(name, icpName, nodes);
- } else {
- logger.warn("The {} ecp does not have an internal connection point", name);
- }
- } else {
- logger.warn("The {} ecp does not have an requirements section", name);
- }
- return "";
- }
-
private String buildVnf(JsonObject vnf, Map<String, JsonElement> virtualLinks) {
JsonObject vnfProperties = child(vnf, PROPERTIES);
JsonObject flavourProperties = child(child(child(vnf, "capabilities"), "deployment_flavour"), "properties");
@@ -192,23 +120,7 @@ public class OnapR2VnfdBuilder {
vlContent.toString();
}
- private String buildEcpInternal(String ecpName, String icpName, Set<Map.Entry<String, JsonElement>> nodes) {
- JsonObject icpNode = get(icpName, nodes).getAsJsonObject();
- if (icpNode.has(REQUIREMENTS)) {
- String vdu = getRequirement(icpNode.getAsJsonObject().get(REQUIREMENTS).getAsJsonArray(), "virtual_binding");
- //internal connection point is bound to VDU
- if (vdu != null) {
- return buildVduCpd(ecpName, vdu, child(icpNode, PROPERTIES));
- } else {
- logger.warn("The {} internal connection point of the {} ecp does not have a VDU", icpName, ecpName);
- }
- } else {
- logger.warn("The {} internal connection point of the {} ecp does not have a requirements section", icpName, ecpName);
- }
- return "";
- }
-
- private String buildIcp(String name, JsonObject icp) {
+ protected String buildIcp(String name, JsonObject icp) {
if (icp.has(REQUIREMENTS)) {
JsonArray requirements = icp.get(REQUIREMENTS).getAsJsonArray();
String vdu = getRequirement(requirements, "virtual_binding");
@@ -237,7 +149,7 @@ public class OnapR2VnfdBuilder {
return "";
}
- private String buildVduCpd(String name, String vdu, JsonObject properties) {
+ protected String buildVduCpd(String name, String vdu, JsonObject properties) {
return indent(name + ":\n" +
" type: tosca.nodes.nfv.VduCp\n" +
" " + PROPERTIES + ":\n" +
@@ -250,21 +162,22 @@ public class OnapR2VnfdBuilder {
" - virtual_binding: " + vdu + "\n", 2);
}
- private String buildVolume(String nodeName, JsonObject volume) {
+ protected String buildVolume(String nodeName, JsonObject volume) {
return indent(nodeName + ":\n" +
" type: tosca.nodes.nfv.Vdu.VirtualStorage\n" +
" properties:\n" +
" type_of_storage: volume\n" +
- " size_of_storage: " + trimUnit(childElement(child(volume, PROPERTIES), "size_of_storage").getAsString()) + "\n", 2);
+ " size_of_storage: " + childElement(child(volume, PROPERTIES), "size_of_storage").getAsString() + "\n", 2);
}
- private String buildVl(JsonObject vlProperties, String name) {
+ protected String buildVl(JsonObject vlProperties, String name) {
+ JsonObject connectivityType = child(vlProperties, "connectivity_type");
return indent(name + ":\n" +
" type: tosca.nodes.nfv.VnfVirtualLink\n" +
" properties:\n" +
" connectivity_type:\n" +
- " layer_protocol: [ " + childElement(child(vlProperties, "connectivity_type"), "layer_protocol").getAsString() + " ]\n" +
- " flow_pattern: " + childElement(child(vlProperties, "connectivity_type"), "flow_pattern").getAsString() + "\n" +
+ " layer_protocol: [ " + childElement(connectivityType, "layer_protocol").getAsString() + " ]\n" +
+ (connectivityType.has("flow_pattern") ? " flow_pattern: " + childElement(connectivityType, "flow_pattern").getAsString() + "\n" : "") +
" vl_profile:\n" +
" max_bit_rate_requirements:\n" +
" root: " + Integer.MAX_VALUE + "\n" + //FIXME GAP IN CBAM TEMPLATE
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapR1VnfPackageBuilder.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfPackageBuilder.java
index 6542a032..8de82347 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapR1VnfPackageBuilder.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfPackageBuilder.java
@@ -33,7 +33,7 @@ import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CatalogManager.getV
* Transforms a CBAM package into an ONAP package
*/
-public class OnapR1VnfPackageBuilder {
+public class OnapVnfPackageBuilder {
/**
* Entry point for the command line package transformer
@@ -41,7 +41,7 @@ public class OnapR1VnfPackageBuilder {
* @param args not used (required due to signature)
*/
public static void main(String[] args) throws Exception {
- byte[] covert = new OnapR1VnfPackageBuilder().covert(systemFunctions().in(), SupportedOnapPackageVersions.V1);
+ byte[] covert = new OnapVnfPackageBuilder().covert(systemFunctions().in(), SupportedOnapPackageVersions.V1);
systemFunctions().out().write(covert);
}
@@ -57,7 +57,7 @@ public class OnapR1VnfPackageBuilder {
byte[] cbamVnfdContent = vnfdContent.toByteArray();
String onapVnfd = SupportedOnapPackageVersions.V2 == version ?
new OnapR2VnfdBuilder().toOnapVnfd(new String(cbamVnfdContent, StandardCharsets.UTF_8)) :
- new OnapVnfdBuilder().toOnapVnfd(new String(cbamVnfdContent, StandardCharsets.UTF_8));
+ new OnapR1VnfdBuilder().toOnapVnfd(new String(cbamVnfdContent, StandardCharsets.UTF_8));
byte[] modifiedCbamPackage = new CbamVnfPackageBuilder().toModifiedCbamVnfPackage(cbamVnfPackage, vnfdLocation, new CbamVnfdBuilder().build(new String(cbamVnfdContent)));
return buildNewOnapPackage(modifiedCbamPackage, onapVnfd);
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/ConverterApi.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/ConverterApi.java
index 95438caa..758c8b3f 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/ConverterApi.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/ConverterApi.java
@@ -22,7 +22,7 @@ import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer.OnapR1VnfPackageBuilder;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer.OnapVnfPackageBuilder;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.packagetransformer.SupportedOnapPackageVersions;
import org.slf4j.Logger;
import org.springframework.stereotype.Controller;
@@ -47,7 +47,7 @@ import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RequestMapping(value = BASE_URL)
public class ConverterApi {
private static Logger logger = getLogger(ConverterApi.class);
- private OnapR1VnfPackageBuilder vnfPackageConverter = new OnapR1VnfPackageBuilder();
+ private OnapVnfPackageBuilder vnfPackageConverter = new OnapVnfPackageBuilder();
/**
* Return the converted ONAP package
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java
index f64ce1e0..7c8e2318 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java
@@ -334,6 +334,7 @@ public class LifecycleManager {
return child(child(operation.getValue().getAsJsonObject(), "inputs"), "additional_parameters").entrySet();
}
}
+
throw buildFatalFailure(logger, "Unable to find operation named " + operationName);
}