From 18b81c30d2ea81b3e768839008860d1ffb77f2c8 Mon Sep 17 00:00:00 2001 From: ojasdubey Date: Tue, 26 Sep 2017 16:42:47 +0530 Subject: Bugfix - Create VF failed for Manual VSPs Excluded the manual onboarded VSP port type from port mirroring port collection Issue ID: SDC-399 Change-Id: I0c090375bc6ff1c935c01eb2c48793e3e196f808 Signed-off-by: ojasdubey --- .../impl/tosca/PortMirroringEnricher.java | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src') 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 9eeabebe6c..2fe1416ffc 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 @@ -1,5 +1,9 @@ package org.openecomp.sdc.enrichment.impl.tosca; +import static org.openecomp.sdc.tosca.services.DataModelUtil.getClonedObject; +import static org.openecomp.sdc.tosca.services.ToscaConstants.PORT_MIRRORING_CAPABILITY_CP_PROPERTY_NAME; +import static org.openecomp.sdc.tosca.services.ToscaConstants.PORT_MIRRORING_CAPABILITY_ID; + import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.openecomp.sdc.datatypes.error.ErrorMessage; @@ -28,10 +32,6 @@ import java.util.Objects; import java.util.Optional; import java.util.stream.Collectors; -import static org.openecomp.sdc.tosca.services.DataModelUtil.getClonedObject; -import static org.openecomp.sdc.tosca.services.ToscaConstants.PORT_MIRRORING_CAPABILITY_CP_PROPERTY_NAME; -import static org.openecomp.sdc.tosca.services.ToscaConstants.PORT_MIRRORING_CAPABILITY_ID; - public class PortMirroringEnricher { //Map of service template file name and map of all port node template ids, node template private Map> portNodeTemplates = new HashMap<>(); @@ -75,7 +75,8 @@ public class PortMirroringEnricher { if (Objects.nonNull(nodeTemplates)) { //Get all concrete port node templates from the service template Map serviceTemplatePortNodeTemplates = nodeTemplates.entrySet().stream() - .filter(nodeTemplateEntry -> isPortNodeTemplate(nodeTemplateEntry.getValue())) + .filter(nodeTemplateEntry -> (Objects.nonNull(nodeTemplateEntry.getValue())) + && (isPortNodeTemplate(nodeTemplateEntry.getValue().getType()))) .collect(Collectors.toMap(nodeTemplateEntry -> nodeTemplateEntry.getKey(), nodeTemplateEntry -> nodeTemplateEntry.getValue())); @@ -281,15 +282,14 @@ public class PortMirroringEnricher { imports.add(openecompIndexImport); } - private boolean isPortNodeTemplate(NodeTemplate nodeTemplate) { - String nodeType = nodeTemplate.getType(); + private boolean isPortNodeTemplate(String nodeType) { //Check if node corresponds to a concrete port node - if (nodeType.equals(ToscaNodeType.NEUTRON_PORT) - || nodeType.equals(ToscaNodeType.CONTRAILV2_VIRTUAL_MACHINE_INTERFACE) - || nodeType.equals(ToscaNodeType.CONTRAIL_PORT) - || nodeType.equals(ToscaNodeType.NETWORK_PORT) - || nodeType.equals(ToscaNodeType.NATIVE_NETWORK_PORT)) { - return true; + if (Objects.nonNull(nodeType)) { + if (nodeType.equals(ToscaNodeType.NEUTRON_PORT) + || nodeType.equals(ToscaNodeType.CONTRAILV2_VIRTUAL_MACHINE_INTERFACE) + || nodeType.equals(ToscaNodeType.CONTRAIL_PORT)) { + return true; + } } return false; } -- cgit 1.2.3-korg