Bugfix - Create VF failed for Manual VSPs 63/15463/5
authorojasdubey <ojas.dubey@amdocs.com>
Tue, 26 Sep 2017 11:12:47 +0000 (16:42 +0530)
committerojasdubey <ojas.dubey@amdocs.com>
Wed, 27 Sep 2017 07:02:32 +0000 (12:32 +0530)
Excluded the manual onboarded VSP port type
from port mirroring port collection

Issue ID: SDC-399

Change-Id: I0c090375bc6ff1c935c01eb2c48793e3e196f808
Signed-off-by: ojasdubey <ojas.dubey@amdocs.com>
openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/PortMirroringEnricher.java

index 9eeabeb..2fe1416 100644 (file)
@@ -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<String, Map<String, NodeTemplate>> 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<String, NodeTemplate> 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;
   }