Update nf_type for PNF in AAI 76/130776/1
authoraleem.raja@t-systems.com <aleem.raja@t-systems.com>
Wed, 7 Sep 2022 10:24:04 +0000 (15:54 +0530)
committeraleem.raja@t-systems.com <aleem.raja@t-systems.com>
Wed, 7 Sep 2022 10:24:17 +0000 (15:54 +0530)
Update nf_type for PNF in AAI to distinguish different PNFs
nf_type value will come from SDC properties

Issue-ID: SO-3967
Signed-off-by: aleem.raja@t-systems.com <aleem.raja@t-systems.com>
Change-Id: I9dd039ac098a60f7cf4d4a9c456c7681f64d9987

bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoPnf.java
bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java
bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java
bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ModelInfoPnfExpected.json [new file with mode: 0644]
bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/PnfResourceCustomizationInput.json [new file with mode: 0644]
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java

index a01fa96..9b81979 100644 (file)
 
 package org.onap.so.bpmn.servicedecomposition.modelinfo;
 
+import com.fasterxml.jackson.annotation.JsonProperty;
 import java.io.Serializable;
 
 public class ModelInfoPnf extends ModelInfoMetadata implements Serializable {
     private static final long serialVersionUID = 50687109134317615L;
+
+    @JsonProperty("nf-role")
+    private String role;
+
+    @JsonProperty("nf-type")
+    private String NfType;
+
+    public String getRole() {
+        return role;
+    }
+
+    public void setRole(String role) {
+        this.role = role;
+    }
+
+    public String getNfType() {
+        return NfType;
+    }
+
+    public void setNfType(String nfType) {
+        NfType = nfType;
+    }
 }
index a0784b3..c36aaac 100644 (file)
@@ -86,6 +86,7 @@ import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization;
 import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization;
 import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
 import org.onap.so.db.catalog.beans.OrchestrationStatus;
+import org.onap.so.db.catalog.beans.PnfResourceCustomization;
 import org.onap.so.db.catalog.beans.Service;
 import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization;
 import org.onap.so.db.catalog.beans.VfModuleCustomization;
@@ -982,6 +983,13 @@ public class BBInputSetup implements JavaDelegate {
         }
     }
 
+    protected void mapCatalogPnf(Pnf pnf, ModelInfo modelInfo, Service service) {
+        PnfResourceCustomization pnfResourceCustomization = getPnfResourceCustomizationFromService(modelInfo, service);
+        if (pnfResourceCustomization != null) {
+            pnf.setModelInfoPnf(this.mapperLayer.mapCatalogPnfToPnf(pnfResourceCustomization));
+        }
+    }
+
     protected VnfResourceCustomization getVnfResourceCustomizationFromService(ModelInfo modelInfo, Service service) {
         VnfResourceCustomization vnfResourceCustomization = null;
         for (VnfResourceCustomization resourceCust : service.getVnfCustomizations()) {
@@ -993,6 +1001,17 @@ public class BBInputSetup implements JavaDelegate {
         return vnfResourceCustomization;
     }
 
+    protected PnfResourceCustomization getPnfResourceCustomizationFromService(ModelInfo modelInfo, Service service) {
+        PnfResourceCustomization pnfResourceCustomization = null;
+        for (PnfResourceCustomization resourceCust : service.getPnfCustomizations()) {
+            if (resourceCust.getModelCustomizationUUID().equalsIgnoreCase(modelInfo.getModelCustomizationUuid())) {
+                pnfResourceCustomization = resourceCust;
+                break;
+            }
+        }
+        return pnfResourceCustomization;
+    }
+
     protected void populateL3Network(BBInputSetupParameter parameter) {
         L3Network network = null;
         for (L3Network networkTemp : parameter.getServiceInstance().getNetworks()) {
@@ -1645,6 +1664,15 @@ public class BBInputSetup implements JavaDelegate {
                         .filter(pnfs -> Objects.equals(key, pnfs.getModelInfo().getModelCustomizationId())).findFirst()
                         .ifPresent(pnfs -> BBInputSetupPnf.populatePnfToServiceInstance(pnfs, pnfId, serviceInstance));
             }
+
+            serviceInstance.getPnfs().stream().filter(pnf -> pnfInstanceName.equalsIgnoreCase(pnf.getPnfName()))
+                    .findFirst().ifPresent(pnf -> {
+                        ModelInfo pnfModelInfo = new ModelInfo();
+                        pnfModelInfo.setModelCustomizationUuid(pnf.getModelInfoPnf().getModelCustomizationUuid());
+                        pnfModelInfo.setModelCustomizationId(pnf.getModelInfoPnf().getModelCustomizationUuid());
+                        mapCatalogPnf(pnf, pnfModelInfo, service);
+                    });
+
         } else if (bbName.contains(VF_MODULE) || bbName.contains(VOLUME_GROUP) || (bbName.contains(CONTROLLER)
                 && (VF_MODULE).equalsIgnoreCase(executeBB.getBuildingBlock().getBpmnScope()))) {
             String vfModuleInstanceName = lookupKeyMap.get(ResourceKey.VF_MODULE_INSTANCE_NAME);
index 2bb383e..759c9ec 100644 (file)
@@ -65,6 +65,7 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration;
 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup;
 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork;
+import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoPnf;
 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceProxy;
 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
@@ -79,6 +80,7 @@ import org.onap.so.db.catalog.beans.InstanceGroupType;
 import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
 import org.onap.so.db.catalog.beans.OrchestrationStatus;
 import org.onap.so.db.catalog.beans.Service;
+import org.onap.so.db.catalog.beans.PnfResourceCustomization;
 import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization;
 import org.onap.so.db.catalog.beans.VfModuleCustomization;
 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
@@ -480,6 +482,12 @@ public class BBInputSetupMapperLayer {
         return modelInfoVnf;
     }
 
+    protected ModelInfoPnf mapCatalogPnfToPnf(PnfResourceCustomization pnfResourceCustomization) {
+        ModelInfoPnf modelInfoPnf = modelMapper.map(pnfResourceCustomization, ModelInfoPnf.class);
+        modelMapper.map(pnfResourceCustomization.getPnfResources(), modelInfoPnf);
+        return modelInfoPnf;
+    }
+
     protected ModelInfoVfModule mapCatalogVfModuleToVfModule(VfModuleCustomization vfResourceCustomization) {
         ModelInfoVfModule modelInfoVfModule = modelMapper.map(vfResourceCustomization, ModelInfoVfModule.class);
         modelMapper.map(vfResourceCustomization.getVfModule(), modelInfoVfModule);
index 9195df0..6f09130 100644 (file)
@@ -61,6 +61,7 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup;
 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork;
 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoPnf;
 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
 import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
 import org.onap.so.db.catalog.beans.CollectionResource;
@@ -74,6 +75,8 @@ import org.onap.so.db.catalog.beans.InstanceGroup;
 import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
 import org.onap.so.db.catalog.beans.OrchestrationStatus;
 import org.onap.so.db.catalog.beans.Service;
+import org.onap.so.db.catalog.beans.PnfResource;
+import org.onap.so.db.catalog.beans.PnfResourceCustomization;
 import org.onap.so.db.catalog.beans.VfModuleCustomization;
 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
 import org.onap.so.db.catalog.beans.VnfcCustomization;
@@ -507,6 +510,26 @@ public class BBInputSetupMapperLayerTest {
         assertThat(actualModelInfoGenericVnf, sameBeanAs(expectedModelInfoGenericVnf));
     }
 
+    @Test
+    public void testMapCatalogPnfToPnf() throws IOException {
+        PnfResourceCustomization pnfResourceCustomization = mapper.readValue(
+                new File(RESOURCE_PATH + "PnfResourceCustomizationInput.json"), PnfResourceCustomization.class);
+
+        PnfResource pnfResource = new PnfResource();
+        pnfResource.setModelUUID("modelUuid");
+        pnfResource.setModelInvariantUUID("modelInvariantUuid");
+        pnfResource.setModelVersion("modelVersion");
+
+        pnfResourceCustomization.setPnfResources(pnfResource);
+
+        ModelInfoPnf expectedModelInfoPnf =
+                mapper.readValue(new File(RESOURCE_PATH + "ModelInfoPnfExpected.json"), ModelInfoPnf.class);
+
+        ModelInfoPnf actualModelInfoPnf = bbInputSetupMapperLayer.mapCatalogPnfToPnf(pnfResourceCustomization);
+
+        assertThat(actualModelInfoPnf, sameBeanAs(expectedModelInfoPnf));
+    }
+
     @Test
     public void testMapCatalogVfModuleToVfModule() throws JsonParseException, JsonMappingException, IOException {
         VfModuleCustomization vfResourceCustomization = mapper
index 803d2bf..bc751c3 100644 (file)
@@ -97,6 +97,7 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup;
 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork;
 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoPnf;
 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceProxy;
 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
 import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException;
@@ -113,6 +114,7 @@ import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization;
 import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
 import org.onap.so.db.catalog.beans.OrchestrationStatus;
 import org.onap.so.db.catalog.beans.Service;
+import org.onap.so.db.catalog.beans.PnfResourceCustomization;
 import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization;
 import org.onap.so.db.catalog.beans.VfModuleCustomization;
 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
@@ -1734,6 +1736,28 @@ public class BBInputSetupTest {
         assertEquals(modelInfoGenericVnf, genericVnf.getModelInfoGenericVnf());
     }
 
+    @Test
+    public void testMapCatalogPnf() {
+        ModelInfoPnf modelInfoPnf = new ModelInfoPnf();
+        Pnf pnf = new Pnf();
+        RequestDetails requestDetails = new RequestDetails();
+        ModelInfo modelInfo = new ModelInfo();
+        modelInfo.setModelCustomizationUuid("modelCustomizationUUID");
+        requestDetails.setModelInfo(modelInfo);
+        Service service = new Service();
+
+        PnfResourceCustomization resourceCust = new PnfResourceCustomization();
+        resourceCust.setModelCustomizationUUID("pnfModelCustomizationUUID");
+        service.getPnfCustomizations().add(resourceCust);
+        resourceCust.setModelCustomizationUUID("modelCustomizationUUID");
+
+        doReturn(modelInfoPnf).when(bbInputSetupMapperLayer).mapCatalogPnfToPnf(resourceCust);
+
+        SPY_bbInputSetup.mapCatalogPnf(pnf, modelInfo, service);
+
+        assertEquals(modelInfoPnf, pnf.getModelInfoPnf());
+    }
+
     @Test
     public void testMapCatalogCollectionAndInstanceGroup() {
         ModelInfoCollection modelInfoCollection = new ModelInfoCollection();
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ModelInfoPnfExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ModelInfoPnfExpected.json
new file mode 100644 (file)
index 0000000..5c9dbb6
--- /dev/null
@@ -0,0 +1,11 @@
+{
+  "nfType": "nfType",
+  "model-customization-uuid": "modelCustomizationUUID",
+  "model-invariant-uuid": "modelInvariantUuid",
+  "model-uuid": "modelUuid",
+  "model-version": "modelVersion",
+  "model-instance-name": "modelInstanceName",
+  "model-name": null,
+  "nf-role": "nfRole",
+  "nf-type": "nfType"
+}
\ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/PnfResourceCustomizationInput.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/PnfResourceCustomizationInput.json
new file mode 100644 (file)
index 0000000..b7845ba
--- /dev/null
@@ -0,0 +1,14 @@
+{
+  "modelCustomizationUUID" : "modelCustomizationUUID",
+  "modelInstanceName" : "modelInstanceName",
+  "minInstances": 2,
+  "maxInstances": 3,
+  "availabilityZoneMaxCount": 5,
+  "nfFunction" : "nfFunction",
+  "nfType" : "nfType",
+  "nfRole" : "nfRole",
+  "nfNamingCode" : "nfNamingCode",
+  "multiStageDesign" : "multiStageDesign",
+  "blueprintName" : "testBlueprintName",
+  "blueprintVersion" : "testBlueprintVersion"
+}
\ No newline at end of file
index 9899d89..4664ffc 100644 (file)
@@ -113,6 +113,7 @@ public class AAIObjectMapper {
                     map().setModelCustomizationId(source.getModelInfoPnf().getModelCustomizationUuid());
                     map().setModelInvariantId(source.getModelInfoPnf().getModelInvariantUuid());
                     map().setModelVersionId(source.getModelInfoPnf().getModelUuid());
+                    map().setNfType(source.getModelInfoPnf().getNfType());
                 }
             });
         }