From 22a25ae0b0690c5b26f949cd0d5bc7079cf05d2a Mon Sep 17 00:00:00 2001 From: Marcus G K Williams Date: Wed, 28 Mar 2018 16:26:11 -0700 Subject: Bug Fix - OOF api updates processing flavor-label Additional API interactions were added to OOF response post API freeze that enable core HPA functionality. This patch updates the processsing of the API reponse to process additional flavor parameters. Issue-ID: SO-408 Change-Id: I1656a7ba955ab41c57b7a3e07a3d0cc38b16e2fa Signed-off-by: Marcus G K Williams --- .../mso/adapters/vnf/MsoVnfAdapterImpl.java | 40 ++++++++++++++-------- 1 file changed, 25 insertions(+), 15 deletions(-) (limited to 'adapters/mso-vnf-adapter/src/main') diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java index 2fec3f8b43..f8cba6afcb 100644 --- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java @@ -668,15 +668,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { LOGGER.debug("requestTypeString = " + requestTypeString + ", nestedStackId = " + nestedStackId + ", nestedBaseStackId = " + nestedBaseStackId); - // TODO(sshank): Figure out the body format to be sent from Groovy. - String hpaEnviromnentString = ""; - // Something similar to the following: - /* - if requestTypeString.substring(?) != "" { - hpaEnviromnentString = requestTypeString.substring(?) - } - */ - // Will capture execution time for metrics long startTime = System.currentTimeMillis(); @@ -1052,6 +1043,18 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { LOGGER.debug("no environment parameter found for this Type " + vfModuleType); } + // Replace flavors in environment with those returned by OOF + Map returnMap = updateFlavorsFromOof(heatEnvironmentString, inputs); + heatEnvironmentString = returnMap.get("heatEnvironmentString").toString(); + LOGGER.debug("After OOF Update Heat Env String is: " + heatEnvironmentString); + if (returnMap.get("inputs") instanceof Map) { + inputs = (Map) returnMap.get("inputs"); + LOGGER.debug("After OOF Update inputs are: " + inputs.toString()); + } else { + LOGGER.debug("inputs is not an instance of a Map: " + returnMap.get("inputs")); + throw new VnfException("Updating inputs using OOF info failed.", MsoExceptionCategory.INTERNAL); + } + // 1510 - Add the files: for nested templates *if* there are any LOGGER.debug("In MsoVnfAdapterImpl, createVfModule about to call db.getNestedTemplates avec templateId=" + heatTemplate.getArtifactUuid()); @@ -1170,12 +1173,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { //LOGGER.debug("About to create MHEE with " + sb); mhee = new MsoHeatEnvironmentEntry(sb); - // sshank: hpaEnviromnentString is obtained from requestTypeString above. - if (hpaEnviromnentString != null && hpaEnviromnentString.contains("parameters:")) { - StringBuilder hpasb = new StringBuilder(hpaEnviromnentString); - mhee.setHPAParameters(hpasb); - } - StringBuilder sb2 = new StringBuilder("\nHeat Template Parameters:\n"); for (HeatTemplateParam parm : heatTemplate.getParameters()) { sb2.append("\t" + parm.getParamName() + ", required=" + parm.isRequired()); @@ -2163,4 +2160,17 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { return CatalogDatabase.getInstance(); } + private Map updateFlavorsFromOof(String heatEnvironmentString, Map inputs) { + Map returnMap = new HashMap<>(); + for (Map.Entry input : inputs.entrySet()){ + if (heatEnvironmentString.contains("label_" + input.getKey())){ + heatEnvironmentString = heatEnvironmentString.replace("label_" + input.getKey(), + input.getValue()); + inputs.remove("label_" + input.getKey()); + } + } + returnMap.put("heatEnvironmentString", heatEnvironmentString); + returnMap.put("inputs", inputs); + return returnMap; + } } -- cgit 1.2.3-korg