X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=nokiav2%2Fdriver%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fvfc%2Fnfvo%2Fdriver%2Fvnfm%2Fsvnfm%2Fnokia%2Fpackagetransformer%2FOnapVnfdBuilder.java;fp=nokiav2%2Fdriver%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fvfc%2Fnfvo%2Fdriver%2Fvnfm%2Fsvnfm%2Fnokia%2Fpackagetransformer%2FOnapVnfdBuilder.java;h=b5dd961654c507241ddf519fdca602915f74c349;hb=3ec51cb825272e0ef32c0e7cb197bfc7f1519b97;hp=406f0033350ed59d6e0250266321986f870e6552;hpb=1e6859ddd141a5cbc6d8b9fcd5c190e75c92d7f3;p=vfc%2Fnfvo%2Fdriver%2Fvnfm%2Fsvnfm.git 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 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> 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> 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 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 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 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) {