diff options
author | tragait <rahul.tyagi@est.tech> | 2021-02-22 17:27:00 +0000 |
---|---|---|
committer | tragait <rahul.tyagi@est.tech> | 2021-02-22 17:34:50 +0000 |
commit | 09aed6c2207d166b365d0f033b9e19762e3887fd (patch) | |
tree | 9be4a7e88ca5122dc9d74608df8b3bd9195bb1e7 /asdc-controller/src/main/java/org/onap | |
parent | 01ac4cc7d7b2fc4d527ccae82fb2fd43a8446f76 (diff) |
fix default software version source
This commit fixes default software version source input
for pnfcustomization table. If pnfcustomization has a
value in default software version field that will be picked.
Else first entry of software versions will be picked.
Issue-ID: SO-3543
Signed-off-by: tragait <rahul.tyagi@est.tech>
Change-Id: I10261c2d4c8e816fdaa2ef54d20c7e83b9f41701
Diffstat (limited to 'asdc-controller/src/main/java/org/onap')
-rw-r--r-- | asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java index 56ec77cdee..da7aad4319 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java @@ -986,11 +986,30 @@ public class ToscaResourceInstaller { pnfResourceCustomization.setBlueprintVersion(getStringValue(properties.get(SDNC_MODEL_VERSION))); pnfResourceCustomization.setSkipPostInstConf(getBooleanValue(properties.get(SKIP_POST_INST_CONF))); pnfResourceCustomization.setControllerActor(getStringValue(properties.get(CONTROLLER_ACTOR))); - pnfResourceCustomization.setDefaultSoftwareVersion(getStringValue(properties.get(DEFAULT_SOFTWARE_VERSION))); + pnfResourceCustomization.setDefaultSoftwareVersion(extractDefaultSoftwareVersionFromSwVersions(properties)); pnfResourceCustomization.setPnfResources(pnfResource); return pnfResourceCustomization; } + private String extractDefaultSoftwareVersionFromSwVersions(Map<String, Property> properties) { + final String SOFTWARE_VERSIONS = "software_versions"; + final String EMPTY_STRING = ""; + String defaultSoftwareVersionValue = getStringValue(properties.get(DEFAULT_SOFTWARE_VERSION)); + if (defaultSoftwareVersionValue != null && !defaultSoftwareVersionValue.isEmpty()) { + return defaultSoftwareVersionValue; + } + if (properties.containsKey(SOFTWARE_VERSIONS) && properties.get(SOFTWARE_VERSIONS).getValue() != null) { + if (properties.get(SOFTWARE_VERSIONS).getValue() instanceof List) { + List<String> propertyValueList = (List) properties.get(SOFTWARE_VERSIONS).getValue(); + return propertyValueList.get(0); + } else if (properties.get(SOFTWARE_VERSIONS).getValue() instanceof String) { + return getStringValue(properties.get(SOFTWARE_VERSIONS)); + } + } + + return EMPTY_STRING; + } + /** * Get value from {@link Property} and cast to boolean value. Return true if property is null. */ |