aboutsummaryrefslogtreecommitdiffstats
path: root/asdc-controller/src
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2018-09-04 11:21:02 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2018-09-08 22:33:28 -0400
commit69455a268648881f4b5a0c4547d769c2e6ecc2c1 (patch)
tree8ea753e5282e91316d842522c8873fd51572344c /asdc-controller/src
parent3e9ee0977d0c8643f81e720bbf23e5a40864a0d8 (diff)
added generic fabric support to SO
Fix Autoincrement of ID field in table Fix accidental removal of method Update usage of requestdb client removed unused imports in common tasks and test Fix broken branch, have unit tests pass references the Epic branch Fix broken branch from compiling committing classpath for vfc adapter cause its not going away added in the fail case for when there are no profiles removed second set of adapters in application test yml removed double adapters in request db application test added jpa repo dependency to the so bpmn folder pom add creation timestamp column to the table added in null checks for Config returned from policy switched to string in requestprocess with jenerate switched to string in requestprocess with jenerate updated aai version in common pom to 605 from 591 renamed the db scripts for flyway sync to register added endpoint to application test yml for failing test ... Change-Id: I800f837ea75d7cdff740dc3a387e4d7654cfd085 Issue-ID: SO-972 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'asdc-controller/src')
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/ASDCControllerSingleton.java1
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java18
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/ResourceInstance.java2
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleArtifact.java10
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java9
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java272
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/util/YamlEditor.java8
-rw-r--r--asdc-controller/src/test/resources/schema.sql74
8 files changed, 363 insertions, 31 deletions
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/ASDCControllerSingleton.java b/asdc-controller/src/main/java/org/onap/so/asdc/ASDCControllerSingleton.java
index 471a08bf99..62971ecd2b 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/ASDCControllerSingleton.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/ASDCControllerSingleton.java
@@ -15,7 +15,6 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- * Modifications Copyright (C) 2018 IBM.
* ============LICENSE_END=========================================================
*/
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java
index 55a437f2c0..fae3a49910 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java
@@ -268,7 +268,7 @@ public class ASDCController {
- private IDistributionClientDownloadResult downloadTheArtifact (IArtifactInfo artifact,
+ protected IDistributionClientDownloadResult downloadTheArtifact (IArtifactInfo artifact,
String distributionId) throws ASDCDownloadException {
LOGGER.debug ("Trying to download the artifact : " + artifact.getArtifactURL ()
@@ -370,7 +370,7 @@ public class ASDCController {
}
- private void sendDeployNotificationsForResource(VfResourceStructure vfResourceStructure,DistributionStatusEnum distribStatus, String errorReason) {
+ protected void sendDeployNotificationsForResource(VfResourceStructure vfResourceStructure,DistributionStatusEnum distribStatus, String errorReason) {
for (IArtifactInfo artifactInfo : vfResourceStructure.getResourceInstance().getArtifacts()) {
@@ -397,7 +397,7 @@ public class ASDCController {
}
}
- private void sendCsarDeployNotification(INotificationData iNotif, VfResourceStructure resourceStructure, ToscaResourceStructure toscaResourceStructure, boolean deploySuccessful, String errorReason) {
+ protected void sendCsarDeployNotification(INotificationData iNotif, VfResourceStructure resourceStructure, ToscaResourceStructure toscaResourceStructure, boolean deploySuccessful, String errorReason) {
IArtifactInfo csarArtifact = toscaResourceStructure.getToscaArtifact();
@@ -424,7 +424,7 @@ public class ASDCController {
}
}
- private void deployResourceStructure (VfResourceStructure resourceStructure, ToscaResourceStructure toscaResourceStructure) throws ArtifactInstallerException {
+ protected void deployResourceStructure (VfResourceStructure resourceStructure, ToscaResourceStructure toscaResourceStructure) throws ArtifactInstallerException {
LOGGER.info (MessageEnum.ASDC_START_DEPLOY_ARTIFACT, resourceStructure.getResourceInstance().getResourceInstanceName(), resourceStructure.getResourceInstance().getResourceUUID(), "ASDC");
try {
@@ -459,7 +459,7 @@ public class ASDCController {
DOWNLOAD, DEPLOY
}
- private void sendASDCNotification (NotificationType notificationType,
+ protected void sendASDCNotification (NotificationType notificationType,
String artifactURL,
String consumerID,
String distributionID,
@@ -515,7 +515,7 @@ public class ASDCController {
LOGGER.recordMetricEvent (subStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully sent notification to ASDC", "ASDC", action, null);
}
- private void sendFinalDistributionStatus (
+ protected void sendFinalDistributionStatus (
String distributionID,
DistributionStatusEnum status,
String errorReason) {
@@ -664,7 +664,7 @@ public class ASDCController {
}
}
- private void processResourceNotification (INotificationData iNotif) {
+ protected void processResourceNotification (INotificationData iNotif) {
// For each artifact, create a structure describing the VFModule in a ordered flat level
VfResourceStructure resourceStructure = null;
ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure();
@@ -735,7 +735,7 @@ public class ASDCController {
"Exception caught during Installation of artifact", "ASDC", "processResourceNotification", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in processResourceNotification", e);
}
}
- private void processCsarServiceArtifacts (INotificationData iNotif, ToscaResourceStructure toscaResourceStructure) {
+ protected void processCsarServiceArtifacts (INotificationData iNotif, ToscaResourceStructure toscaResourceStructure) {
List<IArtifactInfo> serviceArtifacts = iNotif.getServiceArtifacts();
@@ -768,7 +768,7 @@ public class ASDCController {
}
private static final String UNKNOWN="Unknown";
-
+
/**
* @return the address of the ASDC we are connected to.
*/
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ResourceInstance.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ResourceInstance.java
index cfdff85bc3..9115ed3ef2 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ResourceInstance.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ResourceInstance.java
@@ -24,7 +24,7 @@ import java.util.ArrayList;
import org.onap.sdc.api.notification.IResourceInstance;
-final class ResourceInstance implements IResourceInstance {
+public class ResourceInstance implements IResourceInstance {
@Override
public String getResourceInstanceName(){
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleArtifact.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleArtifact.java
index adc8071454..92fc598e7d 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleArtifact.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleArtifact.java
@@ -44,7 +44,15 @@ public final class VfModuleArtifact {
public VfModuleArtifact(IArtifactInfo artifactinfo,IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException {
artifactInfo=artifactinfo;
result = new String(clientResult.getArtifactPayload(), "UTF-8");
-
+ }
+
+ public VfModuleArtifact(IArtifactInfo artifactinfo,IDistributionClientDownloadResult clientResult, String modifiedHeatTemplate) throws UnsupportedEncodingException {
+ artifactInfo=artifactinfo;
+ if(modifiedHeatTemplate != null){
+ result = modifiedHeatTemplate;
+ }else{
+ result = new String(clientResult.getArtifactPayload(), "UTF-8");
+ }
}
public HeatFiles getHeatFiles() {
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java
index a045c2bb3a..f5e45115fd 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java
@@ -102,6 +102,15 @@ public class VfResourceStructure {
public void addArtifactToStructure(IDistributionClient distributionClient,IArtifactInfo artifactinfo,IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException {
VfModuleArtifact vfModuleArtifact = new VfModuleArtifact(artifactinfo,clientResult);
+ addArtifactByType(artifactinfo,clientResult,vfModuleArtifact);
+ }
+
+ public void addArtifactToStructure(IDistributionClient distributionClient,IArtifactInfo artifactinfo,IDistributionClientDownloadResult clientResult, String modifiedHeatTemplate) throws UnsupportedEncodingException {
+ VfModuleArtifact vfModuleArtifact = new VfModuleArtifact(artifactinfo,clientResult,modifiedHeatTemplate);
+ addArtifactByType(artifactinfo,clientResult,vfModuleArtifact);
+ }
+
+ protected void addArtifactByType(IArtifactInfo artifactinfo,IDistributionClientDownloadResult clientResult, VfModuleArtifact vfModuleArtifact) throws UnsupportedEncodingException {
switch(artifactinfo.getArtifactType()) {
case ASDCConfiguration.HEAT:
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 7dfb1bae3e..70831bc828 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
@@ -41,6 +41,7 @@ import org.onap.sdc.toscaparser.api.CapabilityAssignment;
import org.onap.sdc.toscaparser.api.CapabilityAssignments;
import org.onap.sdc.toscaparser.api.Group;
import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.Policy;
import org.onap.sdc.toscaparser.api.RequirementAssignment;
import org.onap.sdc.toscaparser.api.elements.Metadata;
import org.onap.sdc.utils.DistributionStatusEnum;
@@ -62,6 +63,7 @@ import org.onap.so.db.catalog.beans.CollectionResourceCustomization;
import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
import org.onap.so.db.catalog.beans.ConfigurationResource;
import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization;
+import org.onap.so.db.catalog.beans.CvnfcCustomization;
import org.onap.so.db.catalog.beans.ExternalServiceToInternalService;
import org.onap.so.db.catalog.beans.HeatEnvironment;
import org.onap.so.db.catalog.beans.HeatFiles;
@@ -83,12 +85,16 @@ import org.onap.so.db.catalog.beans.VfModule;
import org.onap.so.db.catalog.beans.VfModuleCustomization;
import org.onap.so.db.catalog.beans.VnfResource;
import org.onap.so.db.catalog.beans.VnfResourceCustomization;
+import org.onap.so.db.catalog.beans.VnfVfmoduleCvnfcConfigurationCustomization;
+import org.onap.so.db.catalog.beans.VnfcCustomization;
import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization;
import org.onap.so.db.catalog.data.repository.AllottedResourceCustomizationRepository;
import org.onap.so.db.catalog.data.repository.AllottedResourceRepository;
import org.onap.so.db.catalog.data.repository.CollectionResourceCustomizationRepository;
import org.onap.so.db.catalog.data.repository.CollectionResourceRepository;
import org.onap.so.db.catalog.data.repository.ConfigurationResourceCustomizationRepository;
+import org.onap.so.db.catalog.data.repository.ConfigurationResourceRepository;
+import org.onap.so.db.catalog.data.repository.CvnfcCustomizationRepository;
import org.onap.so.db.catalog.data.repository.ExternalServiceToInternalServiceRepository;
import org.onap.so.db.catalog.data.repository.HeatTemplateRepository;
import org.onap.so.db.catalog.data.repository.InstanceGroupRepository;
@@ -101,6 +107,7 @@ import org.onap.so.db.catalog.data.repository.VFModuleCustomizationRepository;
import org.onap.so.db.catalog.data.repository.VFModuleRepository;
import org.onap.so.db.catalog.data.repository.VnfCustomizationRepository;
import org.onap.so.db.catalog.data.repository.VnfResourceRepository;
+import org.onap.so.db.catalog.data.repository.VnfcCustomizationRepository;
import org.onap.so.db.catalog.data.repository.VnfcInstanceGroupCustomizationRepository;
import org.onap.so.db.request.beans.WatchdogComponentDistributionStatus;
import org.onap.so.db.request.beans.WatchdogDistributionStatus;
@@ -151,6 +158,9 @@ public class ToscaResourceInstaller {
@Autowired
protected ConfigurationResourceCustomizationRepository configCustomizationRepo;
+
+ @Autowired
+ protected ConfigurationResourceRepository configRepo;
@Autowired
protected VnfResourceRepository vnfRepo;
@@ -166,6 +176,12 @@ public class ToscaResourceInstaller {
@Autowired
protected VnfcInstanceGroupCustomizationRepository vnfcInstanceGroupCustomizationRepo;
+
+ @Autowired
+ protected VnfcCustomizationRepository vnfcCustomizationRepo;
+
+ @Autowired
+ protected CvnfcCustomizationRepository cvnfcCustomizationRepo;
@Autowired
protected AllottedResourceRepository allottedRepo;
@@ -420,40 +436,57 @@ public class ToscaResourceInstaller {
protected void processVfModules(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStructure,
Service service, NodeTemplate nodeTemplate, Metadata metadata, String vfCustomizationCategory) throws Exception {
- if (!vfCustomizationCategory.equalsIgnoreCase(ALLOTTED_RESOURCE))
+
+ logger.debug("VF Category is : " + vfCustomizationCategory);
+
+ //if (!vfCustomizationCategory.equalsIgnoreCase(ALLOTTED_RESOURCE))
+ if(vfResourceStructure.getVfModuleStructure() != null && !vfResourceStructure.getVfModuleStructure().isEmpty())
{
String vfCustomizationUUID = toscaResourceStruct.getSdcCsarHelper()
.getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
- logger.debug("vfCustomizationUUID=" + vfCustomizationUUID);
+ logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);
- IResourceInstance vfMetaDataResource = vfResourceStructure.getResourceInstance();
+ IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
- // Make sure the vfMetadata and tosca customizations match before comparing their VF Modules UUID's
- if(vfCustomizationUUID.equals(vfMetaDataResource.getResourceCustomizationUUID())){
-
- logger.debug("vfCustomizationUUID: " + vfCustomizationUUID + " matches vfMetaData CustomizationUUID");
+ // Make sure the VF ResourceCustomizationUUID from the notification and tosca customizations match before comparing their VF Modules UUID's
+ logger.debug("Checking if Notification VF ResourceCustomizationUUID: " + vfNotificationResource.getResourceCustomizationUUID() +
+ " matches Tosca VF Customization UUID: " + vfCustomizationUUID);
+
+ if(vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())){
- VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service);
+ logger.debug("vfCustomizationUUID: " + vfCustomizationUUID + " matches vfNotificationResource CustomizationUUID");
- for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) {
- logger.debug("vfModuleStructure ModelUUID: " + vfModuleStructure.toString());
+ VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service);
+
+ Set<CvnfcCustomization> cvnfcCustomizations = new HashSet<CvnfcCustomization>();
+ Set<VnfcCustomization> vnfcCustomizations = new HashSet<VnfcCustomization>();
+
+ for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) {
+
+ logger.debug("vfModuleStructure:" + vfModuleStructure.toString());
List<org.onap.sdc.toscaparser.api.Group> vfGroups = toscaResourceStruct
.getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID);
- IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata();
+ IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata();
+
+ logger.debug("Comparing VFModule Metadata CustomizationUUID : " + vfMetadata.getVfModuleModelCustomizationUUID());
+ for(Group group : vfGroups){
+ logger.debug("To Group VFModuleModelCustomizationUUID " + group.getMetadata().getValue("vfModuleModelCustomizationUUID"));
+ }
Optional<org.onap.sdc.toscaparser.api.Group> matchingObject = vfGroups.stream().
filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID").equals(vfMetadata.getVfModuleModelCustomizationUUID())).
findFirst();
if(matchingObject.isPresent()){
- VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(), nodeTemplate, toscaResourceStruct, vfResourceStructure,vfMetadata, vnfResource);
+ VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(), nodeTemplate, toscaResourceStruct,
+ vfResourceStructure,vfMetadata, vnfResource, service, cvnfcCustomizations, vnfcCustomizations);
vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources());
}else
throw new Exception("Cannot find matching VFModule Customization for VF Module Metadata: " + vfMetadata.getVfModuleModelCustomizationUUID());
}
service.getVnfCustomizations().add(vnfResource);
- }
+ }
}
}
@@ -744,7 +777,38 @@ public class ToscaResourceInstaller {
return configCustomizationResource;
}
+
+ protected ConfigurationResourceCustomization createFabricConfiguration(NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure) {
+
+ Metadata fabricMetadata = nodeTemplate.getMetaData();
+
+ ConfigurationResource configResource = new ConfigurationResource();
+
+ configResource.setModelName(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ configResource.setModelInvariantUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ configResource.setModelUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ configResource.setModelVersion(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ configResource.setDescription(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+ configResource.setToscaNodeType(nodeTemplate.getType());
+
+ ConfigurationResourceCustomization configCustomizationResource = new ConfigurationResourceCustomization();
+
+ Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>();
+
+ configCustomizationResource.setModelCustomizationUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ configCustomizationResource.setModelInstanceName(nodeTemplate.getName());
+
+ configCustomizationResource.setNfFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "function"));
+ configCustomizationResource.setNfRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "role"));
+ configCustomizationResource.setNfType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, "type"));
+ configCustomizationResource.setConfigResourceCustomization(configCustomizationResource);
+ configCustomizationResource.setConfigurationResource(configResource);
+ configResourceCustomizationSet.add(configCustomizationResource);
+ configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);
+
+ return configCustomizationResource;
+ }
protected void createToscaCsar(ToscaResourceStructure toscaResourceStructure) {
ToscaCsar toscaCsar = new ToscaCsar();
@@ -761,6 +825,34 @@ public class ToscaResourceInstaller {
toscaResourceStructure.setCatalogToscaCsar(toscaCsar);
}
+
+ protected VnfcCustomization findExistingVfc(Set<VnfcCustomization> vnfcCustomizations, String customizationUUID) {
+ VnfcCustomization vnfcCustomization = null;
+ for(VnfcCustomization vnfcCustom : vnfcCustomizations){
+ if (vnfcCustom != null && vnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) {
+ vnfcCustomization = vnfcCustom;
+ }
+ }
+
+ if(vnfcCustomization==null)
+ vnfcCustomization = vnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID);
+
+ return vnfcCustomization;
+ }
+
+ protected CvnfcCustomization findExistingCvfc(Set<CvnfcCustomization> cvnfcCustomizations, String customizationUUID) {
+ CvnfcCustomization cvnfcCustomization = null;
+ for(CvnfcCustomization cvnfcCustom : cvnfcCustomizations){
+ if (cvnfcCustom != null && cvnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) {
+ cvnfcCustomization = cvnfcCustom;
+ }
+ }
+
+ if(cvnfcCustomization==null)
+ cvnfcCustomization = cvnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID);
+
+ return cvnfcCustomization;
+ }
protected NetworkResourceCustomization createNetwork(NodeTemplate networkNodeTemplate,
ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin,Service service) {
@@ -1084,7 +1176,7 @@ public class ToscaResourceInstaller {
protected VfModuleCustomization createVFModuleResource(Group group, NodeTemplate nodeTemplate,
ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure,
- IVfModuleData vfModuleData, VnfResourceCustomization vnfResource) {
+ IVfModuleData vfModuleData, VnfResourceCustomization vnfResource, Service service, Set<CvnfcCustomization> cvnfcCustomizations, Set<VnfcCustomization> vnfcCustomizations) {
VfModuleCustomization vfModuleCustomization = findExistingVfModuleCustomization(vnfResource,
vfModuleData.getVfModuleModelCustomizationUUID());
if(vfModuleCustomization == null){
@@ -1104,9 +1196,160 @@ public class ToscaResourceInstaller {
vfResourceStructure.setAlreadyDeployed(true);
}
+ //******************************************************************************************************************
+ //* Extract VFC's and CVFC's then add them to VFModule
+ //******************************************************************************************************************
+
+ Set<VnfVfmoduleCvnfcConfigurationCustomization> vnfVfmoduleCvnfcConfigurationCustomizations = new HashSet<VnfVfmoduleCvnfcConfigurationCustomization>();
+
+ // Extract CVFC lists
+ List<NodeTemplate> cvfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(nodeTemplate, SdcTypes.CVFC);
+
+ for(NodeTemplate cvfcTemplate : cvfcList) {
+
+ CvnfcCustomization existingCvnfcCustomization = findExistingCvfc(cvnfcCustomizations, cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+
+ if(existingCvnfcCustomization == null){
+
+ //Extract associated VFC - Should always be just one
+ List<NodeTemplate> vfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(cvfcTemplate, SdcTypes.VFC);
+
+ VnfcCustomization vnfcCustomization = new VnfcCustomization();
+ VnfcCustomization existingVnfcCustomization = null;
+
+ for(NodeTemplate vfcTemplate : vfcList) {
+
+ existingVnfcCustomization = findExistingVfc(vnfcCustomizations, vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+
+ if(existingVnfcCustomization == null){
+ vnfcCustomization.setModelCustomizationUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ vnfcCustomization.setModelInstanceName(vfcTemplate.getName());
+ vnfcCustomization.setModelInvariantUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ vnfcCustomization.setModelName(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ vnfcCustomization.setModelUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+
+ vnfcCustomization.setModelVersion(
+ testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+ vnfcCustomization.setDescription(
+ testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ vnfcCustomization.setToscaNodeType(testNull(vfcTemplate.getType()));
+
+ vnfcCustomizations.add(vnfcCustomization);
+ }
+
+ }
+
+ CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
+ cvnfcCustomization.setModelCustomizationUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ cvnfcCustomization.setModelInstanceName(cvfcTemplate.getName());
+ cvnfcCustomization.setModelInvariantUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ cvnfcCustomization.setModelName(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ cvnfcCustomization.setModelUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+
+ cvnfcCustomization.setModelVersion(
+ testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+ cvnfcCustomization.setDescription(
+ testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ cvnfcCustomization.setToscaNodeType(testNull(cvfcTemplate.getType()));
+
+ if(existingVnfcCustomization != null){
+ cvnfcCustomization.setVnfcCustomization(existingVnfcCustomization);
+ }else{
+ cvnfcCustomization.setVnfcCustomization(vnfcCustomization);
+ }
+
+ cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization);
+ cvnfcCustomization.setVnfResourceCustomization(vnfResource);
+
+ cvnfcCustomizations.add(cvnfcCustomization);
+
+ //*****************************************************************************************************************************************
+ //* Extract Fabric Configuration
+ //*****************************************************************************************************************************************
+
+ List<NodeTemplate> fabricConfigList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(nodeTemplate, SdcTypes.CONFIGURATION);
+
+ for(NodeTemplate fabricTemplate : fabricConfigList) {
+
+ ConfigurationResource fabricConfig = null;
+
+ ConfigurationResource existingConfig = findExistingConfiguration(service, fabricTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+
+ if(existingConfig == null){
+
+ ConfigurationResourceCustomization fabricConfigCustomization = createFabricConfiguration(fabricTemplate, toscaResourceStructure);
+
+ fabricConfig = fabricConfigCustomization.getConfigurationResource();
+
+ service.getConfigurationCustomizations().add(fabricConfigCustomization);
+ }else {
+ fabricConfig = existingConfig;
+ }
+
+
+ VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = createVfCnvfConfigCustomization(fabricTemplate, toscaResourceStructure,
+ vnfResource, vfModuleCustomization, cvnfcCustomization, fabricConfig);
+
+ vnfVfmoduleCvnfcConfigurationCustomizations.add(vnfVfmoduleCvnfcConfigurationCustomization);
+ }
+
+ }
+
+ }
+
+ vfModuleCustomization.setVnfcCustomization(vnfcCustomizations);
+ vfModuleCustomization.setCvnfcCustomization(cvnfcCustomizations);
+ vfModuleCustomization.setVnfVfmoduleCvnfcConfigurationCustomization(vnfVfmoduleCvnfcConfigurationCustomizations);
+
return vfModuleCustomization;
}
+ protected VnfVfmoduleCvnfcConfigurationCustomization createVfCnvfConfigCustomization(NodeTemplate fabricTemplate, ToscaResourceStructure toscaResourceStruct,
+ VnfResourceCustomization vnfResource, VfModuleCustomization vfModuleCustomization, CvnfcCustomization cvnfcCustomization,
+ ConfigurationResource configResource) {
+
+ Metadata fabricMetadata = fabricTemplate.getMetaData();
+
+
+ VnfVfmoduleCvnfcConfigurationCustomization vfModuleToCvnfc = new VnfVfmoduleCvnfcConfigurationCustomization();
+
+ vfModuleToCvnfc.setConfigurationResource(configResource);
+ vfModuleToCvnfc.setCvnfcCustomization(cvnfcCustomization);
+ vfModuleToCvnfc.setModelCustomizationUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ vfModuleToCvnfc.setModelInstanceName(fabricTemplate.getName());
+ vfModuleToCvnfc.setVfModuleCustomization(vfModuleCustomization);
+ vfModuleToCvnfc.setVnfResourceCustomization(vnfResource);
+ vfModuleToCvnfc.setPolicyName(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "name"));
+
+ List<Policy> policyList = toscaResourceStruct.getSdcCsarHelper().getPoliciesOfTarget(fabricTemplate);
+
+ if(policyList != null){
+ for(Policy policy : policyList){
+ vfModuleToCvnfc.setPolicyName(policy.getName());
+ }
+ }
+
+ vfModuleToCvnfc.setConfigurationFunction(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
+ vfModuleToCvnfc.setConfigurationRole(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE));
+ vfModuleToCvnfc.setConfigurationType(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
+
+ return vfModuleToCvnfc;
+ }
+
+ protected ConfigurationResource findExistingConfiguration(Service service, String modelUUID) {
+ ConfigurationResource configResource = null;
+ for(ConfigurationResourceCustomization configurationResourceCustom : service.getConfigurationCustomizations()){
+ if (configurationResourceCustom.getConfigurationResource() != null
+ && configurationResourceCustom.getConfigurationResource().getModelUUID().equals(modelUUID)) {
+ configResource = configurationResourceCustom.getConfigurationResource();
+ }
+ }
+ if(configResource==null)
+ configResource = configRepo.findResourceByModelUUID(modelUUID);
+
+ return configResource;
+ }
+
protected VfModuleCustomization findExistingVfModuleCustomization(VnfResourceCustomization vnfResource,
String vfModuleModelCustomizationUUID) {
VfModuleCustomization vfModuleCustomization = null;
@@ -1210,6 +1453,7 @@ public class ToscaResourceInstaller {
protected void setHeatInformationForVfModule(ToscaResourceStructure toscaResourceStructure,
VfResourceStructure vfResourceStructure, VfModule vfModule, VfModuleCustomization vfModuleCustomization,
Metadata vfMetadata) {
+
Optional<VfModuleStructure> matchingObject = vfResourceStructure.getVfModuleStructure().stream()
.filter(vfModuleStruct -> vfModuleStruct.getVfModuleMetadata().getVfModuleModelUUID()
.equalsIgnoreCase(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/util/YamlEditor.java b/asdc-controller/src/main/java/org/onap/so/asdc/util/YamlEditor.java
index fdeddf1f68..32f512b0f0 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/util/YamlEditor.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/util/YamlEditor.java
@@ -39,9 +39,9 @@ import org.onap.so.db.catalog.beans.HeatTemplateParam;
public class YamlEditor {
- private static final String REFER_PATTERN = "file:///";
- private Map <String, Object> yml;
- private Yaml yaml = new Yaml ();
+ protected static final String REFER_PATTERN = "file:///";
+ protected Map <String, Object> yml;
+ protected Yaml yaml = new Yaml ();
public YamlEditor () {
@@ -52,7 +52,7 @@ public class YamlEditor {
}
@SuppressWarnings("unchecked")
- private synchronized void init (byte[] body) {
+ protected synchronized void init (byte[] body) {
InputStream input = new ByteArrayInputStream (body);
yml = (Map <String, Object>) yaml.load (input);
}
diff --git a/asdc-controller/src/test/resources/schema.sql b/asdc-controller/src/test/resources/schema.sql
index f8f32b7005..0372887f15 100644
--- a/asdc-controller/src/test/resources/schema.sql
+++ b/asdc-controller/src/test/resources/schema.sql
@@ -771,6 +771,78 @@ FOREIGN KEY (`NB_REQ_REF_LOOKUP_ID`) REFERENCES `northbound_request_ref_lookup`
ON DELETE CASCADE ON UPDATE CASCADE)
ENGINE = InnoDB DEFAULT CHARACTER SET = latin1;
+CREATE TABLE IF NOT EXISTS vnfc_customization (
+`MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL,
+`MODEL_INSTANCE_NAME` VARCHAR(200) NOT NULL,
+`MODEL_UUID` VARCHAR(200) NOT NULL,
+`MODEL_INVARIANT_UUID` VARCHAR(200) NOT NULL,
+`MODEL_VERSION` VARCHAR(20) NOT NULL,
+`MODEL_NAME` VARCHAR(200) NOT NULL,
+`TOSCA_NODE_TYPE` VARCHAR(200) NOT NULL,
+`DESCRIPTION` VARCHAR(1200) NULL DEFAULT NULL,
+`CREATION_TIMESTAMP` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+PRIMARY KEY (`MODEL_CUSTOMIZATION_UUID`))
+ENGINE = InnoDB
+AUTO_INCREMENT = 20654
+DEFAULT CHARACTER SET = latin1;
+
+CREATE TABLE IF NOT EXISTS cvnfc_customization (
+`ID` INT(11) NOT NULL AUTO_INCREMENT,
+`MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL,
+`MODEL_INSTANCE_NAME` VARCHAR(200) NOT NULL,
+`MODEL_UUID` VARCHAR(200) NOT NULL,
+`MODEL_INVARIANT_UUID` VARCHAR(200) NOT NULL,
+`MODEL_VERSION` VARCHAR(20) NOT NULL,
+`MODEL_NAME` VARCHAR(200) NOT NULL,
+`TOSCA_NODE_TYPE` VARCHAR(200) NOT NULL,
+`DESCRIPTION` VARCHAR(1200) NULL DEFAULT NULL,
+`NFC_FUNCTION` VARCHAR(200) NULL,
+`NFC_NAMING_CODE` VARCHAR(200) NULL,
+`CREATION_TIMESTAMP` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+`VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL,
+`VF_MODULE_CUST_MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL,
+`VNFC_CUST_MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL, PRIMARY KEY (`ID`), INDEX `fk_cvnfc_customization__vf_module_customization1_idx` (`VF_MODULE_CUST_MODEL_CUSTOMIZATION_UUID` ASC), INDEX `fk_cvnfc_customization__vnfc_customization1_idx` (`VNFC_CUST_MODEL_CUSTOMIZATION_UUID` ASC), INDEX `fk_cvnfc_customization__vnf_resource_customization1_idx` (`VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID` ASC), UNIQUE INDEX `UK_cvnfc_customization` (`VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID` ASC, `VF_MODULE_CUST_MODEL_CUSTOMIZATION_UUID` ASC, `MODEL_CUSTOMIZATION_UUID` ASC), INDEX `fk_cvnfc_customization__vnf_vfmod_cvnfc_config_cust1_idx` (`MODEL_CUSTOMIZATION_UUID` ASC), CONSTRAINT `fk_cvnfc_customization__vf_module_customization1` FOREIGN KEY (`VF_MODULE_CUST_MODEL_CUSTOMIZATION_UUID`) REFERENCES `vf_module_customization` (`MODEL_CUSTOMIZATION_UUID`) ON
+DELETE CASCADE ON
+UPDATE CASCADE, CONSTRAINT `fk_cvnfc_customization__vnfc_customization1` FOREIGN KEY (`VNFC_CUST_MODEL_CUSTOMIZATION_UUID`) REFERENCES `vnfc_customization` (`MODEL_CUSTOMIZATION_UUID`) ON
+DELETE CASCADE ON
+UPDATE CASCADE, CONSTRAINT `fk_cvnfc_customization__vnf_resource_customization1` FOREIGN KEY (`VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID`) REFERENCES `vnf_resource_customization` (`MODEL_CUSTOMIZATION_UUID`) ON
+DELETE CASCADE ON
+UPDATE CASCADE) ENGINE = InnoDB AUTO_INCREMENT = 20654 DEFAULT CHARACTER SET = latin1;
+
+
+CREATE TABLE IF NOT EXISTS vnf_vfmodule_cvnfc_configuration_customization (
+ `ID` INT(11) NOT NULL AUTO_INCREMENT,
+ `MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL,
+ `VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL,
+ `VF_MODULE_MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL,
+ `CVNFC_MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL,
+ `MODEL_INSTANCE_NAME` VARCHAR(200) NOT NULL,
+ `CONFIGURATION_TYPE` VARCHAR(200) NULL,
+ `CONFIGURATION_ROLE` VARCHAR(200) NULL,
+ `CONFIGURATION_FUNCTION` VARCHAR(200) NULL,
+ `POLICY_NAME` VARCHAR(200) NULL,
+ `CREATION_TIMESTAMP` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ `CONFIGURATION_MODEL_UUID` VARCHAR(200) NOT NULL,
+ PRIMARY KEY (`ID`),
+ INDEX `fk_vnf_vfmodule_cvnfc_config_cust__configuration_idx` (`CONFIGURATION_MODEL_UUID` ASC),
+ UNIQUE INDEX `UK_vnf_vfmodule_cvnfc_configuration_customization` (`VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID` ASC , `VF_MODULE_MODEL_CUSTOMIZATION_UUID` ASC , `CVNFC_MODEL_CUSTOMIZATION_UUID` ASC , `MODEL_CUSTOMIZATION_UUID` ASC),
+ INDEX `fk_vnf_vfmodule_cvnfc_config_cust__cvnfc_cust1_idx` (`CVNFC_MODEL_CUSTOMIZATION_UUID` ASC),
+ INDEX `fk_vnf_vfmodule_cvnfc_config_cust__vf_module_cust_idx` (`VF_MODULE_MODEL_CUSTOMIZATION_UUID` ASC),
+ INDEX `fk_vnf_vfmodule_cvnfc_config_cust__vnf_res_cust_idx` (`VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID` ASC),
+ CONSTRAINT `fk_vnf_vfmod_cvnfc_config_cust__configuration_resource` FOREIGN KEY (`CONFIGURATION_MODEL_UUID`)
+ REFERENCES `configuration` (`MODEL_UUID`)
+ ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `fk_cvnfc_configuration_customization__cvnfc_customization1` FOREIGN KEY (`CVNFC_MODEL_CUSTOMIZATION_UUID`)
+ REFERENCES `cvnfc_customization` (`MODEL_CUSTOMIZATION_UUID`)
+ ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `fk_vnf_configuration_cvnfc_customization__vf_module_customiza1` FOREIGN KEY (`VF_MODULE_MODEL_CUSTOMIZATION_UUID`)
+ REFERENCES `vf_module_customization` (`MODEL_CUSTOMIZATION_UUID`)
+ ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `fk_vfmodule_cvnfc_configuration_customization__vnf_resource_c1` FOREIGN KEY (`VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID`)
+ REFERENCES `vnf_resource_customization` (`MODEL_CUSTOMIZATION_UUID`)
+ ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=INNODB AUTO_INCREMENT=20654 DEFAULT CHARACTER SET=LATIN1;
+
--------START Request DB SCHEMA --------
CREATE DATABASE requestdb;
USE requestdb;
@@ -1036,4 +1108,4 @@ create table if not exists model (
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
ALTER TABLE `catalogdb`.`vnf_recipe`
-CHANGE COLUMN `VNF_TYPE` `NF_ROLE` VARCHAR(200) NULL DEFAULT NULL ; \ No newline at end of file
+CHANGE COLUMN `VNF_TYPE` `NF_ROLE` VARCHAR(200) NULL DEFAULT NULL ;