diff options
author | Yan Yang <yangyanyj@chinamobile.com> | 2018-05-31 00:55:37 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-05-31 00:55:37 +0000 |
commit | 3ec51cb825272e0ef32c0e7cb197bfc7f1519b97 (patch) | |
tree | bb7f52cd3b241328eae331790849b0bd024f1b22 /nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/OnapVnfdBuilder.java | |
parent | 1e6859ddd141a5cbc6d8b9fcd5c190e75c92d7f3 (diff) | |
parent | ce16741b481dbaae3a3447f84efb2b4ce5dffc82 (diff) |
Merge "Fix template generator for R2"
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.java | 60 |
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) { |