From a15d4951fe5f3aa243ceed45d3250f8fe722143b Mon Sep 17 00:00:00 2001 From: "Manzon, Inna (im453s)" Date: Wed, 12 Dec 2018 17:47:01 +0200 Subject: Fabric configuration change Change-Id: I584bbce2bdd45c6873ca3ed3b8b8820530d4804b Issue-ID: SDC-1998 Signed-off-by: Manzon, Inna (im453s) --- .../ResourceTranslationNovaServerImpl.java | 27 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main') diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerImpl.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerImpl.java index 745d1bdf90..8c36d208c6 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerImpl.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNovaServerImpl.java @@ -374,15 +374,31 @@ public class ResourceTranslationNovaServerImpl extends ResourceTranslationBase { Optional valueSpacesProperty = HeatToToscaUtil.getResourceProperty(portResource, HeatConstants.VALUE_SPECS_PROPERTY_NAME); - valueSpacesProperty.filter(props -> props instanceof Map && MapUtils.isNotEmpty((Map)props)).ifPresent(valueSpecs ->{ - Object value = ((Map)(valueSpecs)).get(HeatConstants.ATT_FABRIC_CONFIGURATION_REQUIRED); - if(value!= null && HeatBoolean.eval(value )){ + valueSpacesProperty.filter(props -> props instanceof Map && MapUtils.isNotEmpty((Map)props)).ifPresent(valueSpecs ->{ + if(valueSpecs instanceof Map && (isAttFabricConfigurationFlagSet((Map)valueSpecs) || isBindingProfileFabricConfigSet((Map)valueSpecs))) { addFabricConfigurationCapability(translateTo, resourceType); } }); } + + private boolean isValueFoundAndTrue(Object value) { + return Objects.nonNull(value) && HeatBoolean.eval(value); + } + + private boolean isAttFabricConfigurationFlagSet(Map valueSpecs) { + return isValueFoundAndTrue(valueSpecs.get(HeatConstants.ATT_FABRIC_CONFIGURATION_REQUIRED)); + } + + private boolean isBindingProfileFabricConfigSet(Map valueSpecs) { + Object binding_profile = valueSpecs.get(HeatConstants.VALUE_SPECS_BINDING_PROFILE_PROPERTY_NAME); + if (Objects.nonNull(binding_profile) && binding_profile instanceof Map) { + return !MapUtils.isEmpty((Map)binding_profile) + && isValueFoundAndTrue(((Map)binding_profile).get(HeatConstants.VALUE_SPECS_FABRIC_CONFIG_PROPERTY_NAME)); + } + return false; + } private void addFabricConfigurationCapability(TranslateTo translateTo, String localType){ @@ -391,7 +407,10 @@ public class ResourceTranslationNovaServerImpl extends ResourceTranslationBase { CapabilityDefinition fabricConfigurationCap = new CapabilityDefinition(); fabricConfigurationCap.setType(ToscaCapabilityType.FABRIC_CONFIGURATION); mapCapabilities.put(FABRIC_CONFIGURATION_KEY, fabricConfigurationCap); - DataModelUtil.addNodeTypeCapabilitiesDef (DataModelUtil.getNodeType(serviceTemplate, localType), mapCapabilities); + DataModelUtil.addNodeTypeCapabilitiesDef (DataModelUtil.getNodeType(serviceTemplate, localType), mapCapabilities); + if (logger.isDebugEnabled()) { + logger.debug("New capability of type {} will be added to resource {}", ToscaCapabilityType.FABRIC_CONFIGURATION, translateTo.getResourceId()); + } } private Optional getOrTranslatePortTemplate(TranslateTo translateTo, -- cgit 1.2.3-korg