aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-tosca-generator-lib
diff options
context:
space:
mode:
authorAvi Ziv <AVIZI@amdocs.com>2017-07-26 17:37:57 +0300
committerAvi Ziv <avi.ziv@amdocs.com>2017-07-26 18:27:22 +0300
commit61070c9c6b665fdea79b3ccdfeafc3a6b50d262e (patch)
treedfe9c169cfac91d6c72ac9ff23375f2aafac6405 /openecomp-be/lib/openecomp-sdc-tosca-generator-lib
parentb824a997e19f6ee9627cb1b1e124c756bd8183fc (diff)
[SDC] Full OnBoard health-check and NFoD support
Change-Id: I606f8a52c7e6d2bd5558f824957d890e552c5423 Signed-off-by: Avi Ziv <avi.ziv@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-tosca-generator-lib')
-rw-r--r--openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/pom.xml2
-rw-r--r--openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/src/main/java/org/openecomp/sdc/generator/datatypes/tosca/VspModelInfo.java75
-rw-r--r--openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/src/main/java/org/openecomp/sdc/generator/util/GeneratorConstants.java5
-rw-r--r--openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-core/src/main/java/org/openecomp/sdc/generator/core/services/ManualVspToscaGenerationService.java71
-rw-r--r--openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-core/src/main/java/org/openecomp/sdc/generator/core/utils/GeneratorUtils.java4
5 files changed, 115 insertions, 42 deletions
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 047fe7f843..51399fbb7d 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 1fb1030dd3..025db1cafc 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 class VspModelInfo {
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 b24a85d61c..5464627927 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 class GeneratorConstants {
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 6d488c0221..6ec7bfca9f 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.MEM_SIZE_PROP_
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.ToscaUtil;
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 @@ public class ManualVspToscaGenerationService {
// 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 @@ public class ManualVspToscaGenerationService {
}
}
- 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 @@ public class ManualVspToscaGenerationService {
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 @@ public class ManualVspToscaGenerationService {
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 @@ public class ManualVspToscaGenerationService {
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 @@ public class ManualVspToscaGenerationService {
createGlobalSubstitutionNodeType(substitutionServiceTemplate, componentName);
DataModelUtil.addNodeType(globalSubstitutionServiceTemplate, substitutionNodeTypeId,
substitutionNodeType);
-
Map<String, Map<String, List<String>>> substitutionMapping =
GeneratorUtils.getSubstitutionNodeTypeExposedConnectionPoints(substitutionNodeType,
substitutionServiceTemplate, toscaServiceModel);
@@ -379,7 +376,7 @@ public class ManualVspToscaGenerationService {
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 c13997b47c..59b06ba7a8 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 @@ public class GeneratorUtils {
} 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;