From 5e880aefe549a5825429740962c1acf9ff91e49e Mon Sep 17 00:00:00 2001 From: liboNet Date: Mon, 1 Oct 2018 04:01:30 +0800 Subject: Update the schema parse based on newer version the schema format of HPA requirement has been modified so that the parse needs update too based on the wiki: https://wiki.onap.org/display/DW/Specifying+HPA+ Capability+Requirements+using+TOSCA-based+VNF+Descriptors Change-Id: I48b39797e70d686ed0b9b2e7001b9a00068e76fd Issue-ID: POLICY-1160 Signed-off-by: liboNet --- .../reception/decoding/pdpx/ExtractFromNode.java | 32 +++++++++++++--------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'plugins/reception-plugins/src/main/java/org/onap') diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ExtractFromNode.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ExtractFromNode.java index d60aa113..4f822b20 100644 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ExtractFromNode.java +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ExtractFromNode.java @@ -48,7 +48,7 @@ import org.onap.sdc.toscaparser.api.RequirementAssignment; */ public class ExtractFromNode { - private static final String CONFIGURATION_VALUE = "configuration-value"; + private static final String CONFIGURATION_VALUE = "configurationValue"; private static final Logger LOGGER = FlexLogger.getLogger(ExtractFromNode.class); private static final String VDU_TYPE = "tosca.nodes.nfv.Vdu.Compute"; private static final String VDU_CP_TYPE = "tosca.nodes.nfv.VduCp"; @@ -215,8 +215,8 @@ public class ExtractFromNode { /** * GenerateHugePages, supported hpa features, All under the capability of tosca.nodes.nfv.Vdu.Compute. The format is - * a map like: {"schema-version": "0", "schema-location": "", "platform-id": "generic", "mandatory": true, - * "configuration-value": "2 MB"} + * a map like: {"schemaVersion": "0", "schemaSelector": "", "hardwarePlatform": "generic", "mandatory": "true", + * "configurationValue": "2 MB"} * * @param capabilityAssignment represents the capability of node * @@ -227,11 +227,14 @@ public class ExtractFromNode { sdcCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, MEMORY_PAGE_SIZE_PATH); LOGGER.debug("the memoryPageSize = " + memoryPageSize); if (memoryPageSize != null) { - final Map retMap = - gson.fromJson(memoryPageSize, new TypeToken>() {}.getType()); + final Map retMap = + gson.fromJson(memoryPageSize, new TypeToken>() {}.getType()); LOGGER.debug("the retMap = " + retMap); - final String memoryPageSizeValue = retMap.get(CONFIGURATION_VALUE).toString(); - final String mandatory = retMap.get("mandatory").toString(); + final String memoryPageSizeValue = retMap.get(CONFIGURATION_VALUE); + final String mandatory = retMap.get("mandatory"); + if (memoryPageSizeValue == null) { + return; + } final HpaFeatureAttribute hpaFeatureAttribute = generateHpaFeatureAttribute("memoryPageSize", memoryPageSizeValue); final FlavorProperty flavorProperty = new FlavorProperty(); @@ -283,7 +286,7 @@ public class ExtractFromNode { return; } } else { - LOGGER.debug(" no configuration-value defined in interfaceType"); + LOGGER.debug(" no configurationValue defined in interfaceType"); return; } @@ -303,8 +306,8 @@ public class ExtractFromNode { /** * GenerateNetworkFeature, all pci feature are grouped into FlavorFeature together. The format is a map like: - * {"schema-version": "0", "schema-location": "", "platform-id": "generic", "mandatory": true, - * "configuration-value": "2 MB"} + * {"schemaVersion": "0", "schemaSelector": "", "hardwarePlatform": "generic", "mandatory": "true", + * "configurationValue": "2 MB"} * * @param networkHpaFeature represents the specified Hpa feature * @param node represents the CP Node @@ -321,9 +324,12 @@ public class ExtractFromNode { final String pciValue = sdcCsarHelper.getNodeTemplatePropertyLeafValue(node, pciKeyPath); if (pciValue != null) { LOGGER.debug("the pciValue = " + pciValue); - final Map retMap = - gson.fromJson(pciValue, new TypeToken>() {}.getType()); - final String pciConfigValue = retMap.get(CONFIGURATION_VALUE).toString(); + final Map retMap = + gson.fromJson(pciValue, new TypeToken>() {}.getType()); + final String pciConfigValue = retMap.get(CONFIGURATION_VALUE); + if (pciConfigValue == null) { + return; + } final HpaFeatureAttribute hpaFeatureAttribute = generateHpaFeatureAttribute(pciKey, pciConfigValue); flavorProperty.getHpaFeatureAttributes().add(hpaFeatureAttribute); } -- cgit 1.2.3-korg