[SDC] Full OnBoard health-check and NFoD support

Change-Id: I606f8a52c7e6d2bd5558f824957d890e552c5423
Signed-off-by: Avi Ziv <avi.ziv@amdocs.com>
diff --git a/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/pom.xml b/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/pom.xml
index 047fe7f..51399fb 100644
--- a/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/pom.xml
+++ b/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/pom.xml
@@ -65,4 +65,4 @@
         </dependency>
     </dependencies>
 
-</project>
+</project>
\ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/src/main/java/org/openecomp/sdc/generator/datatypes/tosca/VspModelInfo.java b/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/src/main/java/org/openecomp/sdc/generator/datatypes/tosca/VspModelInfo.java
index 1fb1030..025db1c 100644
--- a/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/src/main/java/org/openecomp/sdc/generator/datatypes/tosca/VspModelInfo.java
+++ b/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/src/main/java/org/openecomp/sdc/generator/datatypes/tosca/VspModelInfo.java
@@ -55,4 +55,79 @@
   public void setNics(Map<String, List<Nic>> nics) {
     this.nics = nics;
   }
+
+  @Override
+  public int hashCode() {
+    int result = releaseVendor != null ? releaseVendor.hashCode() : 0;
+    result = 31 * result + (components != null ? components.hashCode() : 0);
+    result = 31 * result + (allowedFlavors != null ? allowedFlavors.hashCode() : 0);
+    result = 31 * result + (multiFlavorVfcImages != null ? multiFlavorVfcImages.hashCode() : 0);
+    result = 31 * result + (nics != null ? nics.hashCode() : 0);
+    return result;
+  }
+
+  @Override
+  public String toString() {
+    return "VspModelInfo{"
+       + "releaseVendor='" + releaseVendor + '\''
+       + ", components=" + components
+       + ", allowedFlavors=" + allowedFlavors
+       + ", multiFlavorVfcImages=" + multiFlavorVfcImages
+       + ", nics=" + nics
+       + '}';
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (this == obj) {
+      return true;
+    }
+    if (getClass() != obj.getClass()) {
+      return false;
+    }
+    VspModelInfo other = (VspModelInfo) obj;
+    if (this.releaseVendor == null) {
+      if (other.releaseVendor != null) {
+        return false;
+      }
+    } else if (!releaseVendor.equals(other.releaseVendor)) {
+      return false;
+    }
+    if (this.components == null) {
+      if (other.components != null) {
+        return false;
+      }
+    } else if (!components.equals(other.components)) {
+      return false;
+    }
+    if (this.allowedFlavors == null) {
+      if (other.allowedFlavors != null) {
+        return false;
+      }
+    } else if (!allowedFlavors.equals(other.allowedFlavors)) {
+      return false;
+    }
+    if (this.multiFlavorVfcImages == null) {
+      if (other.multiFlavorVfcImages != null) {
+        return false;
+      }
+    } else if (!multiFlavorVfcImages.equals(other.multiFlavorVfcImages)) {
+      return false;
+    }
+    if (this.multiFlavorVfcImages == null) {
+      if (other.multiFlavorVfcImages != null) {
+        return false;
+      }
+    } else if (!multiFlavorVfcImages.equals(other.multiFlavorVfcImages)) {
+      return false;
+    }
+    if (this.nics == null) {
+      if (other.nics != null) {
+        return false;
+      }
+    } else if (!nics.equals(other.nics)) {
+      return false;
+    }
+    return true;
+  }
 }
diff --git a/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/src/main/java/org/openecomp/sdc/generator/util/GeneratorConstants.java b/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/src/main/java/org/openecomp/sdc/generator/util/GeneratorConstants.java
index b24a85d..5464627 100644
--- a/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/src/main/java/org/openecomp/sdc/generator/util/GeneratorConstants.java
+++ b/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/src/main/java/org/openecomp/sdc/generator/util/GeneratorConstants.java
@@ -5,9 +5,10 @@
   public static final String IMAGES_PROPERTY = "images";
   public static final String RELEASE_VENDOR = "releaseVendor";
   public static final String VNF_CONFIG_NODE_TEMPLATE_ID_SUFFIX = "_VNF_Configuration";
-  public static final String VFC_NODE_TEMPLATE_ID_SUFFIX = "_VFC";
   public static final String VNF_NODE_TEMPLATE_ID_SUFFIX = "_VNF";
-  public static final String PORT_NODE_TEMPLATE_ID_SUFFIX = "_wan_port";
+  public static final String PORT_TYPE_INTERNAL_NODE_TEMPLATE_SUFFIX = "_lan";
+  public static final String PORT_TYPE_EXTERNAL_NODE_TEMPLATE_SUFFIX = "_wan";
+  public static final String PORT_NODE_TEMPLATE_ID_SUFFIX = "_port";
 
   public static final String TOSCA_SERVICE_TEMPLATE_FILE_NAME_SUFFIX = "ServiceTemplate.yaml";
 
diff --git a/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-core/src/main/java/org/openecomp/sdc/generator/core/services/ManualVspToscaGenerationService.java b/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-core/src/main/java/org/openecomp/sdc/generator/core/services/ManualVspToscaGenerationService.java
index 6d488c0..6ec7bfc 100644
--- a/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-core/src/main/java/org/openecomp/sdc/generator/core/services/ManualVspToscaGenerationService.java
+++ b/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-core/src/main/java/org/openecomp/sdc/generator/core/services/ManualVspToscaGenerationService.java
@@ -9,9 +9,10 @@
 import static org.openecomp.sdc.generator.util.GeneratorConstants.NUM_CPUS;
 import static org.openecomp.sdc.generator.util.GeneratorConstants.NUM_CPUS_PROP_DESC_PREFIX;
 import static org.openecomp.sdc.generator.util.GeneratorConstants.PORT_NODE_TEMPLATE_ID_SUFFIX;
+import static org.openecomp.sdc.generator.util.GeneratorConstants.PORT_TYPE_EXTERNAL_NODE_TEMPLATE_SUFFIX;
+import static org.openecomp.sdc.generator.util.GeneratorConstants.PORT_TYPE_INTERNAL_NODE_TEMPLATE_SUFFIX;
 import static org.openecomp.sdc.generator.util.GeneratorConstants.RELEASE_VENDOR;
 import static org.openecomp.sdc.generator.util.GeneratorConstants.TOSCA_SERVICE_TEMPLATE_FILE_NAME_SUFFIX;
-import static org.openecomp.sdc.generator.util.GeneratorConstants.VFC_NODE_TEMPLATE_ID_SUFFIX;
 import static org.openecomp.sdc.generator.util.GeneratorConstants.VNF_CONFIG_NODE_TEMPLATE_ID_SUFFIX;
 import static org.openecomp.sdc.generator.util.GeneratorConstants.VNF_NODE_TEMPLATE_ID_SUFFIX;
 
@@ -36,6 +37,7 @@
 import org.openecomp.sdc.tosca.services.impl.ToscaAnalyzerServiceImpl;
 import org.openecomp.sdc.translator.services.heattotosca.Constants;
 import org.openecomp.sdc.translator.services.heattotosca.globaltypes.GlobalTypesGenerator;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.NetworkType;
 import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic;
 
 import java.util.ArrayList;
@@ -118,8 +120,7 @@
       // May be need to revisited for supporting multiple components
       String componentId = components.entrySet().iterator().next().getKey();
       createVnfConfigurationNodeTemplate(mainServiceTemplate, vspModelInfo);
-      createComponentNodeTemplate(mainServiceTemplate, vspModelInfo, componentId);
-      createVnfNodeTemplate(mainServiceTemplate, vspModelInfo);
+      createVnfNodeTemplate(mainServiceTemplate, vspModelInfo, componentId);
     }
     return mainServiceTemplate;
   }
@@ -141,42 +142,16 @@
     }
   }
 
-  private void createComponentNodeTemplate(ServiceTemplate mainServiceTemplate,
-                                                  VspModelInfo vspModelInfo,
-                                                  String componentId) {
-    Optional<String> componentName = getComponentNameFromVspModel(vspModelInfo);
-    if (componentName.isPresent()) {
-      NodeTemplate vfcNodeTemplate = new NodeTemplate();
-      vfcNodeTemplate.setType(ToscaNodeType.MULTIFLAVOR_VFC_NODE_TYPE);
-      Map<String, Object> properties = new LinkedHashMap<>();
-      if (MapUtils.isNotEmpty(vspModelInfo.getMultiFlavorVfcImages())) {
-        List<MultiFlavorVfcImage> componentImages =
-            vspModelInfo.getMultiFlavorVfcImages().get(componentId);
-        Map<String, MultiFlavorVfcImage> vfcImages = new HashMap<>();
-        for (MultiFlavorVfcImage image : componentImages) {
-          vfcImages.put(image.getSoftware_version(), image);
-        }
-        properties.put(IMAGES_PROPERTY, vfcImages);
-        vfcNodeTemplate.setProperties(properties);
-      }
-      String nodeTemplateId = componentName.get() + VFC_NODE_TEMPLATE_ID_SUFFIX;
-      DataModelUtil.addNodeTemplate(mainServiceTemplate, nodeTemplateId,
-          vfcNodeTemplate);
-    }
-  }
-
   private void createVnfNodeTemplate(ServiceTemplate mainServiceTemplate,
-                                      VspModelInfo vspModelInfo) {
+                                     VspModelInfo vspModelInfo, String componentId) {
     Optional<String> componentName = getComponentNameFromVspModel(vspModelInfo);
     if (componentName.isPresent()) {
       NodeTemplate vnfNodeTemplate = new NodeTemplate();
-      String vnfNodeTemplateType =
-          ToscaNodeType.MULTIDEPLOYMENTFLAVOR_NODE_TYPE + "." + componentName.get();
-      vnfNodeTemplate.setType(vnfNodeTemplateType);
+      vnfNodeTemplate.setType(ToscaNodeType.MULTIDEPLOYMENTFLAVOR_NODE_TYPE);
       List<String> directiveList = new ArrayList<>();
       directiveList.add(ToscaConstants.NODE_TEMPLATE_DIRECTIVE_SUBSTITUTABLE);
       vnfNodeTemplate.setDirectives(directiveList);
-      vnfNodeTemplate.setProperties(new LinkedHashMap<>());
+      vnfNodeTemplate.setProperties(getVnfNodeTemplateProperties(vspModelInfo, componentId));
       DataModelUtil
           .addSubstitutionFilteringProperty(getSubstitutionServiceTemplateFileName(componentName
                   .get()), vnfNodeTemplate, 1);
@@ -186,10 +161,28 @@
       String nodeTemplateId = componentName.get() + VNF_NODE_TEMPLATE_ID_SUFFIX;
       DataModelUtil.addNodeTemplate(mainServiceTemplate, nodeTemplateId,
           vnfNodeTemplate);
-      abstractSubstitutionIdTypes.put(componentName.get(), vnfNodeTemplateType);
+      abstractSubstitutionIdTypes.put(componentName.get(), ToscaNodeType
+          .MULTIDEPLOYMENTFLAVOR_NODE_TYPE);
     }
   }
 
+  private Map<String, Object> getVnfNodeTemplateProperties(VspModelInfo vspModelInfo,
+                                                           String componentId) {
+    Map<String, Object> properties = new LinkedHashMap<>();
+    if (MapUtils.isNotEmpty(vspModelInfo.getMultiFlavorVfcImages())) {
+      List<MultiFlavorVfcImage> componentImages =
+          vspModelInfo.getMultiFlavorVfcImages().get(componentId);
+      if (Objects.nonNull(componentImages)) {
+        Map<String, MultiFlavorVfcImage> vfcImages = new HashMap<>();
+        componentImages.stream()
+            .forEach(multiFlavorVfcImage ->
+                vfcImages.put(multiFlavorVfcImage.getSoftware_version(), multiFlavorVfcImage));
+        properties.put(IMAGES_PROPERTY, vfcImages);
+      }
+    }
+    return properties;
+  }
+
   private String getSubstitutionServiceTemplateFileName(String componentName) {
     return componentName + TOSCA_SERVICE_TEMPLATE_FILE_NAME_SUFFIX;
   }
@@ -276,7 +269,7 @@
             nicNodeTemplate.setType(ToscaNodeType.NETWORK_PORT);
             DataModelUtil.addBindingReqFromPortToCompute(componentNodeTemplateId, nicNodeTemplate);
             DataModelUtil.addNodeTemplate(substitutionServiceTemplate,
-                getNicNodeTemplateId(nic.getName()), nicNodeTemplate);
+                getNicNodeTemplateId(nic.getName(), nic.getNetworkType()), nicNodeTemplate);
           }
         }
       }
@@ -288,9 +281,14 @@
     return componentName;
   }
 
-  private String getNicNodeTemplateId(String nicName) {
+  private String getNicNodeTemplateId(String nicName, NetworkType nicNetworkType) {
     StringBuilder builder = new StringBuilder();
     builder.append(nicName);
+    if (nicNetworkType == NetworkType.External) {
+      builder.append(PORT_TYPE_EXTERNAL_NODE_TEMPLATE_SUFFIX);
+    } else if (nicNetworkType == NetworkType.Internal) {
+      builder.append(PORT_TYPE_INTERNAL_NODE_TEMPLATE_SUFFIX);
+    }
     builder.append(PORT_NODE_TEMPLATE_ID_SUFFIX);
     return builder.toString();
   }
@@ -337,7 +335,6 @@
         createGlobalSubstitutionNodeType(substitutionServiceTemplate, componentName);
     DataModelUtil.addNodeType(globalSubstitutionServiceTemplate, substitutionNodeTypeId,
         substitutionNodeType);
-
     Map<String, Map<String, List<String>>> substitutionMapping =
         GeneratorUtils.getSubstitutionNodeTypeExposedConnectionPoints(substitutionNodeType,
             substitutionServiceTemplate, toscaServiceModel);
@@ -379,7 +376,7 @@
                                                 String componentName) {
     NodeType substitutionNodeType = new ToscaAnalyzerServiceImpl()
         .createInitSubstitutionNodeType(substitutionServiceTemplate,
-            ToscaNodeType.VFC_ABSTRACT_SUBSTITUTE);
+            ToscaNodeType.MULTIFLAVOR_VFC_NODE_TYPE);
     substitutionNodeType.setProperties(
         getManualVspSubstitutionNodeTypeProperties(substitutionNodeType, componentName));
     return substitutionNodeType;
diff --git a/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-core/src/main/java/org/openecomp/sdc/generator/core/utils/GeneratorUtils.java b/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-core/src/main/java/org/openecomp/sdc/generator/core/utils/GeneratorUtils.java
index c13997b..59b06ba 100644
--- a/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-core/src/main/java/org/openecomp/sdc/generator/core/utils/GeneratorUtils.java
+++ b/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-core/src/main/java/org/openecomp/sdc/generator/core/utils/GeneratorUtils.java
@@ -163,8 +163,8 @@
     } catch (Exception ex) {
       MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
           LoggerTragetServiceName.GENERATE_MANUAL_VSP_TOSCA, ErrorLevel.INFO.name(),
-          LoggerErrorCode.DATA_ERROR.getErrorCode(), "Error occured in get node type exposed "
-              + "points");
+          LoggerErrorCode.DATA_ERROR.getErrorCode(),
+          "Error occured in get node type exposed points : " + ex.getMessage());
       return null;
     }
     return substitutionMapping;