aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-tosca-generator-lib
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2021-03-22 15:33:06 +0000
committerChristophe Closset <christophe.closset@intl.att.com>2021-03-24 06:59:47 +0000
commitd378c37fbd1ecec7b43394926f1ca32a695e07de (patch)
tree5c8a085f8732f980d871d966ac49361644efa698 /openecomp-be/lib/openecomp-sdc-tosca-generator-lib
parenta6ae7294ecd336d7e88f915710b08e2658eaee00 (diff)
Reformat openecomp-be
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Issue-ID: SDC-3449 Change-Id: I13e02322f8e00820cc5a1d85752caaeda9bf10d1
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/src/main/java/org/openecomp/sdc/generator/datatypes/tosca/ComputeFlavor.java2
-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/DeploymentFlavorModel.java3
-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/LicenseFlavor.java2
-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/MultiFlavorVfcImage.java2
-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/VendorInfo.java2
-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.java2
-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.java13
-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.java559
-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.java112
9 files changed, 309 insertions, 388 deletions
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/ComputeFlavor.java b/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/src/main/java/org/openecomp/sdc/generator/datatypes/tosca/ComputeFlavor.java
index f0d5472fd9..693344b50d 100644
--- a/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/src/main/java/org/openecomp/sdc/generator/datatypes/tosca/ComputeFlavor.java
+++ b/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/src/main/java/org/openecomp/sdc/generator/datatypes/tosca/ComputeFlavor.java
@@ -19,7 +19,6 @@
* Modifications copyright (c) 2019 Nokia
* ================================================================================
*/
-
package org.openecomp.sdc.generator.datatypes.tosca;
import lombok.EqualsAndHashCode;
@@ -38,5 +37,4 @@ public class ComputeFlavor {
private int num_cpus;
private String disk_size;
private String mem_size;
-
}
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/DeploymentFlavorModel.java b/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/src/main/java/org/openecomp/sdc/generator/datatypes/tosca/DeploymentFlavorModel.java
index ae7952e897..ede0a131e4 100644
--- a/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/src/main/java/org/openecomp/sdc/generator/datatypes/tosca/DeploymentFlavorModel.java
+++ b/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/src/main/java/org/openecomp/sdc/generator/datatypes/tosca/DeploymentFlavorModel.java
@@ -19,7 +19,6 @@
* Modifications copyright (c) 2019 Nokia
* ================================================================================
*/
-
package org.openecomp.sdc.generator.datatypes.tosca;
import lombok.EqualsAndHashCode;
@@ -39,6 +38,4 @@ public class DeploymentFlavorModel {
private VendorInfo vendor_info;
private ComputeFlavor compute_flavor;
private LicenseFlavor license_flavor;
-
}
-
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/LicenseFlavor.java b/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/src/main/java/org/openecomp/sdc/generator/datatypes/tosca/LicenseFlavor.java
index 0f7e5e80fb..98593d934b 100644
--- a/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/src/main/java/org/openecomp/sdc/generator/datatypes/tosca/LicenseFlavor.java
+++ b/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/src/main/java/org/openecomp/sdc/generator/datatypes/tosca/LicenseFlavor.java
@@ -19,7 +19,6 @@
* Modifications copyright (c) 2019 Nokia
* ================================================================================
*/
-
package org.openecomp.sdc.generator.datatypes.tosca;
import lombok.EqualsAndHashCode;
@@ -36,5 +35,4 @@ import lombok.ToString;
public class LicenseFlavor {
private String feature_group_uuid;
-
}
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/MultiFlavorVfcImage.java b/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/src/main/java/org/openecomp/sdc/generator/datatypes/tosca/MultiFlavorVfcImage.java
index 3c64231321..5f7948f255 100644
--- a/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/src/main/java/org/openecomp/sdc/generator/datatypes/tosca/MultiFlavorVfcImage.java
+++ b/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/src/main/java/org/openecomp/sdc/generator/datatypes/tosca/MultiFlavorVfcImage.java
@@ -19,7 +19,6 @@
* Modifications copyright (c) 2019 Nokia
* ================================================================================
*/
-
package org.openecomp.sdc.generator.datatypes.tosca;
import lombok.EqualsAndHashCode;
@@ -39,5 +38,4 @@ public class MultiFlavorVfcImage {
private String file_hash;
private String file_hash_type;
private String software_version;
-
}
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/VendorInfo.java b/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/src/main/java/org/openecomp/sdc/generator/datatypes/tosca/VendorInfo.java
index 1837841948..7f56f521ad 100644
--- a/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/src/main/java/org/openecomp/sdc/generator/datatypes/tosca/VendorInfo.java
+++ b/openecomp-be/lib/openecomp-sdc-tosca-generator-lib/openecomp-sdc-tosca-generator-api/src/main/java/org/openecomp/sdc/generator/datatypes/tosca/VendorInfo.java
@@ -19,7 +19,6 @@
* Modifications copyright (c) 2019 Nokia
* ================================================================================
*/
-
package org.openecomp.sdc.generator.datatypes.tosca;
import lombok.EqualsAndHashCode;
@@ -37,5 +36,4 @@ public class VendorInfo {
private String manufacturer_reference_number;
private String vendor_model;
-
}
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 05f43ce76b..bb302bbbe4 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
@@ -19,7 +19,6 @@
* Modifications copyright (c) 2019 Nokia
* ================================================================================
*/
-
package org.openecomp.sdc.generator.datatypes.tosca;
import java.util.List;
@@ -47,5 +46,4 @@ public class VspModelInfo {
private Map<String, List<MultiFlavorVfcImage>> multiFlavorVfcImages;
//Map of component and ports (NICs)
private Map<String, List<Nic>> nics;
-
}
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 3917ebe5ba..03e72255bd 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
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,10 +17,10 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.generator.util;
public final class GeneratorConstants {
+
public static final String ALLOWED_FLAVORS_PROPERTY = "allowed_flavors";
public static final String IMAGES_PROPERTY = "images";
public static final String RELEASE_VENDOR = "releaseVendor";
@@ -30,14 +30,13 @@ public final class GeneratorConstants {
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";
-
//Manual VSP propeties
public static final String NUM_CPUS = "num_cpus";
public static final String DISK_SIZE = "disk_size";
public static final String MEM_SIZE = "mem_size";
- public static final String NUM_CPUS_PROP_DESC_PREFIX = "Number of cpu for ";
- public static final String DISK_SIZE_PROP_DESC_PREFIX = "Disk size for ";
- public static final String MEM_SIZE_PROP_DESC_PREFIX = "Memory size for ";
+ public static final String NUM_CPUS_PROP_DESC_PREFIX = "Number of cpu for ";
+ public static final String DISK_SIZE_PROP_DESC_PREFIX = "Disk size for ";
+ public static final String MEM_SIZE_PROP_DESC_PREFIX = "Memory size for ";
// prevent utility class instantiation
private GeneratorConstants() {
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 5a18155f03..8fd2d090db 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
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.generator.core.services;
import java.util.ArrayList;
@@ -53,344 +52,298 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic;
*/
public class ManualVspToscaGenerationService {
- //Map of the abstract node template id and substitution node type
- private Map<String, String> abstractSubstitutionIdTypes = new HashMap<>();
- //Map of service template name and service template for the generated service templates
- private Map<String, ServiceTemplate> generatedServiceTemplates = new HashMap<>();
-
+ //Map of the abstract node template id and substitution node type
+ private Map<String, String> abstractSubstitutionIdTypes = new HashMap<>();
+ //Map of service template name and service template for the generated service templates
+ private Map<String, ServiceTemplate> generatedServiceTemplates = new HashMap<>();
+
+ /**
+ * Create manual vsp tosca service model tosca service model.
+ *
+ * @param vspModelInfo the vsp model info
+ * @return the tosca service model
+ */
+ public ToscaServiceModel createManualVspToscaServiceModel(VspModelInfo vspModelInfo) {
+ ToscaServiceModel toscaServiceModel = new ToscaServiceModel();
+ Map<String, ServiceTemplate> serviceTemplates = new HashMap<>(GlobalTypesGenerator.getGlobalTypesServiceTemplate(OnboardingTypesEnum.MANUAL));
+ toscaServiceModel.setServiceTemplates(serviceTemplates);
+ toscaServiceModel
+ .setEntryDefinitionServiceTemplate(Constants.MAIN_TEMPLATE_NAME + GeneratorConstants.TOSCA_SERVICE_TEMPLATE_FILE_NAME_SUFFIX);
+ createToscaFromVspData(vspModelInfo, toscaServiceModel);
+ for (Map.Entry<String, ServiceTemplate> serviceTemplateEntry : generatedServiceTemplates.entrySet()) {
+ ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates, serviceTemplateEntry.getValue());
+ }
+ return toscaServiceModel;
+ }
- /**
- * Create manual vsp tosca service model tosca service model.
- *
- * @param vspModelInfo the vsp model info
- * @return the tosca service model
- */
- public ToscaServiceModel createManualVspToscaServiceModel(VspModelInfo vspModelInfo) {
- ToscaServiceModel toscaServiceModel = new ToscaServiceModel();
- Map<String, ServiceTemplate> serviceTemplates = new HashMap<>(GlobalTypesGenerator
- .getGlobalTypesServiceTemplate(OnboardingTypesEnum.MANUAL));
- toscaServiceModel.setServiceTemplates(serviceTemplates);
- toscaServiceModel.setEntryDefinitionServiceTemplate(Constants.MAIN_TEMPLATE_NAME
- + GeneratorConstants.TOSCA_SERVICE_TEMPLATE_FILE_NAME_SUFFIX);
- createToscaFromVspData(vspModelInfo, toscaServiceModel);
- for (Map.Entry<String, ServiceTemplate> serviceTemplateEntry :
- generatedServiceTemplates.entrySet()) {
- ToscaUtil.addServiceTemplateToMapWithKeyFileName(serviceTemplates, serviceTemplateEntry
- .getValue());
+ private void createToscaFromVspData(VspModelInfo vspModelInfo, ToscaServiceModel toscaServiceModel) {
+ //Only one component supported
+ Optional<String> componentName = getComponentNameFromVspModel(vspModelInfo);
+ if (componentName.isPresent()) {
+ //Create main service template
+ ServiceTemplate mainServiceTemplate = createMainServiceTemplate(vspModelInfo);
+ generatedServiceTemplates.put(Constants.MAIN_TEMPLATE_NAME, mainServiceTemplate);
+ //Create substitution service template
+ for (Map.Entry<String, String> entry : abstractSubstitutionIdTypes.entrySet()) {
+ ServiceTemplate substitutionServiceTemplate = createSubstitutionServiceTemplate(componentName.get(), entry.getValue(), vspModelInfo,
+ toscaServiceModel);
+ generatedServiceTemplates.put(componentName.get(), substitutionServiceTemplate);
+ }
+ }
}
- return toscaServiceModel;
- }
- private void createToscaFromVspData(VspModelInfo vspModelInfo,
- ToscaServiceModel toscaServiceModel) {
- //Only one component supported
- Optional<String> componentName = getComponentNameFromVspModel(vspModelInfo);
- if (componentName.isPresent()) {
- //Create main service template
- ServiceTemplate mainServiceTemplate = createMainServiceTemplate(vspModelInfo);
- generatedServiceTemplates.put(Constants.MAIN_TEMPLATE_NAME, mainServiceTemplate);
- //Create substitution service template
- for (Map.Entry<String, String> entry : abstractSubstitutionIdTypes.entrySet()) {
- ServiceTemplate substitutionServiceTemplate =
- createSubstitutionServiceTemplate(componentName.get(), entry.getValue(), vspModelInfo,
- toscaServiceModel);
- generatedServiceTemplates.put(componentName.get(), substitutionServiceTemplate);
- }
+ private Optional<String> getComponentNameFromVspModel(VspModelInfo vspModelInfo) {
+ String componentName = null;
+ if (MapUtils.isNotEmpty(vspModelInfo.getComponents())) {
+ //supported for single component only
+ componentName = vspModelInfo.getComponents().entrySet().iterator().next().getValue();
+ }
+ return Optional.ofNullable(componentName);
}
- }
+ private ServiceTemplate createMainServiceTemplate(VspModelInfo vspModelInfo) {
+ ServiceTemplate mainServiceTemplate = createInitMainServiceTemplate(vspModelInfo.getReleaseVendor());
+ Map<String, String> components = vspModelInfo.getComponents();
+ if (MapUtils.isNotEmpty(components)) {
+ //Currently since only one component is supported we can fetch the component in this manner.
+
+ // May be need to revisited for supporting multiple components
+ String componentId = components.entrySet().iterator().next().getKey();
+ createVnfConfigurationNodeTemplate(mainServiceTemplate, vspModelInfo);
+ createVnfNodeTemplate(mainServiceTemplate, vspModelInfo, componentId);
+ }
+ return mainServiceTemplate;
+ }
- private Optional<String> getComponentNameFromVspModel(VspModelInfo vspModelInfo) {
- String componentName = null;
- if (MapUtils.isNotEmpty(vspModelInfo.getComponents())) {
- //supported for single component only
- componentName = vspModelInfo.getComponents().entrySet().iterator().next().getValue();
+ private void createVnfConfigurationNodeTemplate(ServiceTemplate mainServiceTemplate, VspModelInfo vspModelInfo) {
+ Optional<String> componentName = getComponentNameFromVspModel(vspModelInfo);
+ if (componentName.isPresent()) {
+ NodeTemplate vnfConfigurationNodeTemplate = new NodeTemplate();
+ vnfConfigurationNodeTemplate.setType(ToscaNodeType.VNF_CONFIG_NODE_TYPE);
+ if (Objects.nonNull(vspModelInfo.getAllowedFlavors())) {
+ Map<String, Object> properties = new LinkedHashMap<>();
+ properties.put(GeneratorConstants.ALLOWED_FLAVORS_PROPERTY, vspModelInfo.getAllowedFlavors());
+ vnfConfigurationNodeTemplate.setProperties(properties);
+ }
+ String nodeTemplateId = componentName.get() + GeneratorConstants.VNF_CONFIG_NODE_TEMPLATE_ID_SUFFIX;
+ DataModelUtil.addNodeTemplate(mainServiceTemplate, nodeTemplateId, vnfConfigurationNodeTemplate);
+ }
}
- return Optional.ofNullable(componentName);
- }
- private ServiceTemplate createMainServiceTemplate(VspModelInfo vspModelInfo) {
- ServiceTemplate mainServiceTemplate = createInitMainServiceTemplate(vspModelInfo
- .getReleaseVendor());
- Map<String, String> components = vspModelInfo.getComponents();
- if (MapUtils.isNotEmpty(components)) {
- //Currently since only one component is supported we can fetch the component in this manner.
- // May be need to revisited for supporting multiple components
- String componentId = components.entrySet().iterator().next().getKey();
- createVnfConfigurationNodeTemplate(mainServiceTemplate, vspModelInfo);
- createVnfNodeTemplate(mainServiceTemplate, vspModelInfo, componentId);
+ private void createVnfNodeTemplate(ServiceTemplate mainServiceTemplate, VspModelInfo vspModelInfo, String componentId) {
+ Optional<String> componentName = getComponentNameFromVspModel(vspModelInfo);
+ if (componentName.isPresent()) {
+ NodeTemplate vnfNodeTemplate = new NodeTemplate();
+ vnfNodeTemplate.setType(ToscaNodeType.MULTIDEPLOYMENTFLAVOR_NODE_TYPE);
+ List<String> directiveList = new ArrayList<>();
+ directiveList.add(ToscaConstants.NODE_TEMPLATE_DIRECTIVE_SUBSTITUTABLE);
+ vnfNodeTemplate.setDirectives(directiveList);
+ vnfNodeTemplate.setProperties(getVnfNodeTemplateProperties(vspModelInfo, componentId));
+ DataModelUtil.addSubstitutionFilteringProperty(getSubstitutionServiceTemplateFileName(componentName.get()), vnfNodeTemplate, 1);
+ //Enable below if we need "abstract_" as prefix like we have in Unified model
+
+ //String nodeTemplateId =
+
+ // Constants.ABSTRACT_NODE_TEMPLATE_ID_PREFIX + componentName + "VNF_NODE_TEMPLATE_ID_SUFFIX";
+ String nodeTemplateId = componentName.get() + GeneratorConstants.VNF_NODE_TEMPLATE_ID_SUFFIX;
+ DataModelUtil.addNodeTemplate(mainServiceTemplate, nodeTemplateId, vnfNodeTemplate);
+ abstractSubstitutionIdTypes.put(componentName.get(), ToscaNodeType.MULTIDEPLOYMENTFLAVOR_NODE_TYPE);
+ }
}
- return mainServiceTemplate;
- }
- private void createVnfConfigurationNodeTemplate(ServiceTemplate mainServiceTemplate,
- VspModelInfo vspModelInfo) {
- Optional<String> componentName = getComponentNameFromVspModel(vspModelInfo);
- if (componentName.isPresent()) {
- NodeTemplate vnfConfigurationNodeTemplate = new NodeTemplate();
- vnfConfigurationNodeTemplate.setType(ToscaNodeType.VNF_CONFIG_NODE_TYPE);
- if (Objects.nonNull(vspModelInfo.getAllowedFlavors())) {
+ private Map<String, Object> getVnfNodeTemplateProperties(VspModelInfo vspModelInfo, String componentId) {
Map<String, Object> properties = new LinkedHashMap<>();
- properties.put(GeneratorConstants.ALLOWED_FLAVORS_PROPERTY, vspModelInfo.getAllowedFlavors());
- vnfConfigurationNodeTemplate.setProperties(properties);
- }
- String nodeTemplateId = componentName.get() + GeneratorConstants.VNF_CONFIG_NODE_TEMPLATE_ID_SUFFIX;
- DataModelUtil.addNodeTemplate(mainServiceTemplate, nodeTemplateId,
- vnfConfigurationNodeTemplate);
+ 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(GeneratorConstants.IMAGES_PROPERTY, vfcImages);
+ }
+ }
+ return properties;
}
- }
- private void createVnfNodeTemplate(ServiceTemplate mainServiceTemplate,
- VspModelInfo vspModelInfo, String componentId) {
- Optional<String> componentName = getComponentNameFromVspModel(vspModelInfo);
- if (componentName.isPresent()) {
- NodeTemplate vnfNodeTemplate = new NodeTemplate();
- vnfNodeTemplate.setType(ToscaNodeType.MULTIDEPLOYMENTFLAVOR_NODE_TYPE);
- List<String> directiveList = new ArrayList<>();
- directiveList.add(ToscaConstants.NODE_TEMPLATE_DIRECTIVE_SUBSTITUTABLE);
- vnfNodeTemplate.setDirectives(directiveList);
- vnfNodeTemplate.setProperties(getVnfNodeTemplateProperties(vspModelInfo, componentId));
- DataModelUtil
- .addSubstitutionFilteringProperty(getSubstitutionServiceTemplateFileName(componentName
- .get()), vnfNodeTemplate, 1);
- //Enable below if we need "abstract_" as prefix like we have in Unified model
- //String nodeTemplateId =
- // Constants.ABSTRACT_NODE_TEMPLATE_ID_PREFIX + componentName + "VNF_NODE_TEMPLATE_ID_SUFFIX";
- String nodeTemplateId = componentName.get() + GeneratorConstants.VNF_NODE_TEMPLATE_ID_SUFFIX;
- DataModelUtil.addNodeTemplate(mainServiceTemplate, nodeTemplateId,
- vnfNodeTemplate);
- abstractSubstitutionIdTypes.put(componentName.get(), ToscaNodeType
- .MULTIDEPLOYMENTFLAVOR_NODE_TYPE);
+ private String getSubstitutionServiceTemplateFileName(String componentName) {
+ return componentName + GeneratorConstants.TOSCA_SERVICE_TEMPLATE_FILE_NAME_SUFFIX;
}
- }
- 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(GeneratorConstants.IMAGES_PROPERTY, vfcImages);
- }
+ private ServiceTemplate createInitMainServiceTemplate(String releaseVendor) {
+ ServiceTemplate mainServiceTemplate = new ServiceTemplate();
+ Map<String, String> templateMetadata = new HashMap<>();
+ templateMetadata.put(ToscaConstants.ST_METADATA_TEMPLATE_NAME, Constants.MAIN_TEMPLATE_NAME);
+ if (Objects.nonNull(releaseVendor)) {
+ templateMetadata.put(GeneratorConstants.RELEASE_VENDOR, releaseVendor);
+ }
+ mainServiceTemplate.setTosca_definitions_version(ToscaConstants.TOSCA_DEFINITIONS_VERSION);
+ mainServiceTemplate.setMetadata(templateMetadata);
+ mainServiceTemplate.setTopology_template(new TopologyTemplate());
+ mainServiceTemplate.setImports(getImports());
+ return mainServiceTemplate;
}
- return properties;
- }
-
- private String getSubstitutionServiceTemplateFileName(String componentName) {
- return componentName + GeneratorConstants.TOSCA_SERVICE_TEMPLATE_FILE_NAME_SUFFIX;
- }
- private ServiceTemplate createInitMainServiceTemplate(String releaseVendor) {
- ServiceTemplate mainServiceTemplate = new ServiceTemplate();
- Map<String, String> templateMetadata = new HashMap<>();
- templateMetadata.put(ToscaConstants.ST_METADATA_TEMPLATE_NAME, Constants.MAIN_TEMPLATE_NAME);
- if (Objects.nonNull(releaseVendor)) {
- templateMetadata.put(GeneratorConstants.RELEASE_VENDOR, releaseVendor);
+ private List<Map<String, Import>> getImports() {
+ Map<String, Import> globalSubstitutionTypeImportMap = new HashMap<>();
+ Import globalSubstitutionTypeImport = new Import();
+ globalSubstitutionTypeImport.setFile(ToscaUtil.getServiceTemplateFileName(Constants.GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME));
+ globalSubstitutionTypeImportMap.put(Constants.GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME, globalSubstitutionTypeImport);
+ List<Map<String, Import>> manualVspGlobalTypesImportList = GlobalTypesGenerator.getManualVspGlobalTypesImportList();
+ manualVspGlobalTypesImportList.add(globalSubstitutionTypeImportMap);
+ return manualVspGlobalTypesImportList;
}
- mainServiceTemplate.setTosca_definitions_version(ToscaConstants.TOSCA_DEFINITIONS_VERSION);
- mainServiceTemplate.setMetadata(templateMetadata);
- mainServiceTemplate.setTopology_template(new TopologyTemplate());
- mainServiceTemplate.setImports(getImports());
- return mainServiceTemplate;
- }
-
- private List<Map<String, Import>> getImports() {
- Map<String, Import> globalSubstitutionTypeImportMap = new HashMap<>();
- Import globalSubstitutionTypeImport = new Import();
- globalSubstitutionTypeImport.setFile(ToscaUtil.getServiceTemplateFileName(Constants
- .GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME));
- globalSubstitutionTypeImportMap.put(Constants.GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME,
- globalSubstitutionTypeImport);
- List<Map<String, Import>> manualVspGlobalTypesImportList = GlobalTypesGenerator
- .getManualVspGlobalTypesImportList();
- manualVspGlobalTypesImportList.add(globalSubstitutionTypeImportMap);
- return manualVspGlobalTypesImportList;
- }
-
- private ServiceTemplate createSubstitutionServiceTemplate(String serviceTemplateName,
- String substitutionNodeTypeId,
- VspModelInfo vspModelInfo,
- ToscaServiceModel toscaServiceModel) {
- ServiceTemplate substitutionServiceTemplate =
- createInitSubstitutionServiceTemplate(serviceTemplateName);
- createSubstitutionServiceTemplateComponents(substitutionServiceTemplate, vspModelInfo);
- createSubstitutionServiceTemplateNics(substitutionServiceTemplate, vspModelInfo);
- handleSubstitutionMapping(substitutionServiceTemplate, toscaServiceModel,
- substitutionNodeTypeId, serviceTemplateName);
- return substitutionServiceTemplate;
- }
- private void createSubstitutionServiceTemplateComponents(ServiceTemplate
- substitutionServiceTemplate,
- VspModelInfo vspModelInfo) {
- Map<String, String> components = vspModelInfo.getComponents();
- if (MapUtils.isNotEmpty(components)) {
- for (String componentName : components.values()) {
- String localNodeTypeId =
- createComponentDefinitionNodeTemplate(substitutionServiceTemplate, componentName);
- createLocalNodeType(substitutionServiceTemplate, localNodeTypeId);
- }
+ private ServiceTemplate createSubstitutionServiceTemplate(String serviceTemplateName, String substitutionNodeTypeId, VspModelInfo vspModelInfo,
+ ToscaServiceModel toscaServiceModel) {
+ ServiceTemplate substitutionServiceTemplate = createInitSubstitutionServiceTemplate(serviceTemplateName);
+ createSubstitutionServiceTemplateComponents(substitutionServiceTemplate, vspModelInfo);
+ createSubstitutionServiceTemplateNics(substitutionServiceTemplate, vspModelInfo);
+ handleSubstitutionMapping(substitutionServiceTemplate, toscaServiceModel, substitutionNodeTypeId, serviceTemplateName);
+ return substitutionServiceTemplate;
}
- }
- private void createSubstitutionServiceTemplateNics(ServiceTemplate substitutionServiceTemplate,
- VspModelInfo vspModelInfo) {
- Map<String, List<Nic>> nics = vspModelInfo.getNics();
- if (MapUtils.isNotEmpty(nics)) {
- for (Map.Entry<String, List<Nic>> entry : nics.entrySet()) {
- String componentId = entry.getKey();
- String componentNodeTemplateId = getSubstitutionComponentNodeTemplateId(
- vspModelInfo.getComponents().get(componentId));
- List<Nic> nicList = entry.getValue();
- if (CollectionUtils.isNotEmpty(nicList)) {
- for (Nic nic : nicList) {
- NodeTemplate nicNodeTemplate = new NodeTemplate();
- nicNodeTemplate.setType(ToscaNodeType.NETWORK_PORT);
- DataModelUtil.addBindingReqFromPortToCompute(componentNodeTemplateId, nicNodeTemplate);
- DataModelUtil.addNodeTemplate(substitutionServiceTemplate,
- getNicNodeTemplateId(nic.getName(), nic.getNetworkType()), nicNodeTemplate);
- }
+ private void createSubstitutionServiceTemplateComponents(ServiceTemplate substitutionServiceTemplate, VspModelInfo vspModelInfo) {
+ Map<String, String> components = vspModelInfo.getComponents();
+ if (MapUtils.isNotEmpty(components)) {
+ for (String componentName : components.values()) {
+ String localNodeTypeId = createComponentDefinitionNodeTemplate(substitutionServiceTemplate, componentName);
+ createLocalNodeType(substitutionServiceTemplate, localNodeTypeId);
+ }
}
- }
}
- }
- private String getSubstitutionComponentNodeTemplateId(String componentName) {
- //TODO: Confirm if anything else is needed here
- return componentName;
- }
-
- private String getNicNodeTemplateId(String nicName, NetworkType nicNetworkType) {
- StringBuilder builder = new StringBuilder();
- builder.append(nicName);
- if (nicNetworkType == NetworkType.External) {
- builder.append(GeneratorConstants.PORT_TYPE_EXTERNAL_NODE_TEMPLATE_SUFFIX);
- } else if (nicNetworkType == NetworkType.Internal) {
- builder.append(GeneratorConstants.PORT_TYPE_INTERNAL_NODE_TEMPLATE_SUFFIX);
+ private void createSubstitutionServiceTemplateNics(ServiceTemplate substitutionServiceTemplate, VspModelInfo vspModelInfo) {
+ Map<String, List<Nic>> nics = vspModelInfo.getNics();
+ if (MapUtils.isNotEmpty(nics)) {
+ for (Map.Entry<String, List<Nic>> entry : nics.entrySet()) {
+ String componentId = entry.getKey();
+ String componentNodeTemplateId = getSubstitutionComponentNodeTemplateId(vspModelInfo.getComponents().get(componentId));
+ List<Nic> nicList = entry.getValue();
+ if (CollectionUtils.isNotEmpty(nicList)) {
+ for (Nic nic : nicList) {
+ NodeTemplate nicNodeTemplate = new NodeTemplate();
+ nicNodeTemplate.setType(ToscaNodeType.NETWORK_PORT);
+ DataModelUtil.addBindingReqFromPortToCompute(componentNodeTemplateId, nicNodeTemplate);
+ DataModelUtil
+ .addNodeTemplate(substitutionServiceTemplate, getNicNodeTemplateId(nic.getName(), nic.getNetworkType()), nicNodeTemplate);
+ }
+ }
+ }
+ }
}
- builder.append(GeneratorConstants.PORT_NODE_TEMPLATE_ID_SUFFIX);
- return builder.toString();
- }
- private String createComponentDefinitionNodeTemplate(ServiceTemplate substitutionServiceTemplate,
- String componentName) {
- NodeTemplate nodeTemplate = new NodeTemplate();
- String localNodeTypeId = getLocalNodeTypeId(componentName);
- nodeTemplate.setType(localNodeTypeId);
- DataModelUtil.addNodeTemplate(substitutionServiceTemplate, componentName, nodeTemplate);
- return localNodeTypeId;
- }
-
- private void createLocalNodeType(ServiceTemplate substitutionServiceTemplate,
- String localNodeTypeId) {
- NodeType localNodeType = new NodeType();
- localNodeType.setDerived_from(ToscaNodeType.COMPUTE);
- DataModelUtil.addNodeType(substitutionServiceTemplate, localNodeTypeId, localNodeType );
- }
+ private String getSubstitutionComponentNodeTemplateId(String componentName) {
+ //TODO: Confirm if anything else is needed here
+ return componentName;
+ }
- private String getLocalNodeTypeId(String componentName) {
- return ToscaNodeType.VFC_NODE_TYPE_PREFIX + componentName;
- }
+ private String getNicNodeTemplateId(String nicName, NetworkType nicNetworkType) {
+ StringBuilder builder = new StringBuilder();
+ builder.append(nicName);
+ if (nicNetworkType == NetworkType.External) {
+ builder.append(GeneratorConstants.PORT_TYPE_EXTERNAL_NODE_TEMPLATE_SUFFIX);
+ } else if (nicNetworkType == NetworkType.Internal) {
+ builder.append(GeneratorConstants.PORT_TYPE_INTERNAL_NODE_TEMPLATE_SUFFIX);
+ }
+ builder.append(GeneratorConstants.PORT_NODE_TEMPLATE_ID_SUFFIX);
+ return builder.toString();
+ }
- private ServiceTemplate createInitSubstitutionServiceTemplate(String serviceTemplateName) {
- ServiceTemplate substitutionServiceTemplate = new ServiceTemplate();
- Map<String, String> templateMetadata = new HashMap<>();
- substitutionServiceTemplate.setTosca_definitions_version(ToscaConstants
- .TOSCA_DEFINITIONS_VERSION);
- templateMetadata.put(ToscaConstants.ST_METADATA_TEMPLATE_NAME, serviceTemplateName);
- substitutionServiceTemplate.setMetadata(templateMetadata);
- substitutionServiceTemplate.setTopology_template(new TopologyTemplate());
- substitutionServiceTemplate.setImports(getImports());
- return substitutionServiceTemplate;
- }
+ private String createComponentDefinitionNodeTemplate(ServiceTemplate substitutionServiceTemplate, String componentName) {
+ NodeTemplate nodeTemplate = new NodeTemplate();
+ String localNodeTypeId = getLocalNodeTypeId(componentName);
+ nodeTemplate.setType(localNodeTypeId);
+ DataModelUtil.addNodeTemplate(substitutionServiceTemplate, componentName, nodeTemplate);
+ return localNodeTypeId;
+ }
- private void handleSubstitutionMapping(ServiceTemplate substitutionServiceTemplate,
- ToscaServiceModel toscaServiceModel,
- String substitutionNodeTypeId,
- String componentName) {
- ServiceTemplate globalSubstitutionServiceTemplate = fetchGlobalSubstitutionServiceTemplate();
- NodeType substitutionNodeType =
- createGlobalSubstitutionNodeType(substitutionServiceTemplate, componentName);
- DataModelUtil.addNodeType(globalSubstitutionServiceTemplate, substitutionNodeTypeId,
- substitutionNodeType);
- Map<String, Map<String, List<String>>> substitutionMapping =
- GeneratorUtils.getSubstitutionNodeTypeExposedConnectionPoints(substitutionNodeType,
- substitutionServiceTemplate, toscaServiceModel);
- if (Objects.nonNull(substitutionMapping)) {
- //add substitution mapping after capability and requirement expose calculation
- substitutionServiceTemplate.getTopology_template().setSubstitution_mappings(
- DataModelUtil.createSubstitutionTemplateSubMapping(substitutionNodeTypeId,
- substitutionNodeType, substitutionMapping));
+ private void createLocalNodeType(ServiceTemplate substitutionServiceTemplate, String localNodeTypeId) {
+ NodeType localNodeType = new NodeType();
+ localNodeType.setDerived_from(ToscaNodeType.COMPUTE);
+ DataModelUtil.addNodeType(substitutionServiceTemplate, localNodeTypeId, localNodeType);
}
- }
- //*************** CREATE GLOBAL SUBSTITUTION SERVICE TEMPLATE **********************
+ private String getLocalNodeTypeId(String componentName) {
+ return ToscaNodeType.VFC_NODE_TYPE_PREFIX + componentName;
+ }
- private ServiceTemplate createInitGlobalSubstitutionServiceTemplate() {
- ServiceTemplate globalSubstitutionServiceTemplate = new ServiceTemplate();
- Map<String, String> templateMetadata = new HashMap<>();
- globalSubstitutionServiceTemplate.setTosca_definitions_version(ToscaConstants
- .TOSCA_DEFINITIONS_VERSION);
- templateMetadata.put(ToscaConstants.ST_METADATA_TEMPLATE_NAME,
- Constants.GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME);
- globalSubstitutionServiceTemplate.setMetadata(templateMetadata);
- globalSubstitutionServiceTemplate.setImports(getImports());
- return globalSubstitutionServiceTemplate;
- }
+ private ServiceTemplate createInitSubstitutionServiceTemplate(String serviceTemplateName) {
+ ServiceTemplate substitutionServiceTemplate = new ServiceTemplate();
+ Map<String, String> templateMetadata = new HashMap<>();
+ substitutionServiceTemplate.setTosca_definitions_version(ToscaConstants.TOSCA_DEFINITIONS_VERSION);
+ templateMetadata.put(ToscaConstants.ST_METADATA_TEMPLATE_NAME, serviceTemplateName);
+ substitutionServiceTemplate.setMetadata(templateMetadata);
+ substitutionServiceTemplate.setTopology_template(new TopologyTemplate());
+ substitutionServiceTemplate.setImports(getImports());
+ return substitutionServiceTemplate;
+ }
- private NodeType createGlobalSubstitutionNodeType(ServiceTemplate substitutionServiceTemplate,
- String componentName) {
- NodeType substitutionNodeType = new ToscaAnalyzerServiceImpl()
- .createInitSubstitutionNodeType(substitutionServiceTemplate,
- ToscaNodeType.MULTIFLAVOR_VFC_NODE_TYPE);
- substitutionNodeType.setProperties(
- getManualVspSubstitutionNodeTypeProperties(componentName));
- return substitutionNodeType;
- }
+ private void handleSubstitutionMapping(ServiceTemplate substitutionServiceTemplate, ToscaServiceModel toscaServiceModel,
+ String substitutionNodeTypeId, String componentName) {
+ ServiceTemplate globalSubstitutionServiceTemplate = fetchGlobalSubstitutionServiceTemplate();
+ NodeType substitutionNodeType = createGlobalSubstitutionNodeType(substitutionServiceTemplate, componentName);
+ DataModelUtil.addNodeType(globalSubstitutionServiceTemplate, substitutionNodeTypeId, substitutionNodeType);
+ Map<String, Map<String, List<String>>> substitutionMapping = GeneratorUtils
+ .getSubstitutionNodeTypeExposedConnectionPoints(substitutionNodeType, substitutionServiceTemplate, toscaServiceModel);
+ if (Objects.nonNull(substitutionMapping)) {
+ //add substitution mapping after capability and requirement expose calculation
+ substitutionServiceTemplate.getTopology_template().setSubstitution_mappings(
+ DataModelUtil.createSubstitutionTemplateSubMapping(substitutionNodeTypeId, substitutionNodeType, substitutionMapping));
+ }
+ }
- private Map<String, PropertyDefinition> getManualVspSubstitutionNodeTypeProperties(String componentName) {
- //Create num_cpus property
- PropertyDefinition numCpus = new PropertyDefinition();
- numCpus.setType(PropertyType.INTEGER.getDisplayName());
- numCpus.setDescription(GeneratorConstants.NUM_CPUS_PROP_DESC_PREFIX + componentName);
- numCpus.setRequired(true);
- //Create disk_size property
- PropertyDefinition diskSize = new PropertyDefinition();
- diskSize.setType(PropertyType.SCALAR_UNIT_SIZE.getDisplayName());
- diskSize.setDescription(GeneratorConstants.DISK_SIZE_PROP_DESC_PREFIX + componentName);
- diskSize.setRequired(true);
- //Create mem_size property
- PropertyDefinition memSize = new PropertyDefinition();
- memSize.setType(PropertyType.SCALAR_UNIT_SIZE.getDisplayName());
- memSize.setDescription(GeneratorConstants.MEM_SIZE_PROP_DESC_PREFIX + componentName);
- memSize.setRequired(true);
+ //*************** CREATE GLOBAL SUBSTITUTION SERVICE TEMPLATE **********************
+ private ServiceTemplate createInitGlobalSubstitutionServiceTemplate() {
+ ServiceTemplate globalSubstitutionServiceTemplate = new ServiceTemplate();
+ Map<String, String> templateMetadata = new HashMap<>();
+ globalSubstitutionServiceTemplate.setTosca_definitions_version(ToscaConstants.TOSCA_DEFINITIONS_VERSION);
+ templateMetadata.put(ToscaConstants.ST_METADATA_TEMPLATE_NAME, Constants.GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME);
+ globalSubstitutionServiceTemplate.setMetadata(templateMetadata);
+ globalSubstitutionServiceTemplate.setImports(getImports());
+ return globalSubstitutionServiceTemplate;
+ }
- Map<String, PropertyDefinition> manualVspProperties = new LinkedHashMap<>();
- manualVspProperties.put(GeneratorConstants.NUM_CPUS, numCpus);
- manualVspProperties.put(GeneratorConstants.DISK_SIZE, diskSize);
- manualVspProperties.put(GeneratorConstants.MEM_SIZE, memSize);
+ private NodeType createGlobalSubstitutionNodeType(ServiceTemplate substitutionServiceTemplate, String componentName) {
+ NodeType substitutionNodeType = new ToscaAnalyzerServiceImpl()
+ .createInitSubstitutionNodeType(substitutionServiceTemplate, ToscaNodeType.MULTIFLAVOR_VFC_NODE_TYPE);
+ substitutionNodeType.setProperties(getManualVspSubstitutionNodeTypeProperties(componentName));
+ return substitutionNodeType;
+ }
- return manualVspProperties;
- }
+ private Map<String, PropertyDefinition> getManualVspSubstitutionNodeTypeProperties(String componentName) {
+ //Create num_cpus property
+ PropertyDefinition numCpus = new PropertyDefinition();
+ numCpus.setType(PropertyType.INTEGER.getDisplayName());
+ numCpus.setDescription(GeneratorConstants.NUM_CPUS_PROP_DESC_PREFIX + componentName);
+ numCpus.setRequired(true);
+ //Create disk_size property
+ PropertyDefinition diskSize = new PropertyDefinition();
+ diskSize.setType(PropertyType.SCALAR_UNIT_SIZE.getDisplayName());
+ diskSize.setDescription(GeneratorConstants.DISK_SIZE_PROP_DESC_PREFIX + componentName);
+ diskSize.setRequired(true);
+ //Create mem_size property
+ PropertyDefinition memSize = new PropertyDefinition();
+ memSize.setType(PropertyType.SCALAR_UNIT_SIZE.getDisplayName());
+ memSize.setDescription(GeneratorConstants.MEM_SIZE_PROP_DESC_PREFIX + componentName);
+ memSize.setRequired(true);
+ Map<String, PropertyDefinition> manualVspProperties = new LinkedHashMap<>();
+ manualVspProperties.put(GeneratorConstants.NUM_CPUS, numCpus);
+ manualVspProperties.put(GeneratorConstants.DISK_SIZE, diskSize);
+ manualVspProperties.put(GeneratorConstants.MEM_SIZE, memSize);
+ return manualVspProperties;
+ }
- /**
- * Fetch global substitution service template service template.
- *
- * @return the global substitution service template
- */
- private ServiceTemplate fetchGlobalSubstitutionServiceTemplate() {
- ServiceTemplate globalSubstitutionServiceTemplate =
- generatedServiceTemplates.get(Constants.GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME);
- if (Objects.isNull(globalSubstitutionServiceTemplate)) {
- globalSubstitutionServiceTemplate = createInitGlobalSubstitutionServiceTemplate();
- generatedServiceTemplates.put(Constants.GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME,
- globalSubstitutionServiceTemplate);
+ /**
+ * Fetch global substitution service template service template.
+ *
+ * @return the global substitution service template
+ */
+ private ServiceTemplate fetchGlobalSubstitutionServiceTemplate() {
+ ServiceTemplate globalSubstitutionServiceTemplate = generatedServiceTemplates.get(Constants.GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME);
+ if (Objects.isNull(globalSubstitutionServiceTemplate)) {
+ globalSubstitutionServiceTemplate = createInitGlobalSubstitutionServiceTemplate();
+ generatedServiceTemplates.put(Constants.GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME, globalSubstitutionServiceTemplate);
+ }
+ return globalSubstitutionServiceTemplate;
}
- return globalSubstitutionServiceTemplate;
- }
}
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 a1460a8163..285ac2dbc4 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
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,10 +17,23 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.generator.core.utils;
-import org.onap.sdc.tosca.datatypes.model.*;
+import static org.openecomp.sdc.tosca.services.DataModelUtil.addSubstitutionNodeTypeRequirements;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import org.onap.sdc.tosca.datatypes.model.CapabilityDefinition;
+import org.onap.sdc.tosca.datatypes.model.NodeTemplate;
+import org.onap.sdc.tosca.datatypes.model.NodeType;
+import org.onap.sdc.tosca.datatypes.model.RequirementAssignment;
+import org.onap.sdc.tosca.datatypes.model.RequirementDefinition;
+import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
import org.onap.sdc.tosca.services.ToscaExtensionYamlUtil;
import org.openecomp.sdc.tosca.datatypes.ToscaElementTypes;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
@@ -29,22 +42,17 @@ import org.openecomp.sdc.tosca.services.ToscaAnalyzerService;
import org.openecomp.sdc.tosca.services.ToscaUtil;
import org.openecomp.sdc.tosca.services.impl.ToscaAnalyzerServiceImpl;
-import java.util.*;
-
-import static org.openecomp.sdc.tosca.services.DataModelUtil.addSubstitutionNodeTypeRequirements;
-
/**
* The type Generator utils.
*/
public class GeneratorUtils {
- private GeneratorUtils() {
- // prevent instantiation
- }
-
//TODO : Read from configuration
private static final List<String> SUPPORTED_CAPABILITIES = Arrays.asList("host", "os", "endpoint", "scalable");
private static final List<String> SUPPORTED_REQUIREMENTS = Collections.singletonList("link");
+ private GeneratorUtils() {
+ // prevent instantiation
+ }
/**
* Add service template to tosca service model.
@@ -52,9 +60,7 @@ public class GeneratorUtils {
* @param toscaServiceModel the tosca service model
* @param serviceTemplate the service template
*/
- public static void addServiceTemplateToToscaServiceModel(ToscaServiceModel toscaServiceModel,
- ServiceTemplate serviceTemplate) {
-
+ public static void addServiceTemplateToToscaServiceModel(ToscaServiceModel toscaServiceModel, ServiceTemplate serviceTemplate) {
String serviceTemplateFileName = ToscaUtil.getServiceTemplateFileName(serviceTemplate);
Map<String, ServiceTemplate> serviceTemplates = toscaServiceModel.getServiceTemplates();
if (!serviceTemplates.containsKey(serviceTemplateFileName)) {
@@ -72,11 +78,9 @@ public class GeneratorUtils {
* @return the substitution node type exposed connection points
*/
public static Map<String, Map<String, List<String>>> getSubstitutionNodeTypeExposedConnectionPoints(NodeType substitutionNodeType,
- ServiceTemplate substitutionServiceTemplate,
- ToscaServiceModel toscaServiceModel) {
-
- Map<String, NodeTemplate> nodeTemplates =
- substitutionServiceTemplate.getTopology_template().getNode_templates();
+ ServiceTemplate substitutionServiceTemplate,
+ ToscaServiceModel toscaServiceModel) {
+ Map<String, NodeTemplate> nodeTemplates = substitutionServiceTemplate.getTopology_template().getNode_templates();
String nodeTemplateId;
NodeTemplate nodeTemplate;
String nodeType;
@@ -84,7 +88,6 @@ public class GeneratorUtils {
if (nodeTemplates == null) {
return substitutionMapping;
}
-
try {
Map<String, List<String>> capabilitySubstitutionMapping = new HashMap<>();
Map<String, List<String>> requirementSubstitutionMapping = new HashMap<>();
@@ -96,54 +99,41 @@ public class GeneratorUtils {
Map<String, Map<String, RequirementAssignment>> fullFilledRequirementsDefinition = new HashMap<>();
Map<String, CapabilityDefinition> nodeTypeCapabilitiesDefinition = new HashMap<>();
Map<String, CapabilityDefinition> exposedCapabilitiesDefinition;
-
ToscaAnalyzerService toscaAnalyzerService = new ToscaAnalyzerServiceImpl();
for (Map.Entry<String, NodeTemplate> entry : nodeTemplates.entrySet()) {
nodeTemplateId = entry.getKey();
nodeTemplate = entry.getValue();
nodeType = nodeTemplate.getType();
NodeType flatNodeType = (NodeType) toscaAnalyzerService
- .getFlatEntity(ToscaElementTypes.NODE_TYPE, nodeType,
- substitutionServiceTemplate, toscaServiceModel)
- .getFlatEntity();
+ .getFlatEntity(ToscaElementTypes.NODE_TYPE, nodeType, substitutionServiceTemplate, toscaServiceModel).getFlatEntity();
// get requirements
- nodeTypeRequirementsDefinition =
- getNodeTypeRequirements(flatNodeType, nodeTemplateId, substitutionServiceTemplate,
- requirementSubstitutionMapping);
+ nodeTypeRequirementsDefinition = getNodeTypeRequirements(flatNodeType, nodeTemplateId, substitutionServiceTemplate,
+ requirementSubstitutionMapping);
nodeTemplateRequirementsAssignment = DataModelUtil.getNodeTemplateRequirements(nodeTemplate);
fullFilledRequirementsDefinition.put(nodeTemplateId, nodeTemplateRequirementsAssignment);
//set substitution node type requirements
exposedRequirementsDefinition = toscaAnalyzerService
- .calculateExposedRequirements(nodeTypeRequirementsDefinition,
- nodeTemplateRequirementsAssignment);
-
-
+ .calculateExposedRequirements(nodeTypeRequirementsDefinition, nodeTemplateRequirementsAssignment);
//Filter unsupported requirements
Iterator<Map<String, RequirementDefinition>> iterator = exposedRequirementsDefinition.iterator();
while (iterator.hasNext()) {
Map<String, RequirementDefinition> requirementDefinitionMap = iterator.next();
- for (Map.Entry<String, RequirementDefinition> requirementDefinitionEntry : requirementDefinitionMap
- .entrySet()) {
+ for (Map.Entry<String, RequirementDefinition> requirementDefinitionEntry : requirementDefinitionMap.entrySet()) {
String requirementKey = requirementDefinitionEntry.getKey();
if (!SUPPORTED_REQUIREMENTS.contains(requirementKey)) {
iterator.remove();
}
}
}
- addSubstitutionNodeTypeRequirements(substitutionNodeType, exposedRequirementsDefinition,
- nodeTemplateId);
+ addSubstitutionNodeTypeRequirements(substitutionNodeType, exposedRequirementsDefinition, nodeTemplateId);
//get capabilities
- addNodeTypeCapabilitiesToSubMapping(nodeTypeCapabilitiesDefinition, capabilitySubstitutionMapping,
- nodeType, nodeTemplateId, substitutionServiceTemplate, toscaServiceModel);
+ addNodeTypeCapabilitiesToSubMapping(nodeTypeCapabilitiesDefinition, capabilitySubstitutionMapping, nodeType, nodeTemplateId,
+ substitutionServiceTemplate, toscaServiceModel);
}
-
exposedCapabilitiesDefinition = toscaAnalyzerService
- .calculateExposedCapabilities(nodeTypeCapabilitiesDefinition,
- fullFilledRequirementsDefinition);
-
+ .calculateExposedCapabilities(nodeTypeCapabilitiesDefinition, fullFilledRequirementsDefinition);
//Filter unsupported capabilities
- Iterator<Map.Entry<String, CapabilityDefinition>> iterator =
- exposedCapabilitiesDefinition.entrySet().iterator();
+ Iterator<Map.Entry<String, CapabilityDefinition>> iterator = exposedCapabilitiesDefinition.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, CapabilityDefinition> capabilityDefinitionEntry = iterator.next();
//Expected Capability is of the format <capabilityId>_<componentName>
@@ -152,7 +142,6 @@ public class GeneratorUtils {
iterator.remove();
}
}
-
DataModelUtil.setNodeTypeCapabilitiesDef(substitutionNodeType, exposedCapabilitiesDefinition);
} catch (Exception ex) {
return null;
@@ -169,21 +158,19 @@ public class GeneratorUtils {
* @param requirementSubstitutionMapping the requirement substitution mapping
* @return the node type requirements
*/
- public static List<Map<String, RequirementDefinition>> getNodeTypeRequirements(NodeType flatNodeType,
- String templateName,
- ServiceTemplate serviceTemplate,
- Map<String, List<String>> requirementSubstitutionMapping) {
+ public static List<Map<String, RequirementDefinition>> getNodeTypeRequirements(NodeType flatNodeType, String templateName,
+ ServiceTemplate serviceTemplate,
+ Map<String, List<String>> requirementSubstitutionMapping) {
List<Map<String, RequirementDefinition>> requirementList = new ArrayList<>();
List<String> requirementMapping;
if (flatNodeType.getRequirements() != null) {
for (Map<String, RequirementDefinition> requirementMap : flatNodeType.getRequirements()) {
for (Map.Entry<String, RequirementDefinition> requirementNodeEntry : requirementMap.entrySet()) {
ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
- RequirementDefinition requirementNodeEntryValue = toscaExtensionYamlUtil.yamlToObject(
- toscaExtensionYamlUtil.objectToYaml(requirementNodeEntry.getValue()),
- RequirementDefinition.class);
+ RequirementDefinition requirementNodeEntryValue = toscaExtensionYamlUtil
+ .yamlToObject(toscaExtensionYamlUtil.objectToYaml(requirementNodeEntry.getValue()), RequirementDefinition.class);
if (requirementNodeEntryValue.getOccurrences() == null) {
- requirementNodeEntryValue.setOccurrences(new Object[] {1, 1});
+ requirementNodeEntryValue.setOccurrences(new Object[]{1, 1});
}
Map<String, RequirementDefinition> requirementDef = new HashMap<>();
requirementDef.put(requirementNodeEntry.getKey(), requirementNodeEntryValue);
@@ -191,10 +178,9 @@ public class GeneratorUtils {
requirementMapping = new ArrayList<>();
requirementMapping.add(templateName);
requirementMapping.add(requirementNodeEntry.getKey());
- requirementSubstitutionMapping
- .put(requirementNodeEntry.getKey() + "_" + templateName, requirementMapping);
+ requirementSubstitutionMapping.put(requirementNodeEntry.getKey() + "_" + templateName, requirementMapping);
if (requirementNodeEntryValue.getNode() == null) {
- requirementNodeEntryValue.setOccurrences(new Object[] {1, 1});
+ requirementNodeEntryValue.setOccurrences(new Object[]{1, 1});
}
}
}
@@ -203,18 +189,15 @@ public class GeneratorUtils {
}
private static void addNodeTypeCapabilitiesToSubMapping(Map<String, CapabilityDefinition> nodeTypeCapabilitiesDefinition,
- Map<String, List<String>> capabilitySubstitutionMapping,
- String type, String templateName,
- ServiceTemplate substitutionServiceTemplate,
- ToscaServiceModel toscaServiceModel) {
+ Map<String, List<String>> capabilitySubstitutionMapping, String type, String templateName,
+ ServiceTemplate substitutionServiceTemplate, ToscaServiceModel toscaServiceModel) {
ToscaAnalyzerService toscaAnalyzerService = new ToscaAnalyzerServiceImpl();
- NodeType flatNodeType = (NodeType) toscaAnalyzerService.getFlatEntity(ToscaElementTypes.NODE_TYPE, type,
- substitutionServiceTemplate, toscaServiceModel).getFlatEntity();
+ NodeType flatNodeType = (NodeType) toscaAnalyzerService
+ .getFlatEntity(ToscaElementTypes.NODE_TYPE, type, substitutionServiceTemplate, toscaServiceModel).getFlatEntity();
String capabilityKey;
List<String> capabilityMapping;
if (flatNodeType.getCapabilities() != null) {
- for (Map.Entry<String, CapabilityDefinition> capabilityNodeEntry : flatNodeType.getCapabilities()
- .entrySet()) {
+ for (Map.Entry<String, CapabilityDefinition> capabilityNodeEntry : flatNodeType.getCapabilities().entrySet()) {
capabilityKey = capabilityNodeEntry.getKey() + "_" + templateName;
nodeTypeCapabilitiesDefinition.put(capabilityKey, capabilityNodeEntry.getValue().clone());
capabilityMapping = new ArrayList<>();
@@ -224,5 +207,4 @@ public class GeneratorUtils {
}
}
}
-
}