summaryrefslogtreecommitdiffstats
path: root/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfdBuilder.java
diff options
context:
space:
mode:
Diffstat (limited to 'nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfdBuilder.java')
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfdBuilder.java60
1 files changed, 18 insertions, 42 deletions
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/OnapVnfdBuilder.java
index 406f0033..b5dd9616 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/OnapVnfdBuilder.java
@@ -56,6 +56,18 @@ public class OnapVnfdBuilder {
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
@@ -104,8 +116,8 @@ public class OnapVnfdBuilder {
"topology_template:\n" +
" inputs:\n" +
" etsi_config:\n" +
- " type: string\n"+
- " description: The ETSI configuration\n"+
+ " type: string\n" +
+ " description: The ETSI configuration\n" +
" node_templates:\n";
}
@@ -157,7 +169,7 @@ public class OnapVnfdBuilder {
private String buildEcp(String name, JsonElement ecp, Set<Map.Entry<String, JsonElement>> nodes) {
if (ecp.getAsJsonObject().has(REQUIREMENTS)) {
- String icpName = getIcpName(ecp.getAsJsonObject().get(REQUIREMENTS).getAsJsonArray());
+ String icpName = getRequirement(ecp.getAsJsonObject().get(REQUIREMENTS).getAsJsonArray(), "internal_connection_point");
if (icpName != null) {
return buildEcpInternal(name, icpName, nodes);
} else {
@@ -172,7 +184,7 @@ public class OnapVnfdBuilder {
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 = getVduOfIcp(icpNode.getAsJsonObject().get(REQUIREMENTS).getAsJsonArray());
+ 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));
@@ -185,47 +197,11 @@ public class OnapVnfdBuilder {
return "";
}
- private String getVduOfIcp(JsonArray icpRequirements) {
- String vdu = null;
- for (int i = 0; i < icpRequirements.size(); i++) {
- JsonElement requirement = icpRequirements.get(i);
- Map.Entry<String, JsonElement> next = requirement.getAsJsonObject().entrySet().iterator().next();
- String s = next.getKey();
- if ("virtual_binding".equals(s)) {
- vdu = next.getValue().getAsString();
- }
- }
- return vdu;
- }
-
- private String getIcpName(JsonArray requirements) {
- String icpName = null;
- 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 ("internal_connection_point".equals(s)) {
- icpName = next.getValue().getAsString();
- }
- }
- return icpName;
- }
-
private String buildIcp(String name, JsonObject icp) {
if (icp.has(REQUIREMENTS)) {
JsonArray requirements = icp.get(REQUIREMENTS).getAsJsonArray();
- String vdu = null;
- String vl = null;
- 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 ("virtual_binding".equals(s)) {
- vdu = next.getValue().getAsString();
- } else if ("virtual_link".equals(s)) {
- vl = next.getValue().getAsString();
- }
- }
+ String vdu = getRequirement(requirements, "virtual_binding");
+ String vl = getRequirement(requirements, "virtual_link");
if (vdu == null) {
logger.warn("The {} internal connection point does not have a VDU", name);
} else if (vl == null) {