Fix OOF serviceResourceId bug 33/49733/1
authorMarcus G K Williams <marcus.williams@intel.com>
Thu, 31 May 2018 10:52:10 +0000 (03:52 -0700)
committerMarcus G K Williams <marcus.williams@intel.com>
Thu, 31 May 2018 10:52:23 +0000 (03:52 -0700)
- Works around a bug in OOF
where OOF does not return a serviceResourceId
with homing solutions. SO uses serviceResourceId
to match a homing deman to a homing request.
This patch addes resourceModuleName as another
way to match a demand to a request, as currently
OOF needs this to be unique.

- Changes SO homing processing of key cloudRegionId to
key locationId as this is now the key used for cloudRegionId
in solutions sent back from OOF

Issue-ID: OPTFRA-249
Change-Id: I8e5d9244a227ea4d3d061a758f202144bac270ce
Signed-off-by: Marcus G K Williams <marcus.williams@intel.com>
bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/OofHoming.groovy
bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCallback2AR1Vnf
bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCallback2AR1Vnf2Net
bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCallbackInfraVnf
bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCatalogResp.json

index d6576b7..df6b27f 100644 (file)
@@ -28,6 +28,7 @@ import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils
 import org.openecomp.mso.bpmn.core.domain.CloudFlavor
 import org.openecomp.mso.bpmn.core.domain.InventoryType
 import org.openecomp.mso.bpmn.core.domain.Resource
+import org.openecomp.mso.bpmn.core.domain.ResourceType
 import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition
 import org.openecomp.mso.bpmn.core.domain.Subscriber
 import org.openecomp.mso.bpmn.core.domain.VnfResource
@@ -210,9 +211,16 @@ class OofHoming extends AbstractServiceTaskProcessor {
                     JSONObject placement = arrSol.getJSONObject(j)
                     utils.log("DEBUG", "****** JSONObject is: " + placement + " *****", "true")
                     String jsonServiceResourceId = placement.getString("serviceResourceId")
+                    String jsonResourceModuleName = placement.getString("resourceModuleName")
                     for (Resource resource : resourceList) {
                         String serviceResourceId = resource.getResourceId()
-                        if (serviceResourceId.equalsIgnoreCase(jsonServiceResourceId)) {
+                        String resourceModuleName = ""
+                        if (resource.getResourceType() == ResourceType.ALLOTTED_RESOURCE ||
+                            resource.getResourceType() == ResourceType.VNF) {
+                            resourceModuleName = resource.getNfFunction()
+                            }
+                        if (serviceResourceId.equalsIgnoreCase(jsonServiceResourceId) ||
+                            resourceModuleName.equalsIgnoreCase(jsonResourceModuleName)) {
                             JSONObject solution = placement.getJSONObject("solution")
                             String solutionType = solution.getString("identifierType")
                             String inventoryType = ""
@@ -249,9 +257,10 @@ class OofHoming extends AbstractServiceTaskProcessor {
                                     flavorsArrayList.add(cloudFlavor)
                                 }
                             }
-                            Map<String, String> assignmentMap = jsonUtil.entryArrayToMap(execution, assignmentArr.toString(), "key", "value")
+                            Map<String, String> assignmentMap = jsonUtil.entryArrayToMap(execution,
+                                    assignmentArr.toString(), "key", "value")
                             String cloudOwner = assignmentMap.get("cloudOwner")
-                            String cloudRegionId = assignmentMap.get("cloudRegionId")
+                            String cloudRegionId = assignmentMap.get("locationId")
                             resource.getHomingSolution().setCloudOwner(cloudOwner)
                             resource.getHomingSolution().setCloudRegionId(cloudRegionId)
                             if (flavorsArrayList != null && flavorsArrayList.size != 0) {
index 8087238..53cd70c 100644 (file)
@@ -54,7 +54,7 @@
                         "value": "False"
                     },
                     {
-                        "key": "cloudRegionId",
+                        "key": "locationId",
                         "value": "dfwtx"
                     }
                 ]
@@ -79,7 +79,7 @@
                         "value": "False"
                     },
                     {
-                        "key": "cloudRegionId",
+                        "key": "locationId",
                         "value": "testCloudRegionId2"
                     }
                 ]
                             "value": "aic"
                         },
                         {
-                            "key": "cloudRegionId",
+                            "key": "locationId",
                             "value": "testCloudRegionId3"
                         },
                         {   "key":"flavors",
index 8766df8..d955877 100644 (file)
@@ -55,7 +55,7 @@
                     { "key": "cloudOwner", "value": "aic" },
                     { "key": "vnfHostName", "value": "MDTNJ01" },
                     { "key": "isRehome", "value": "False" },
-                    { "key": "cloudRegionId", "value": "dfwtx" }
+                    { "key": "locationId", "value": "dfwtx" }
                 ]
             },
             {
@@ -69,7 +69,7 @@
                     { "key": "cloudOwner", "value": "aic" },
                     { "key": "vnfHostName", "value": "testVnfHostname2" },
                     { "key": "isRehome", "value": "False" },
-                    { "key": "cloudRegionId", "value": "testCloudRegionId2" }
+                    { "key": "locationId", "value": "testCloudRegionId2" }
                 ]
             },
             {
@@ -83,7 +83,7 @@
                     { "key": "cloudOwner", "value": "aic" },
                     { "key": "vnfHostName", "value": "testVnfHostNameNet" },
                     { "key": "isRehome", "value": "False" },
-                    { "key": "cloudRegionId", "value": "testCloudRegionIdNet" }
+                    { "key": "locationId", "value": "testCloudRegionIdNet" }
                 ]
             },
             {
@@ -96,7 +96,7 @@
                 },
                 "assignmentInfo": [
                     { "key": "cloudOwner", "value": "aic" },
-                    { "key": "cloudRegionId", "value": "testCloudRegionIdNet2" }
+                    { "key": "locationId", "value": "testCloudRegionIdNet2" }
                 ]
             },
             {
                 },
                 "assignmentInfo": [
                     { "key": "cloudOwner", "value": "aic" },
-                    { "key": "cloudRegionId", "value": "testCloudRegionId3" },
+                    { "key": "locationId", "value": "testCloudRegionId3" },
                     { "key":"flavors", "value":{ "flavorLabel1xxx":"vimFlavorxxx", "flavorLabel2xxx":"vimFlavorxxx"}}
                 ]
             }
index 8e6f2d4..15e601b 100644 (file)
@@ -17,7 +17,7 @@
                { "key": "cloudOwner", "value": "amazon" },
                { "key": "vnfHostName", "value": "ahr344gh" },
                { "key": "isRehome", "value": "False" },
-               { "key": "cloudRegionId", "value": "1ac71fb8-ad43-4e16-9459-c3f372b8236d" }
+               { "key": "locationId", "value": "1ac71fb8-ad43-4e16-9459-c3f372b8236d" }
             ]
          },
          {
@@ -30,7 +30,7 @@
             },
             "assignmentInfo": [
                { "key": "cloudOwner", "value": "amazon" },
-               { "key": "cloudRegionId", "value": "1ac71fb8-ad43-4e16-9459-c3f372b8236d" },
+               { "key": "locationId", "value": "1ac71fb8-ad43-4e16-9459-c3f372b8236d" },
                { "key":"flavors", "value":{ "flavorLabel1xxx":"vimFlavorxxx", "flavorLabel2xxx":"vimFlavorxxx"}}
             ]
          }
index 09026d1..8894316 100644 (file)
@@ -37,7 +37,7 @@
             },
             "nfRole": "",
             "nfType": "",
-            "nfFunction": "",
+            "nfFunction": "ADIoDvCE",
             "nfNamingCode": "",
             "multiStageDesign": "N"
         }