Provide custom naming policy for vFW CNF usecase 46/102946/3
authorKonrad Bańka <k.banka@samsung.com>
Fri, 28 Feb 2020 10:21:22 +0000 (11:21 +0100)
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>
Thu, 5 Mar 2020 11:45:48 +0000 (11:45 +0000)
Issue-ID: INT-1457
Signed-off-by: Konrad Bańka <k.banka@samsung.com>
Change-Id: I9a5bc4ba6296800005bd0ed5cbc6c79b1064bdcd

heat/vFW_CNF_CDS/templates/cba/Templates/vnf-mapping.json
heat/vFW_CNF_CDS/templates/policy/README.txt [new file with mode: 0644]
heat/vFW_CNF_CDS/templates/policy/create.json [new file with mode: 0644]
heat/vFW_CNF_CDS/templates/policy/get.json [new file with mode: 0644]
heat/vFW_CNF_CDS/templates/policy/policy.sh [new file with mode: 0755]
heat/vFW_CNF_CDS/templates/policy/push.json [new file with mode: 0644]

index e072824..4dfdaff 100644 (file)
       "entry_schema": {
         "type": ""
       },
       "entry_schema": {
         "type": ""
       },
-      "default": "SDNC_Policy.Config_MS_ONAP_VNF_NAMING_TIMESTAMP"
+      "default": "SDNC_Policy.Config_MS_ONAP_CNF_NAMING_TIMESTAMP"
     },
     "input-param": false,
     "dictionary-name": "vf-naming-policy",
     },
     "input-param": false,
     "dictionary-name": "vf-naming-policy",
diff --git a/heat/vFW_CNF_CDS/templates/policy/README.txt b/heat/vFW_CNF_CDS/templates/policy/README.txt
new file mode 100644 (file)
index 0000000..afb30f7
--- /dev/null
@@ -0,0 +1,13 @@
+`policy.sh` script allows to create and push naming policy for CNF usecase. Execution of script can be checked by calling `./policy.sh -h`. As pdp doesn't expose it's service externally, this folder needs to be copied to some ONAP pod with bash and curl available (for example, mariadb-galera) and executed within.
+Scope of changes and reasoning behind is described in related ticket: https://jira.onap.org/browse/SDNC-1109.
+
+Example execution flow:
+```
+cd ..
+kubectl cp policy onap-mariadb-galera-mariadb-galera-0:/tmp/policy
+kubectl exec -it onap-mariadb-galera-mariadb-galera-0 bash
+cd /tmp/policy
+./policy.sh get #See that CNF naming policy is not uploaded yet
+./policy.sh create #Create and push CNF naming policy
+./policy.sh get #Verify that now it's visible
+```
diff --git a/heat/vFW_CNF_CDS/templates/policy/create.json b/heat/vFW_CNF_CDS/templates/policy/create.json
new file mode 100644 (file)
index 0000000..2443d55
--- /dev/null
@@ -0,0 +1,11 @@
+{
+    "configBody": "{ \"content\": { \"naming-models\": [ { \"naming-properties\": [ { \"property-name\": \"AIC_CLOUD_REGION\" }, { \"property-name\": \"CONSTANT\", \"property-value\": \"onap-nf\" }, { \"increment-sequence\": { \"increment\": \"1\", \"length\": \"3\", \"max\": \"zzz\", \"scope\": \"ENTIRETY\", \"sequence-type\": \"alpha-numeric\", \"start-value\": \"001\" }, \"property-name\": \"SEQUENCE\" }, { \"property-name\": \"DELIMITER\", \"property-value\": \"-\" } ], \"naming-recipe\": \"AIC_CLOUD_REGION|DELIMITER|CONSTANT|DELIMITER|SEQUENCE\", \"naming-type\": \"VNF\" }, { \"naming-properties\": [ { \"property-name\": \"VNF_NAME\" }, { \"increment-sequence\": { \"increment\": \"1\", \"length\": \"3\", \"max\": \"zzz\", \"scope\": \"ENTIRETY\", \"sequence-type\": \"alpha-numeric\", \"start-value\": \"001\" }, \"property-name\": \"SEQUENCE\" }, { \"property-name\": \"NFC_NAMING_CODE\" }, { \"property-name\": \"DELIMITER\", \"property-value\": \"-\" } ], \"naming-recipe\": \"VNF_NAME|DELIMITER|NFC_NAMING_CODE|DELIMITER|SEQUENCE\", \"naming-type\": \"VNFC\" }, { \"naming-properties\": [ { \"property-name\": \"VNF_NAME\" }, { \"property-name\": \"DELIMITER\", \"property-value\": \"-\" }, { \"property-name\": \"VF_MODULE_LABEL\" }, { \"increment-sequence\": { \"increment\": \"1\", \"length\": \"3\", \"max\": \"zzz\", \"scope\": \"PRECEEDING\", \"sequence-type\": \"alpha-numeric\", \"start-value\": \"01\" }, \"property-name\": \"SEQUENCE\" } ], \"naming-recipe\": \"VNF_NAME|DELIMITER|VF_MODULE_LABEL|DELIMITER|SEQUENCE\", \"naming-type\": \"VF-MODULE\" } ], \"policy-instance-name\": \"ONAP_VNF_NAMING_TIMESTAMP\" }, \"service\": \"SDNC-GenerateName\", \"version\": \"CSIT\" }",
+    "description": "ONAP_CNF_NAMING_TIMESTAMP",
+    "guard": "false",
+    "onapName": "SDNC",
+    "policyConfigType": "MicroService",
+    "policyName": "SDNC_Policy.ONAP_CNF_NAMING_TIMESTAMP",
+    "priority": "4",
+    "riskLevel": "4",
+    "riskType": "test"
+}
diff --git a/heat/vFW_CNF_CDS/templates/policy/get.json b/heat/vFW_CNF_CDS/templates/policy/get.json
new file mode 100644 (file)
index 0000000..b9a6281
--- /dev/null
@@ -0,0 +1,3 @@
+{
+    "policyName": "SDNC_Policy.Config_MS_ONAP_CNF_NAMING_TIMESTAMP.*.xml"
+}
diff --git a/heat/vFW_CNF_CDS/templates/policy/policy.sh b/heat/vFW_CNF_CDS/templates/policy/policy.sh
new file mode 100755 (executable)
index 0000000..a09ab0a
--- /dev/null
@@ -0,0 +1,51 @@
+#!/bin/bash
+
+set -e
+
+check(){
+    if ! which curl >/dev/null 2>&1; then
+        echo "Fatal error, curl command not available" >&2
+        return 1
+    fi
+
+    for arg; do
+        if ! test -f "$arg"; then
+            echo "Fatal error, REST payload - $arg - not found in current directory" >&2
+            return 1
+        fi
+    done
+}
+
+query_policy(){
+    local mode="$1"
+    local content="$2"
+    local url="$3"
+
+    declare -a flags=(-kf -H 'Content-Type: application/json'
+                      -H 'ClientAuth: cHl0aG9uOnRlc3Q=' -u testpdp:alpha123
+                      -H 'Environment: TEST')
+
+    check "$content"
+
+    curl -X "$mode" -d @"$content" "${flags[@]}" "${PDP_URL:-https://pdp:8081}/$url"
+}
+
+case "$1" in
+    -h|--help|help|?|"")
+        echo "Script usage:"
+        echo "$0 get|verify - query policy for CNF policy"
+        echo "$0 create - Create CNF naming policy and push it"
+        echo "$0 update - Update CNF naming policy and push it"
+        ;;
+    get|verify)
+        query_policy POST get.json pdp/api/getConfig
+        ;;
+    create|update)
+        query_policy PUT create.json "pdp/api/$1Policy"
+        query_policy PUT push.json "pdp/api/pushPolicy"
+        ;;
+    *)
+        echo "Wrong usage, check '$0 -h'" >&2
+        exit 1
+        ;;
+esac
diff --git a/heat/vFW_CNF_CDS/templates/policy/push.json b/heat/vFW_CNF_CDS/templates/policy/push.json
new file mode 100644 (file)
index 0000000..9a8f9ae
--- /dev/null
@@ -0,0 +1,5 @@
+{
+    "pdpGroup": "default",
+    "policyName": "SDNC_Policy.ONAP_CNF_NAMING_TIMESTAMP",
+    "policyType": "MicroService"
+}