From 6af3bff51edbde8e84262c4ec32aaa09527b7211 Mon Sep 17 00:00:00 2001
From: "prakash.e" <prakash.e@huawei.com>
Date: Tue, 23 Apr 2019 14:31:15 +0530
Subject: SDWAN vpn-site-resource DG- failure cases handled

To activate vnf-resource, order status should be Created.
Fixed by Adding validity check with order-status is Created.

Change-Id: I489ac4bad2af05d8b34922a70c49ed970e934370
Issue-ID: SDNC-659
Signed-off-by: Prakash.E <prakash.e@huawei.com>

Former-commit-id: 0872665a543775469b1c7cf851fef6728529e12f
---
 ...ology-operation-vpn-site-resource-activate.json | 277 +++++++++++++--------
 ...pology-operation-vpn-site-resource-activate.xml |  13 +-
 2 files changed, 188 insertions(+), 102 deletions(-)

(limited to 'platform-logic')

diff --git a/platform-logic/generic-resource-api/src/main/json/sdwan/GENERIC-RESOURCE-API_vnf-topology-operation-vpn-site-resource-activate.json b/platform-logic/generic-resource-api/src/main/json/sdwan/GENERIC-RESOURCE-API_vnf-topology-operation-vpn-site-resource-activate.json
index 244799a1..c85d68f8 100644
--- a/platform-logic/generic-resource-api/src/main/json/sdwan/GENERIC-RESOURCE-API_vnf-topology-operation-vpn-site-resource-activate.json
+++ b/platform-logic/generic-resource-api/src/main/json/sdwan/GENERIC-RESOURCE-API_vnf-topology-operation-vpn-site-resource-activate.json
@@ -1,36 +1,36 @@
 [
     {
-        "id": "294747fd.2c2d98",
+        "id": "951a58ad.b622b8",
         "type": "method",
         "name": "method vnf-topology-operation-vpn-site-resource-activate",
         "xml": "<method rpc='vnf-topology-operation-vpn-site-resource-activate' mode='sync'>\n",
         "comments": "",
         "outputs": 1,
-        "x": 211.5,
-        "y": 201.99997901916504,
-        "z": "79a5b197.5d84",
+        "x": 274.00390625,
+        "y": 217.9999771118164,
+        "z": "e44dd5e7.6a1128",
         "wires": [
             [
-                "4068c2f3.520fdc"
+                "9f312de.ebe59d"
             ]
         ]
     },
     {
-        "id": "cff9203f.6e7f7",
+        "id": "ce93efc.702d31",
         "type": "dgstart",
         "name": "DGSTART",
         "outputs": 1,
-        "x": 89.0713882446289,
-        "y": 38,
-        "z": "79a5b197.5d84",
+        "x": 151.5752944946289,
+        "y": 53.99999809265137,
+        "z": "e44dd5e7.6a1128",
         "wires": [
             [
-                "78d3821a.ddc91c"
+                "6be0f3e4.bbd19c"
             ]
         ]
     },
     {
-        "id": "78d3821a.ddc91c",
+        "id": "6be0f3e4.bbd19c",
         "type": "service-logic",
         "name": "GENERIC-RESOURCE-API ${project.version}",
         "module": "GENERIC-RESOURCE-API",
@@ -38,261 +38,336 @@
         "comments": "",
         "xml": "<service-logic xmlns='http://www.onap.org/sdnc/svclogic' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='GENERIC-RESOURCE-API' version='${project.version}'>",
         "outputs": 1,
-        "x": 188.35708618164062,
-        "y": 112.23810789268464,
-        "z": "79a5b197.5d84",
+        "x": 250.86099243164062,
+        "y": 128.238105985336,
+        "z": "e44dd5e7.6a1128",
         "wires": [
             [
-                "294747fd.2c2d98"
+                "951a58ad.b622b8"
             ]
         ]
     },
     {
-        "id": "4068c2f3.520fdc",
+        "id": "9f312de.ebe59d",
         "type": "block",
         "name": "block : atomic",
         "xml": "<block atomic=\"true\">",
         "atomic": "true",
         "outputs": 1,
-        "x": 189.73804473876953,
-        "y": 373.66666814964265,
-        "z": "79a5b197.5d84",
+        "x": 252.24195098876953,
+        "y": 389.666666242294,
+        "z": "e44dd5e7.6a1128",
         "wires": [
             [
-                "3a6b0423.a0a0ac",
-                "d7b531c1.f5a86",
-                "29c1d8e.17e3128",
-                "206b62f4.ff1b8e",
-                "ac1ddf15.75241",
-                "fd35c3d4.a8e8a"
+                "94324bec.af0568",
+                "9e7bd407.d70c08",
+                "240a825d.6226de",
+                "c7c4dafb.a3de48",
+                "af4009d1.a698c8",
+                "db202f3e.dab93",
+                "5b908f22.f7f5a"
             ]
         ]
     },
     {
-        "id": "3a6b0423.a0a0ac",
+        "id": "94324bec.af0568",
         "type": "set",
         "name": "set vnf-level-oper-status to Active",
         "xml": "<set>\n<parameter name='service-data.vnfs.vnf[$tmp.vidx].vnf-data.vnf-level-oper-status.order-status' value='Active' />\n<parameter name='service-data.vnfs.vnf[$tmp.vidx].vnf-data.vnf-level-oper-status.last-rpc-action' value='`$vnf-topology-operation-input.sdnc-request-header.svc-action`' />\n<parameter name='service-data.vnfs.vnf[$tmp.vidx].vnf-data.vnf-level-oper-status.last-action' value='`$vnf-topology-operation-input.request-information.request-action`' />",
         "comments": "",
-        "x": 598.8850250244141,
-        "y": 446.67056941986084,
-        "z": "79a5b197.5d84",
+        "x": 667.3889236450195,
+        "y": 576.6705493927002,
+        "z": "e44dd5e7.6a1128",
         "wires": []
     },
     {
-        "id": "d7b531c1.f5a86",
+        "id": "9e7bd407.d70c08",
         "type": "returnSuccess",
         "name": "return success",
         "xml": "<return status='success'>\n<parameter name=\"ack-final-indicator\" value=\"Y\" />\n<parameter name=\"error-code\" value=\"200\" />\n<parameter name=\"error-message\" value=\"`$error-message`\" />\n",
         "comments": "",
-        "x": 519.0717163085938,
-        "y": 572.5971069335938,
-        "z": "79a5b197.5d84",
+        "x": 587.5756149291992,
+        "y": 702.5970869064331,
+        "z": "e44dd5e7.6a1128",
         "wires": []
     },
     {
-        "id": "29c1d8e.17e3128",
+        "id": "240a825d.6226de",
         "type": "set",
         "name": "set vnf-index and vnf-object-path",
         "xml": "<set>\n<parameter name='vnfId' value='`$vnf-topology-operation-input.vnf-information.vnf-id`' />\n<parameter name=\"vnf-object-path\" value=\"`'restconf/config/GENERIC-RESOURCE-API:services/service/'  + $vnf-topology-operation-input.service-information.service-instance-id  + '/service-data/vnfs/vnf/'  + $vnf-topology-operation-input.vnf-information.vnf-id  + '/vnf-data/'` \" />",
         "comments": "",
-        "x": 605.0716705322266,
-        "y": 394.5968236923218,
-        "z": "79a5b197.5d84",
+        "x": 673.575569152832,
+        "y": 524.5968036651611,
+        "z": "e44dd5e7.6a1128",
         "wires": []
     },
     {
-        "id": "206b62f4.ff1b8e",
+        "id": "c7c4dafb.a3de48",
         "type": "switchNode",
         "name": "switch service-data.vnfs.vnf_length",
         "xml": "<switch test='`$service-data.vnfs.vnf_length`'>\n",
         "comments": "",
         "outputs": 1,
-        "x": 619.5000610351562,
-        "y": 263.00000545661896,
-        "z": "79a5b197.5d84",
+        "x": 682.0039672851562,
+        "y": 279.00000354927033,
+        "z": "e44dd5e7.6a1128",
         "wires": [
             [
-                "510e4a8b.ead204",
-                "c779a013.c610f",
-                "7ee910c1.660bf"
+                "f4d8522c.a4d9b",
+                "2bef8938.25fbd6",
+                "4701274a.571b48"
             ]
         ]
     },
     {
-        "id": "7ee910c1.660bf",
+        "id": "4701274a.571b48",
         "type": "outcome",
         "name": "0",
         "xml": "<outcome value='0'>\n",
         "comments": "",
         "outputs": 1,
-        "x": 878.4689559936523,
-        "y": 224.96876499336213,
-        "z": "79a5b197.5d84",
+        "x": 940.9728622436523,
+        "y": 240.9687630860135,
+        "z": "e44dd5e7.6a1128",
         "wires": [
             [
-                "a7558172.b2121"
+                "fd0fb6fb.9706b8"
             ]
         ]
     },
     {
-        "id": "a7558172.b2121",
+        "id": "fd0fb6fb.9706b8",
         "type": "returnFailure",
         "name": "return failure",
         "xml": "<return status='failure'>\n\t<parameter name='ack-final' value='Y'/>\n\t<parameter name=\"error-code\" value=\"500\" />\n    <parameter name=\"error-message\" value=\"vnf-topology-operation-input.vnf-request-input.vnf-id not found in service-data\" />\n",
         "comments": "",
-        "x": 1033.2778434753418,
-        "y": 243.88903352897614,
-        "z": "79a5b197.5d84",
+        "x": 1095.7817497253418,
+        "y": 259.8890316216275,
+        "z": "e44dd5e7.6a1128",
         "wires": []
     },
     {
-        "id": "510e4a8b.ead204",
+        "id": "f4d8522c.a4d9b",
         "type": "other",
         "name": "Null",
         "xml": "<outcome value=''>\n",
         "comments": "",
         "outputs": 1,
-        "x": 871.5000953674316,
-        "y": 264.00008651893586,
-        "z": "79a5b197.5d84",
+        "x": 934.0040016174316,
+        "y": 280.0000846115872,
+        "z": "e44dd5e7.6a1128",
         "wires": [
             [
-                "a7558172.b2121"
+                "fd0fb6fb.9706b8"
             ]
         ]
     },
     {
-        "id": "c779a013.c610f",
+        "id": "2bef8938.25fbd6",
         "type": "other",
         "name": "other",
         "xml": "<outcome value='Other'>\n",
         "comments": "",
         "outputs": 1,
-        "x": 864.5005035400391,
-        "y": 297.0000903336331,
-        "z": "79a5b197.5d84",
+        "x": 927.0044097900391,
+        "y": 313.0000884262845,
+        "z": "e44dd5e7.6a1128",
         "wires": [
             [
-                "6aaa180d.7575b8"
+                "f298ba1.2d54c48"
             ]
         ]
     },
     {
-        "id": "6aaa180d.7575b8",
+        "id": "f298ba1.2d54c48",
         "type": "block",
         "name": "block : atomic",
         "xml": "<block atomic=\"true\">",
         "atomic": "true",
         "outputs": 1,
-        "x": 1011.7700462341309,
-        "y": 297.55473539512604,
-        "z": "79a5b197.5d84",
+        "x": 1074.2739524841309,
+        "y": 313.5547334877774,
+        "z": "e44dd5e7.6a1128",
         "wires": [
             [
-                "46580136.d7c0b"
+                "5f9416f7.4477e8"
             ]
         ]
     },
     {
-        "id": "46580136.d7c0b",
+        "id": "5f9416f7.4477e8",
         "type": "for",
         "name": "for vidx..service-data.vnfs.vnf_length[]",
         "xml": "<for index='vidx' start='0' end='`$service-data.vnfs.vnf_length`' >\n",
         "comments": "",
         "outputs": 1,
-        "x": 1257.7861633300781,
-        "y": 304.4286558357999,
-        "z": "79a5b197.5d84",
+        "x": 1320.2900695800781,
+        "y": 320.42865392845124,
+        "z": "e44dd5e7.6a1128",
         "wires": [
             [
-                "a66fcd87.a077a"
+                "d1140903.826428"
             ]
         ]
     },
     {
-        "id": "a66fcd87.a077a",
+        "id": "d1140903.826428",
         "type": "block",
         "name": "block",
         "xml": "<block>\n",
         "atomic": "false",
         "comments": "",
         "outputs": 1,
-        "x": 1477.1357955932617,
-        "y": 303.9687359062955,
-        "z": "79a5b197.5d84",
+        "x": 1539.6397018432617,
+        "y": 319.96873399894685,
+        "z": "e44dd5e7.6a1128",
         "wires": [
             [
-                "ba7c0ee7.d144d"
+                "634303dc.2373ac"
             ]
         ]
     },
     {
-        "id": "ba7c0ee7.d144d",
+        "id": "634303dc.2373ac",
         "type": "switchNode",
         "name": "switch vnfid found",
         "xml": "<switch test=\"`$service-data.vnfs.vnf[$vidx].vnf-id == $vnf-topology-operation-input.vnf-information.vnf-id`\">\n\n",
         "comments": "",
         "outputs": 1,
-        "x": 1631.2153930664062,
-        "y": 303.67881796043366,
-        "z": "79a5b197.5d84",
+        "x": 1693.7192993164062,
+        "y": 319.67881605308503,
+        "z": "e44dd5e7.6a1128",
         "wires": [
             [
-                "a9157f30.c0f4f"
+                "acd02e3d.622b7"
             ]
         ]
     },
     {
-        "id": "a9157f30.c0f4f",
+        "id": "acd02e3d.622b7",
         "type": "outcomeTrue",
         "name": "true",
         "xml": "<outcome value='true'>\n",
         "comments": "",
         "outputs": 1,
-        "x": 1807.1675148010254,
-        "y": 303.57150003593415,
-        "z": "79a5b197.5d84",
+        "x": 1869.6714210510254,
+        "y": 319.5714981285855,
+        "z": "e44dd5e7.6a1128",
         "wires": [
             [
-                "e051341c.b94158"
+                "eb3ae849.6809a8"
             ]
         ]
     },
     {
-        "id": "e051341c.b94158",
+        "id": "eb3ae849.6809a8",
         "type": "set",
         "name": "set tmp.vidx and ctx.vnf-data",
         "xml": "<set>\n<parameter name='tmp.vidx' value='`$vidx`' />\n<parameter name='ctx.vnf-data.' value='`$service-data.vnfs.vnf[$vidx].`' />\n",
         "comments": "",
-        "x": 2016.6998901367188,
-        "y": 305.3216001717374,
-        "z": "79a5b197.5d84",
+        "x": 2079.2037963867188,
+        "y": 321.32159826438874,
+        "z": "e44dd5e7.6a1128",
         "wires": []
     },
     {
-        "id": "ac1ddf15.75241",
+        "id": "af4009d1.a698c8",
         "type": "save",
         "name": "update AnAI - vnf-instance.orchestration-status",
         "xml": "<update plugin=\"org.onap.ccsdk.sli.adaptors.aai.AAIService\" \n\tresource=\"generic-vnf\"   \n\t\tkey=\"generic-vnf.vnf-id = $vnfId\" >\n<parameter name=\"orchestration-status\" value=\"Active\" />\n<parameter name=\"vnf-type\" value=\"some vnf-type\" />",
         "comments": "",
         "outputs": 1,
-        "x": 624.5000305175781,
-        "y": 513.0103950500488,
-        "z": "79a5b197.5d84",
+        "x": 693.0039291381836,
+        "y": 643.0103750228882,
+        "z": "e44dd5e7.6a1128",
         "wires": [
             []
         ]
     },
     {
-        "id": "fd35c3d4.a8e8a",
+        "id": "db202f3e.dab93",
         "type": "set",
         "name": "copy input data to service data",
-        "xml": "<set>\n<!--parameter name='service-data.vnfs.vnf[$tmp.vidx].vnf-id' value='`$vnf-topology-operation-input.vnf-information.vnf-id`' /-->\n<parameter name='service-data.vnfs.vnf[$tmp.vidx].vnf-data.sdnc-request-header.' value='$vnf-topology-operation-input.sdnc-request-header.' />\n<parameter name='service-data.vnfs.vnf[$tmp.vidx].vnf-data.request-information.' value='$vnf-topology-operation-input.request-information.' />\n<parameter name='service-data.vnfs.vnf[$tmp.vidx].vnf-data.service-information.' value='$vnf-topology-operation-input.service-information.' />",
+        "xml": "<set>\n<parameter name='service-data.vnfs.vnf[$tmp.vidx].vnf-data.sdnc-request-header.' value='$vnf-topology-operation-input.sdnc-request-header.' />\n<parameter name='service-data.vnfs.vnf[$tmp.vidx].vnf-data.request-information.' value='$vnf-topology-operation-input.request-information.' />\n<parameter name='service-data.vnfs.vnf[$tmp.vidx].vnf-data.service-information.' value='$vnf-topology-operation-input.service-information.' />",
         "comments": "",
-        "x": 603.5001449584961,
-        "y": 344.010356426239,
-        "z": "79a5b197.5d84",
+        "x": 672.0040435791016,
+        "y": 474.01033639907837,
+        "z": "e44dd5e7.6a1128",
         "wires": []
+    },
+    {
+        "id": "5b908f22.f7f5a",
+        "type": "switchNode",
+        "name": "switch vnf-level-oper-status",
+        "xml": "<switch test='`$service-data.vnfs.vnf[$tmp.vidx].vnf-data.vnf-level-oper-status.order-status`'>\n",
+        "comments": "",
+        "outputs": 1,
+        "x": 658.75390625,
+        "y": 379.00390625,
+        "z": "e44dd5e7.6a1128",
+        "wires": [
+            [
+                "5ccb4fe0.99339",
+                "814ec70c.a8b9c8"
+            ]
+        ]
+    },
+    {
+        "id": "5ccb4fe0.99339",
+        "type": "outcome",
+        "name": "outcome Created",
+        "xml": "<outcome value='Created'>\n",
+        "comments": "",
+        "outputs": 1,
+        "x": 904.5872001647949,
+        "y": 380.1150040626526,
+        "z": "e44dd5e7.6a1128",
+        "wires": [
+            [
+                "e3b020d0.17a88"
+            ]
+        ]
+    },
+    {
+        "id": "814ec70c.a8b9c8",
+        "type": "other",
+        "name": "other",
+        "xml": "<outcome value='Other'>\n",
+        "comments": "",
+        "outputs": 1,
+        "x": 882.5872192382812,
+        "y": 430.1150155067444,
+        "z": "e44dd5e7.6a1128",
+        "wires": [
+            [
+                "50309b2.08dbf64"
+            ]
+        ]
+    },
+    {
+        "id": "50309b2.08dbf64",
+        "type": "returnFailure",
+        "name": "return failure",
+        "xml": "<return status='failure'>\n\t<parameter name='ack-final' value='Y'/>\n\t<parameter name=\"error-code\" value=\"500\" />\n    <parameter name=\"error-message\" value=\"`'VNF is not in appropriate state for activate. Current state is ' + $service-data.vnfs.vnf[$tmp.nidx].vnf-data.vnf-level-oper-status.order-status`\" />",
+        "comments": "",
+        "x": 1042.086986541748,
+        "y": 433.11501455307007,
+        "z": "e44dd5e7.6a1128",
+        "wires": []
+    },
+    {
+        "id": "e3b020d0.17a88",
+        "type": "block",
+        "name": "block : atomic",
+        "xml": "<block atomic=\"true\">",
+        "atomic": "true",
+        "outputs": 1,
+        "x": 1114.8935737609863,
+        "y": 391.44017934799194,
+        "z": "e44dd5e7.6a1128",
+        "wires": [
+            []
+        ]
     }
 ]
\ No newline at end of file
diff --git a/platform-logic/generic-resource-api/src/main/xml/sdwan/GENERIC-RESOURCE-API_vnf-topology-operation-vpn-site-resource-activate.xml b/platform-logic/generic-resource-api/src/main/xml/sdwan/GENERIC-RESOURCE-API_vnf-topology-operation-vpn-site-resource-activate.xml
index 32fa9b27..86099f33 100644
--- a/platform-logic/generic-resource-api/src/main/xml/sdwan/GENERIC-RESOURCE-API_vnf-topology-operation-vpn-site-resource-activate.xml
+++ b/platform-logic/generic-resource-api/src/main/xml/sdwan/GENERIC-RESOURCE-API_vnf-topology-operation-vpn-site-resource-activate.xml
@@ -35,8 +35,19 @@
                     </block>
                 </outcome>
             </switch>
+            <switch test='`$service-data.vnfs.vnf[$tmp.vidx].vnf-data.vnf-level-oper-status.order-status`'>
+                <outcome value='Created'>
+                    <block atomic="true"></block>
+                </outcome>
+                <outcome value='Other'>
+                    <return status='failure'>
+                        <parameter name='ack-final' value='Y'/>
+                        <parameter name="error-code" value="500" />
+                        <parameter name="error-message" value="`'VNF is not in appropriate state for activate. Current state is ' + $service-data.vnfs.vnf[$tmp.nidx].vnf-data.vnf-level-oper-status.order-status`" />
+                    </return>
+                </outcome>
+            </switch>
             <set>
-                <!--parameter name='service-data.vnfs.vnf[$tmp.vidx].vnf-id' value='`$vnf-topology-operation-input.vnf-information.vnf-id`' /-->
                 <parameter name='service-data.vnfs.vnf[$tmp.vidx].vnf-data.sdnc-request-header.' value='$vnf-topology-operation-input.sdnc-request-header.' />
                 <parameter name='service-data.vnfs.vnf[$tmp.vidx].vnf-data.request-information.' value='$vnf-topology-operation-input.request-information.' />
                 <parameter name='service-data.vnfs.vnf[$tmp.vidx].vnf-data.service-information.' value='$vnf-topology-operation-input.service-information.' />
-- 
cgit 1.2.3-korg