From 31b2ced9ebad2ef143b1892152997dc23c935a5c Mon Sep 17 00:00:00 2001 From: talio Date: Sun, 24 Sep 2017 11:41:53 +0300 Subject: Add property Add config property for port mirroring Issue - ID : SDC-351 Change-Id: I6b571e0bae2e26a3a1b9d20f9182943901a08d4c Signed-off-by: talio --- .../impl/tosca/PortMirroringEnricher.java | 45 ++++++++++++---------- 1 file changed, 24 insertions(+), 21 deletions(-) (limited to 'openecomp-be/lib/openecomp-sdc-enrichment-lib') diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/PortMirroringEnricher.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/PortMirroringEnricher.java index 130590cbb3..9eeabebe6c 100644 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/PortMirroringEnricher.java +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/PortMirroringEnricher.java @@ -50,21 +50,21 @@ public class PortMirroringEnricher { * @param toscaServiceModel the tosca service model * @return the map Error descriptor map */ - public Map> enrich(ToscaServiceModel toscaServiceModel) { + public Map> enrich(ToscaServiceModel toscaServiceModel) { mdcDataDebugMessage.debugEntryMessage(null); Map> errors = new HashMap<>(); - Map serviceTemplates = toscaServiceModel.getServiceTemplates(); - serviceTemplates.entrySet().stream() - //Skipping the service templates which do not contain topology template - .filter(serviceTemplateEntry -> serviceTemplateEntry.getValue() - .getTopology_template() != null) - .forEach(serviceTemplateEntry -> - //Collect all the ports across all the service templates - collectPorts(serviceTemplateEntry.getValue())); - //Collect External ports from the list of all ports collected above - filterExternalPorts(toscaServiceModel); - //Handle external port changes - handleExternalPorts(toscaServiceModel); + Map serviceTemplates = toscaServiceModel.getServiceTemplates(); + serviceTemplates.entrySet().stream() + //Skipping the service templates which do not contain topology template + .filter(serviceTemplateEntry -> serviceTemplateEntry.getValue() + .getTopology_template() != null) + .forEach(serviceTemplateEntry -> + //Collect all the ports across all the service templates + collectPorts(serviceTemplateEntry.getValue())); + //Collect External ports from the list of all ports collected above + filterExternalPorts(toscaServiceModel); + //Handle external port changes + handleExternalPorts(toscaServiceModel); mdcDataDebugMessage.debugExitMessage(null); return errors; } @@ -192,30 +192,33 @@ public class PortMirroringEnricher { } } - private void handleExternalPortProperties(NodeTemplate portNodeTemplate){ + private void handleExternalPortProperties(NodeTemplate portNodeTemplate) { ServiceTemplate serviceTemplate = globalTypesServiceTemplate.get("openecomp/nodes.yml"); String externalPortType = portNodeTemplate.getType(); Map globalTypesportProperties = new HashMap<>(); - globalTypesportProperties.putAll(serviceTemplate.getNode_types().get("org.openecomp.resource.cp.nodes.network.Port").getProperties()); - globalTypesportProperties.putAll(serviceTemplate.getNode_types().get(externalPortType).getProperties()); + globalTypesportProperties.putAll( + serviceTemplate.getNode_types().get("org.openecomp.resource.cp.nodes.network.Port") + .getProperties()); + globalTypesportProperties + .putAll(serviceTemplate.getNode_types().get(externalPortType).getProperties()); Map properties = portNodeTemplate.getProperties(); Map filteredProperties = new HashMap<>(); - if(MapUtils.isEmpty(properties)){ + if (MapUtils.isEmpty(properties)) { return; } - for(Map.Entry propertyEntry: properties.entrySet()){ - if(globalTypesportProperties.containsKey(propertyEntry.getKey())){ + for (Map.Entry propertyEntry : properties.entrySet()) { + if (globalTypesportProperties.containsKey(propertyEntry.getKey())) { filteredProperties.put(propertyEntry.getKey(), propertyEntry.getValue()); } } - if(!MapUtils.isEmpty(filteredProperties)) { + if (!MapUtils.isEmpty(filteredProperties)) { portNodeTemplate.setProperties(filteredProperties); - }else{ + } else { portNodeTemplate.setProperties(null); } -- cgit 1.2.3-korg