summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.11__AddVnfResourceOrder.sql3
-rw-r--r--adapters/mso-openstack-adapters/src/test/resources/schema.sql1
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java123
-rw-r--r--asdc-controller/src/test/resources/schema.sql1
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql1
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java12
-rw-r--r--mso-catalog-db/src/test/resources/schema.sql1
7 files changed, 140 insertions, 2 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.11__AddVnfResourceOrder.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.11__AddVnfResourceOrder.sql
new file mode 100644
index 0000000000..fabb005567
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.11__AddVnfResourceOrder.sql
@@ -0,0 +1,3 @@
+use catalogdb;
+ALTER TABLE vnf_resource_customization
+ADD VNFCINSTANCEGROUP_ORDER varchar(255); \ No newline at end of file
diff --git a/adapters/mso-openstack-adapters/src/test/resources/schema.sql b/adapters/mso-openstack-adapters/src/test/resources/schema.sql
index 94c8e55dfd..5e986ab34d 100644
--- a/adapters/mso-openstack-adapters/src/test/resources/schema.sql
+++ b/adapters/mso-openstack-adapters/src/test/resources/schema.sql
@@ -1107,6 +1107,7 @@ CREATE TABLE `vnf_resource_customization` (
`CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`VNF_RESOURCE_MODEL_UUID` varchar(200) NOT NULL,
`SERVICE_MODEL_UUID` varchar(200) NOT NULL,
+ `VNFCINSTANCEGROUP_ORDER` varchar(200) default NULL,
PRIMARY KEY (`ID`),
UNIQUE KEY `UK_vnf_resource_customization` (`MODEL_CUSTOMIZATION_UUID`,`SERVICE_MODEL_UUID`),
KEY `fk_vnf_resource_customization__vnf_resource1_idx` (`VNF_RESOURCE_MODEL_UUID`),
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
index aba70f33e3..ddf1f3d84b 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
@@ -26,6 +26,7 @@ package org.onap.so.asdc.installer.heat;
import java.sql.Timestamp;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
@@ -142,6 +143,7 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
+import org.springframework.util.CollectionUtils;
@Component
public class ToscaResourceInstaller {
@@ -983,7 +985,13 @@ public class ToscaResourceInstaller {
vnfcInstanceGroupCustomizationRepo.saveAndFlush(vnfcInstanceGroupCustomization);
}
-
+ List<String> seqResult = processVNFCGroupSequence(toscaResourceStruct, groupList);
+ if (!CollectionUtils.isEmpty(seqResult)) {
+ String resultStr = seqResult.stream().collect(Collectors.joining(","));
+ vnfResource.setVnfcInstanceGroupOrder(resultStr);
+ logger.debug(
+ "vnfcGroupOrder result for service uuid(" + service.getModelUUID() + ") : " + resultStr);
+ }
// add this vnfResource with existing vnfResource for this service
addVnfCustomization(service, vnfResource);
} else {
@@ -994,6 +1002,85 @@ public class ToscaResourceInstaller {
}
}
+ private List<String> processVNFCGroupSequence(ToscaResourceStructure toscaResourceStructure,
+ List<Group> groupList) {
+ if (CollectionUtils.isEmpty(groupList)) {
+ return Collections.emptyList();
+ }
+
+ ISdcCsarHelper iSdcCsarHelper = toscaResourceStructure.getSdcCsarHelper();
+ List<String> strSequence = new ArrayList<>(groupList.size());
+ List<Group> tempGroupList = new ArrayList<>(groupList.size());
+ List<NodeTemplate> nodes = new ArrayList<>();
+ tempGroupList.addAll(groupList);
+
+ for (Group group : groupList) {
+ List<NodeTemplate> nodeList = group.getMemberNodes();
+ boolean hasRequirements = false;
+ for (NodeTemplate node : nodeList) {
+ RequirementAssignments requirements = iSdcCsarHelper.getRequirementsOf(node);
+ if (requirements != null && requirements.getAll() != null && !requirements.getAll().isEmpty()) {
+ hasRequirements = true;
+ break;
+ }
+ }
+
+ if (!hasRequirements) {
+ strSequence.add(group.getName());
+ tempGroupList.remove(group);
+ nodes.addAll(nodeList);
+ }
+ }
+
+ getVNFCGroupSequenceList(strSequence, tempGroupList, nodes, iSdcCsarHelper);
+
+ return strSequence;
+
+ }
+
+ private void getVNFCGroupSequenceList(List<String> strSequence, List<Group> groupList, List<NodeTemplate> nodes,
+ ISdcCsarHelper iSdcCsarHelper) {
+ if (CollectionUtils.isEmpty(groupList)) {
+ return;
+ }
+
+ List<Group> tempGroupList = new ArrayList<>();
+ tempGroupList.addAll(groupList);
+
+ for (Group group : groupList) {
+ ArrayList<NodeTemplate> members = group.getMemberNodes();
+ for (NodeTemplate memberNode : members) {
+ boolean isAllExists = true;
+ RequirementAssignments requirements = iSdcCsarHelper.getRequirementsOf(memberNode);
+ if (requirements == null || requirements.getAll() == null || requirements.getAll().isEmpty()) {
+ continue;
+ }
+ List<RequirementAssignment> rqaList = requirements.getAll();
+ for (RequirementAssignment rqa : rqaList) {
+ String name = rqa.getNodeTemplateName();
+ for (NodeTemplate node : nodes) {
+ if (name.equals(node.getName())) {
+ break;
+ }
+ }
+
+ isAllExists = false;
+ break;
+ }
+
+ if (isAllExists) {
+ strSequence.add(group.getName());
+ tempGroupList.remove(group);
+ nodes.addAll(group.getMemberNodes());
+ }
+ }
+
+ if (tempGroupList.size() != 0 && tempGroupList.size() < groupList.size()) {
+ getVNFCGroupSequenceList(strSequence, tempGroupList, nodes, iSdcCsarHelper);
+ }
+ }
+ }
+
public void processWatchdog(String distributionId, String servideUUID, Optional<String> distributionNotification,
String consumerId) {
WatchdogServiceModVerIdLookup modVerIdLookup =
@@ -1704,12 +1791,37 @@ public class ToscaResourceInstaller {
vfcInstanceGroupCustom.setFunction(toscaResourceStructure.getSdcCsarHelper()
.getNodeTemplatePropertyLeafValue(vnfcNodeTemplate, getInputName));
vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup);
-
+ createVFCInstanceGroupMembers(vfcInstanceGroupCustom, group);
return vfcInstanceGroupCustom;
}
+ private void createVFCInstanceGroupMembers(VnfcInstanceGroupCustomization vfcInstanceGroupCustom, Group group) {
+ List<NodeTemplate> members = group.getMemberNodes();
+ if (!CollectionUtils.isEmpty(members)) {
+ for (NodeTemplate vfcTemplate : members) {
+ VnfcCustomization vnfcCustomization = new VnfcCustomization();
+
+ Metadata metadata = vfcTemplate.getMetaData();
+ vnfcCustomization
+ .setModelCustomizationUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ vnfcCustomization.setModelInstanceName(vfcTemplate.getName());
+ vnfcCustomization.setModelUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ vnfcCustomization
+ .setModelInvariantUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ vnfcCustomization.setModelVersion(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ vnfcCustomization.setModelName(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ vnfcCustomization.setToscaNodeType(testNull(vfcTemplate.getType()));
+ vnfcCustomization
+ .setDescription(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+
+ // @After vfcInstanceGroupCustom merged
+ // vfcInstanceGroupCustom.getVnfcCustomizations().add(vnfcCustomization);
+ }
+ }
+ }
+
protected VfModuleCustomization createVFModuleResource(Group group, NodeTemplate vfTemplate,
ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure,
IVfModuleData vfModuleData, VnfResourceCustomization vnfResource, Service service,
@@ -2229,6 +2341,13 @@ public class ToscaResourceInstaller {
}
+ if (vnfResourceCustomization.getMinInstances() == null && vnfResourceCustomization.getMaxInstances() == null) {
+ vnfResourceCustomization.setMinInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
+ vnfResourceCustomization.setMaxInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
+ }
+
toscaResourceStructure.setCatalogVnfResourceCustomization(vnfResourceCustomization);
return vnfResourceCustomization;
diff --git a/asdc-controller/src/test/resources/schema.sql b/asdc-controller/src/test/resources/schema.sql
index 8cc5ee9d49..a50b275c20 100644
--- a/asdc-controller/src/test/resources/schema.sql
+++ b/asdc-controller/src/test/resources/schema.sql
@@ -1109,6 +1109,7 @@ CREATE TABLE `vnf_resource_customization` (
`CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`VNF_RESOURCE_MODEL_UUID` varchar(200) NOT NULL,
`SERVICE_MODEL_UUID` varchar(200) NOT NULL,
+ `VNFCINSTANCEGROUP_ORDER` varchar(200) default NULL,
PRIMARY KEY (`ID`),
UNIQUE KEY `UK_vnf_resource_customization` (`MODEL_CUSTOMIZATION_UUID`,`SERVICE_MODEL_UUID`),
KEY `fk_vnf_resource_customization__vnf_resource1_idx` (`VNF_RESOURCE_MODEL_UUID`),
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql
index bc9003f5d0..6b748c1eb5 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql
@@ -1108,6 +1108,7 @@ CREATE TABLE `vnf_resource_customization` (
`CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`VNF_RESOURCE_MODEL_UUID` varchar(200) NOT NULL,
`SERVICE_MODEL_UUID` varchar(200) NOT NULL,
+ `VNFCINSTANCEGROUP_ORDER` varchar(200) default NULL,
PRIMARY KEY (`ID`),
UNIQUE KEY `UK_vnf_resource_customization` (`MODEL_CUSTOMIZATION_UUID`,`SERVICE_MODEL_UUID`),
KEY `fk_vnf_resource_customization__vnf_resource1_idx` (`VNF_RESOURCE_MODEL_UUID`),
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java
index af99aa8c80..36c9251d59 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java
@@ -121,6 +121,9 @@ public class VnfResourceCustomization implements Serializable {
@Column(name = "SKIP_POST_INSTANTIATION_CONFIGURATION")
private Boolean skipPostInstConf;
+ @Column(name = "VNFCINSTANCEGROUP_ORDER")
+ private String vnfcInstanceGroupOrder;
+
@Override
public boolean equals(final Object other) {
if (!(other instanceof VnfResourceCustomization)) {
@@ -148,6 +151,7 @@ public class VnfResourceCustomization implements Serializable {
.append("nfType", nfType).append("nfRole", nfRole).append("nfNamingCode", nfNamingCode)
.append("multiStageDesign", multiStageDesign).append("vnfResources", vnfResources)
.append("vfModuleCustomizations", vfModuleCustomizations)
+ .append("vnfcInstanceGroupOrder", vnfcInstanceGroupOrder)
.append("vnfcInstanceGroupCustomizations", vnfcInstanceGroupCustomizations).toString();
}
@@ -324,4 +328,12 @@ public class VnfResourceCustomization implements Serializable {
public void setSkipPostInstConf(Boolean skipPostInstConf) {
this.skipPostInstConf = skipPostInstConf;
}
+
+ public String getVnfcInstanceGroupOrder() {
+ return vnfcInstanceGroupOrder;
+ }
+
+ public void setVnfcInstanceGroupOrder(String vnfcInstanceGroupOrder) {
+ this.vnfcInstanceGroupOrder = vnfcInstanceGroupOrder;
+ }
}
diff --git a/mso-catalog-db/src/test/resources/schema.sql b/mso-catalog-db/src/test/resources/schema.sql
index f5e7d52ba4..7a894692bf 100644
--- a/mso-catalog-db/src/test/resources/schema.sql
+++ b/mso-catalog-db/src/test/resources/schema.sql
@@ -1106,6 +1106,7 @@ CREATE TABLE `vnf_resource_customization` (
`CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`VNF_RESOURCE_MODEL_UUID` varchar(200) NOT NULL,
`SERVICE_MODEL_UUID` varchar(200) NOT NULL,
+ `VNFCINSTANCEGROUP_ORDER` varchar(200) default NULL,
PRIMARY KEY (`ID`),
UNIQUE KEY `UK_vnf_resource_customization` (`MODEL_CUSTOMIZATION_UUID`,`SERVICE_MODEL_UUID`),
KEY `fk_vnf_resource_customization__vnf_resource1_idx` (`VNF_RESOURCE_MODEL_UUID`),