diff options
author | Konrad Bańka <k.banka@samsung.com> | 2020-02-28 11:21:22 +0100 |
---|---|---|
committer | Bartek Grzybowski <b.grzybowski@partner.samsung.com> | 2020-03-05 11:45:48 +0000 |
commit | 367417cd7957916dffffef5d85e7cca304367c53 (patch) | |
tree | c5160adac89330ab0529d2fa3a9b88f63c21051e /heat/vFW_CNF_CDS | |
parent | 3c887a297e506f393df2a56e748fc398bcbc4b1a (diff) |
Provide custom naming policy for vFW CNF usecase
Issue-ID: INT-1457
Signed-off-by: Konrad Bańka <k.banka@samsung.com>
Change-Id: I9a5bc4ba6296800005bd0ed5cbc6c79b1064bdcd
Diffstat (limited to 'heat/vFW_CNF_CDS')
-rw-r--r-- | heat/vFW_CNF_CDS/templates/cba/Templates/vnf-mapping.json | 2 | ||||
-rw-r--r-- | heat/vFW_CNF_CDS/templates/policy/README.txt | 13 | ||||
-rw-r--r-- | heat/vFW_CNF_CDS/templates/policy/create.json | 11 | ||||
-rw-r--r-- | heat/vFW_CNF_CDS/templates/policy/get.json | 3 | ||||
-rwxr-xr-x | heat/vFW_CNF_CDS/templates/policy/policy.sh | 51 | ||||
-rw-r--r-- | heat/vFW_CNF_CDS/templates/policy/push.json | 5 |
6 files changed, 84 insertions, 1 deletions
diff --git a/heat/vFW_CNF_CDS/templates/cba/Templates/vnf-mapping.json b/heat/vFW_CNF_CDS/templates/cba/Templates/vnf-mapping.json index e0728241..4dfdaff4 100644 --- a/heat/vFW_CNF_CDS/templates/cba/Templates/vnf-mapping.json +++ b/heat/vFW_CNF_CDS/templates/cba/Templates/vnf-mapping.json @@ -365,7 +365,7 @@ "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", diff --git a/heat/vFW_CNF_CDS/templates/policy/README.txt b/heat/vFW_CNF_CDS/templates/policy/README.txt new file mode 100644 index 00000000..afb30f7c --- /dev/null +++ b/heat/vFW_CNF_CDS/templates/policy/README.txt @@ -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 index 00000000..2443d550 --- /dev/null +++ b/heat/vFW_CNF_CDS/templates/policy/create.json @@ -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 index 00000000..b9a6281e --- /dev/null +++ b/heat/vFW_CNF_CDS/templates/policy/get.json @@ -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 index 00000000..a09ab0a8 --- /dev/null +++ b/heat/vFW_CNF_CDS/templates/policy/policy.sh @@ -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 index 00000000..9a8f9ae2 --- /dev/null +++ b/heat/vFW_CNF_CDS/templates/policy/push.json @@ -0,0 +1,5 @@ +{ + "pdpGroup": "default", + "policyName": "SDNC_Policy.ONAP_CNF_NAMING_TIMESTAMP", + "policyType": "MicroService" +} |