From 3a3e9fcdd1141928473b5f793e224204eafe8f1b Mon Sep 17 00:00:00 2001 From: Lukasz Rajewski Date: Fri, 9 Oct 2020 20:59:32 +0200 Subject: [PATCH] vFW CDS CNF CBA with native k8s profile upload vFW CDS CNF CBA with native k8s profile upload Change-Id: Ic3357982af534ea261d4d617e050dc33bc339645 Issue-ID: INT-1658 Signed-off-by: Lukasz Rajewski --- heat/vFW_CNF_CDS/templates/Makefile | 2 +- heat/vFW_CNF_CDS/templates/cba-dev/build.sh | 39 +++ heat/vFW_CNF_CDS/templates/cba-dev/deploy.sh | 22 ++ .../templates/cba-dev/run-vf-base-ra.sh | 65 ++++ .../vFW_CNF_CDS/templates/cba-dev/run-vf-pkg-ra.sh | 67 ++++ heat/vFW_CNF_CDS/templates/cba-dev/run-vnf-ra.sh | 61 ++++ .../templates/cba/Definitions/artifact_types.json | 5 + .../templates/cba/Definitions/data_types.json | 9 +- .../templates/cba/Definitions/node_types.json | 86 ++++- .../Definitions/resources_definition_types.json | 41 ++- .../templates/cba/Definitions/vFW_CNF_CDS.json | 94 ++--- .../cba/Scripts/kotlin/KotlinK8sProfileUpload.kt | 379 --------------------- .../templates/cba/TOSCA-Metadata/TOSCA.meta | 4 +- .../cba/Templates/base_template-mapping.json | 66 +++- .../cba/Templates/base_template-template.vtl | 4 - .../vfw-cnf-cds-vpkg-profile/manifest.yaml | 7 + .../vfw-cnf-cds-vpkg-profile/override_values.yaml | 1 + .../ssh-service-mapping.json | 4 +- .../ssh-service-template.yaml.vtl} | 0 .../templates/cba/Templates/vfw-mapping.json | 66 +++- .../templates/cba/Templates/vfw-template.vtl | 4 - .../templates/cba/Templates/vnf-mapping.json | 12 - .../templates/cba/Templates/vnf-template.vtl | 8 - .../templates/cba/Templates/vpkg-mapping.json | 66 +++- .../templates/cba/Templates/vpkg-template.vtl | 4 - .../templates/cba/Templates/vsn-mapping.json | 66 +++- .../templates/cba/Templates/vsn-template.vtl | 4 - heat/vFW_CNF_CDS/templates/cba/pom.xml | 43 +++ 28 files changed, 671 insertions(+), 558 deletions(-) create mode 100755 heat/vFW_CNF_CDS/templates/cba-dev/build.sh create mode 100755 heat/vFW_CNF_CDS/templates/cba-dev/deploy.sh create mode 100755 heat/vFW_CNF_CDS/templates/cba-dev/run-vf-base-ra.sh create mode 100755 heat/vFW_CNF_CDS/templates/cba-dev/run-vf-pkg-ra.sh create mode 100755 heat/vFW_CNF_CDS/templates/cba-dev/run-vnf-ra.sh delete mode 100644 heat/vFW_CNF_CDS/templates/cba/Scripts/kotlin/KotlinK8sProfileUpload.kt create mode 100644 heat/vFW_CNF_CDS/templates/cba/Templates/k8s-profiles/vfw-cnf-cds-vpkg-profile/manifest.yaml create mode 100644 heat/vFW_CNF_CDS/templates/cba/Templates/k8s-profiles/vfw-cnf-cds-vpkg-profile/override_values.yaml rename heat/vFW_CNF_CDS/templates/cba/Templates/k8s-profiles/{ => vfw-cnf-cds-vpkg-profile}/ssh-service-mapping.json (78%) rename heat/vFW_CNF_CDS/templates/cba/Templates/k8s-profiles/{ssh-service-template.vtl => vfw-cnf-cds-vpkg-profile/ssh-service-template.yaml.vtl} (100%) create mode 100644 heat/vFW_CNF_CDS/templates/cba/pom.xml diff --git a/heat/vFW_CNF_CDS/templates/Makefile b/heat/vFW_CNF_CDS/templates/Makefile index 66dbb298..38a4b389 100644 --- a/heat/vFW_CNF_CDS/templates/Makefile +++ b/heat/vFW_CNF_CDS/templates/Makefile @@ -19,7 +19,7 @@ base: package/ cp base/* package/ cba: package/ - cd cba/ && zip -r $(CBA_NAME).zip . + cd cba/ && zip -r $(CBA_NAME).zip . -x pom.xml .idea/\* target/\* mv cba/$(CBA_NAME).zip package/ package/: diff --git a/heat/vFW_CNF_CDS/templates/cba-dev/build.sh b/heat/vFW_CNF_CDS/templates/cba-dev/build.sh new file mode 100755 index 00000000..a7a34061 --- /dev/null +++ b/heat/vFW_CNF_CDS/templates/cba-dev/build.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +# ============LICENSE_START======================================================= +# Copyright (C) 2020 Orange +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END========================================================= + +cd ../cba/ + +mvn clean install + +if [ $? -eq 1 ] +then + echo "----------------" + echo "CBA BUILD FAILED" + echo "----------------" + exit 1 +fi + +CBA_NAME=`ls target/*.zip` +cp $CBA_NAME ../cba-dev/cba.zip + +echo "-----------------" +echo "CBA BUILD SUCCESS" +echo "-----------------" + +cd ../cba-dev diff --git a/heat/vFW_CNF_CDS/templates/cba-dev/deploy.sh b/heat/vFW_CNF_CDS/templates/cba-dev/deploy.sh new file mode 100755 index 00000000..8ddbe493 --- /dev/null +++ b/heat/vFW_CNF_CDS/templates/cba-dev/deploy.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# ============LICENSE_START======================================================= +# Copyright (C) 2020 Orange +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END========================================================= + +curl --location --request POST 'http://127.0.0.1:8081/api/v1/blueprint-model/publish' \ +--header 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' \ +--form 'file=@cba.zip' | jq diff --git a/heat/vFW_CNF_CDS/templates/cba-dev/run-vf-base-ra.sh b/heat/vFW_CNF_CDS/templates/cba-dev/run-vf-base-ra.sh new file mode 100755 index 00000000..840bb859 --- /dev/null +++ b/heat/vFW_CNF_CDS/templates/cba-dev/run-vf-base-ra.sh @@ -0,0 +1,65 @@ +#!/bin/sh + +# ============LICENSE_START======================================================= +# Copyright (C) 2020 Orange +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END========================================================= + +REQ_ID=`shuf -i 1-1000000 -n 1` +SUB_REQ_ID=$REQ_ID"-"`shuf -i 1-1000 -n 1` +TEMPLATE_NAME="base_template" + +curl --location --request POST 'http://localhost:8081/api/v1/execution-service/process' \ +--header 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' \ +--header 'Content-Type: application/json' \ +--data-raw '{ + "commonHeader": { + "originatorId": "onap-me-cm-adapter", + "requestId": "'$REQ_ID'", + "subRequestId": "'$SUB_REQ_ID'" + }, + "actionIdentifiers": { + "blueprintName": "vFW_CNF_CDS", + "blueprintVersion": "7.0.0", + "actionName": "resource-assignment", + "mode": "sync" + }, + "payload": { + "resource-assignment-request": { + "template-prefix": [ + "'$TEMPLATE_NAME'" + ], + "resolution-key": "ra-test-resolution", + "resource-assignment-properties": { + "vpg-management-port": 100, + "aic-cloud-region": "RegionOne", + "vnf-model-customization-uuid": "d73864db-1f6e-4e54-a533-a96773c926a4", + "service-instance-id": "2afee7c4-8b16-4f2f-a567-48fb7948abcf", + "vnf-id": "21dcbbd2-3ec2-4a9c-bb0d-599cafc16a1f", + "vnf_name": "sample-vnf-name", + "vf-module-name": "vf-module-name", + "vf-module-label": "'$TEMPLATE_NAME'", + "vf-module-type": "vf-module-type", + "vf-module-model-customization-uuid": "d3ae2df9-95d4-48cc-a466-9f12dee80458", + "vf-module-model-invariant-uuid": "564e55dc-3b90-4c9c-9e97-42f2c97d8f11", + "vf-module-model-version": "3d55e2a6-7634-4ceb-98e9-2852d621a544", + "vf-module-id": "3e6a0375-4b92-4bf5-9910-b0b893448a9c", + "vf-naming-policy" : "SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP", + "k8s-rb-profile-name": "vfw-cnf-cds-base-profile", + "management-prefix-id" : 3 + } + } + } +}' | jq '.payload | .["resource-assignment-response"] | .["meshed-template"] | .'$TEMPLATE_NAME' | fromjson | .["resource-accumulator-resolved-data"] ' diff --git a/heat/vFW_CNF_CDS/templates/cba-dev/run-vf-pkg-ra.sh b/heat/vFW_CNF_CDS/templates/cba-dev/run-vf-pkg-ra.sh new file mode 100755 index 00000000..b7835626 --- /dev/null +++ b/heat/vFW_CNF_CDS/templates/cba-dev/run-vf-pkg-ra.sh @@ -0,0 +1,67 @@ +#!/bin/sh + +# ============LICENSE_START======================================================= +# Copyright (C) 2020 Orange +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END========================================================= + +REQ_ID=`shuf -i 1-1000000 -n 1` +SUB_REQ_ID=$REQ_ID"-"`shuf -i 1-1000 -n 1` +TEMPLATE_NAME="vpkg" + +curl --location --request POST 'http://localhost:8081/api/v1/execution-service/process' \ +--header 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' \ +--header 'Content-Type: application/json' \ +--data-raw '{ + "commonHeader": { + "originatorId": "onap-me-cm-adapter", + "requestId": "'$REQ_ID'", + "subRequestId": "'$SUB_REQ_ID'" + }, + "actionIdentifiers": { + "blueprintName": "vFW_CNF_CDS", + "blueprintVersion": "7.0.0", + "actionName": "resource-assignment", + "mode": "sync" + }, + "payload": { + "resource-assignment-request": { + "template-prefix": [ + "'$TEMPLATE_NAME'" + ], + "resolution-key": "ra-test-resolution", + "resource-assignment-properties": { + "vpg-management-port": 100, + "aic-cloud-region": "RegionOne", + "vnf-model-customization-uuid": "d73864db-1f6e-4e54-a533-a96773c926a4", + "service-instance-id": "2afee7c4-8b16-4f2f-a567-48fb7948abcf", + "vnf-id": "21dcbbd2-3ec2-4a9c-bb0d-599cafc16a1f", + "vnf_name": "sample-vnf-name", + "vf-module-name": "vf-module-name", + "vf-module-label": "'$TEMPLATE_NAME'", + "vf-module-type": "vf-module-type", + "vf-module-model-customization-uuid": "d3ae2df9-95d4-48cc-a466-9f12dee80458", + "vf-module-model-invariant-uuid": "564e55dc-3b90-4c9c-9e97-42f2c97d8f11", + "vf-module-model-version": "3d55e2a6-7634-4ceb-98e9-2852d621a544", + "vf-module-id": "3e6a0375-4b92-4bf5-9910-b0b893448a9c", + "vf-naming-policy" : "SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP", + "k8s-rb-profile-name": "vpkg-modified", + "k8s-rb-profile-source": "vfw-cnf-cds-vpkg-profile", + "k8s-rb-profile-namespace": "test", + "management-prefix-id" : 3 + } + } + } +}' | jq '.payload | .["resource-assignment-response"] | .["meshed-template"] | .'$TEMPLATE_NAME' | fromjson | .["resource-accumulator-resolved-data"] ' diff --git a/heat/vFW_CNF_CDS/templates/cba-dev/run-vnf-ra.sh b/heat/vFW_CNF_CDS/templates/cba-dev/run-vnf-ra.sh new file mode 100755 index 00000000..8261ace3 --- /dev/null +++ b/heat/vFW_CNF_CDS/templates/cba-dev/run-vnf-ra.sh @@ -0,0 +1,61 @@ +#!/bin/sh + +# ============LICENSE_START======================================================= +# Copyright (C) 2020 Orange +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END========================================================= + +REQ_ID=`shuf -i 1-1000000 -n 1` +SUB_REQ_ID=$REQ_ID"-"`shuf -i 1-1000 -n 1` + +curl --location --request POST 'http://localhost:8081/api/v1/execution-service/process' \ +--header 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' \ +--header 'Content-Type: application/json' \ +--data-raw '{ + "commonHeader": { + "originatorId": "onap-me-cm-adapter", + "requestId": "'$REQ_ID'", + "subRequestId": "'$SUB_REQ_ID'" + }, + "actionIdentifiers": { + "blueprintName": "vFW_CNF_CDS", + "blueprintVersion": "7.0.0", + "actionName": "resource-assignment", + "mode": "sync" + }, + "payload": { + "resource-assignment-request": { + "template-prefix": [ + "vnf" + ], + "resolution-key": "ra-test-resolution", + "resource-assignment-properties": { + "vpg-management-port": 100, + "aic-cloud-region": "RegionOne", + "vnf-model-customization-uuid": "d73864db-1f6e-4e54-a533-a96773c926a4", + "service-instance-id": "2afee7c4-8b16-4f2f-a567-48fb7948abcf", + "vnf-id": "21dcbbd2-3ec2-4a9c-bb0d-599cafc16a1f", + "vnf_name": "sample-vnf-name", + "k8s-rb-profile-namespace": "vfw-namespace", + "int_private1_net_cidr" : "192.168.10.0/24", + "int_private2_net_cidr" : "192.168.20.0/24", + "onap_private_net_cidr" : "10.0.0.0/16", + "private1-prefix-id" : 2, + "private2-prefix-id" : 1 + } + } + } +}' | jq '.payload | .["resource-assignment-response"] | .["meshed-template"] | .vnf | fromjson | .["resource-accumulator-resolved-data"] ' + diff --git a/heat/vFW_CNF_CDS/templates/cba/Definitions/artifact_types.json b/heat/vFW_CNF_CDS/templates/cba/Definitions/artifact_types.json index bf55ac53..77d0eb19 100644 --- a/heat/vFW_CNF_CDS/templates/cba/Definitions/artifact_types.json +++ b/heat/vFW_CNF_CDS/templates/cba/Definitions/artifact_types.json @@ -15,6 +15,11 @@ "file_ext": [ "vtl" ] + }, + "artifact-k8sprofile-content": { + "description": "K8s Profile Folder Artifact", + "version": "1.0.0", + "derived_from": "tosca.artifacts.Implementation" } } } diff --git a/heat/vFW_CNF_CDS/templates/cba/Definitions/data_types.json b/heat/vFW_CNF_CDS/templates/cba/Definitions/data_types.json index 2a534d4f..5f3a2c09 100644 --- a/heat/vFW_CNF_CDS/templates/cba/Definitions/data_types.json +++ b/heat/vFW_CNF_CDS/templates/cba/Definitions/data_types.json @@ -72,18 +72,23 @@ "version": "1.0.0", "properties": { "vpg-management-port": { - "description": "SSH external port of ssh. When 0 ssh service will not be exposed", + "description": "SSH external port of optional ssh service for vPKG.", "type": "string", "default": "0" }, "k8s-rb-profile-namespace": { "description": "K8s namespace to create helm chart for specified profile", - "type": "string" + "type": "string", + "default": "default" }, "k8s-rb-profile-name": { "description": "Profile name used in multicloud/k8s plugin to identify Helm chart(s) where this mapping is providing override values.", "type": "string" }, + "k8s-rb-profile-source": { + "description": "The source folder or file relative to 'Templates/k8s-profiles' folder", + "type": "string" + }, "private1-prefix-id": { "description": "", "required": false, diff --git a/heat/vFW_CNF_CDS/templates/cba/Definitions/node_types.json b/heat/vFW_CNF_CDS/templates/cba/Definitions/node_types.json index 253f9dc4..9ee224b5 100644 --- a/heat/vFW_CNF_CDS/templates/cba/Definitions/node_types.json +++ b/heat/vFW_CNF_CDS/templates/cba/Definitions/node_types.json @@ -5,8 +5,14 @@ "version": "1.0.0", "attributes": { "assignment-params": { + "description": "Holds resolved template, resolution-summary or key-value", "required": true, "type": "string" + }, + "assignment-map": { + "description": "Holds resolved values for each artifact prefix eg. { vdns: { vnf-id: 123 } }", + "required": true, + "type": "map" } }, "capabilities": { @@ -27,8 +33,8 @@ "occurrence": { "description": "Number of time to perform the resolution.", "required": false, - "type": "integer", - "default": 1 + "default": 1, + "type": "integer" }, "store-result": { "description": "Whether or not to store the output.", @@ -46,8 +52,8 @@ "type": "boolean" }, "artifact-prefix-names": { - "description": "Template , Resource Assignment Artifact Prefix names", "required": true, + "description": "Template , Resource Assignment Artifact Prefix names", "type": "list", "entry_schema": { "type": "string" @@ -79,6 +85,10 @@ "required": true, "type": "string" }, + "resource-assignment-map": { + "required": true, + "type": "string" + }, "status": { "required": true, "type": "string" @@ -153,6 +163,76 @@ }, "derived_from": "tosca.nodes.Component" }, + "component-k8s-profile-upload": { + "description": "This component is rendering and sending the k8s profile to the multicloud plugin.", + "version": "1.0.0", + "attributes": { + "statuses": { + "required": true, + "type": "json" + } + }, + "capabilities": { + "component-node": { + "type": "tosca.capabilities.Node" + } + }, + "interfaces": { + "K8sProfileUploadComponent": { + "operations": { + "process": { + "inputs": { + "k8s-rb-profile-name": { + "description": "K8s profile name", + "required": false, + "type": "string" + }, + "k8s-rb-definition-name": { + "description": "K8s definition name", + "required": false, + "type": "string" + }, + "k8s-rb-definition-version": { + "description": "Version of the definition", + "required": false, + "type": "string" + }, + "k8s-rb-profile-namespace": { + "description": "a K8s namespace for the profile", + "required": false, + "type": "string" + }, + "k8s-rb-profile-source": { + "description": "Source (tgz/folder) for the template in CBA", + "required": false, + "type": "string" + }, + "artifact-prefix-names": { + "description": "Resource Assignment Artifact Prefix names", + "required": false, + "type": "list", + "entry_schema": { + "type": "string" + } + }, + "resource-assignment-map": { + "description": "Holds resolved values for each artifact prefix eg. { vdns: { vnf-id: 123 } }", + "required": false, + "type": "json" + } + }, + "outputs": { + "statuses": { + "required": true, + "type": "string" + } + } + } + } + } + }, + "derived_from": "tosca.nodes.Component" + }, "source-capability": { "description": "This is Component Resource Source Node Type", "version": "1.0.0", diff --git a/heat/vFW_CNF_CDS/templates/cba/Definitions/resources_definition_types.json b/heat/vFW_CNF_CDS/templates/cba/Definitions/resources_definition_types.json index 4c7aa47b..63d83e44 100644 --- a/heat/vFW_CNF_CDS/templates/cba/Definitions/resources_definition_types.json +++ b/heat/vFW_CNF_CDS/templates/cba/Definitions/resources_definition_types.json @@ -267,26 +267,6 @@ "default": { "type": "source-default", "properties": {} - }, - "sdnc": { - "type": "source-rest", - "properties": { - "verb": "GET", - "type": "JSON", - "url-path": "/restconf/config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/k8s-rb-profile-name", - "path": "/param/0/value", - "input-key-mapping": { - "service-instance-id": "service-instance-id", - "vnf-id": "vnf-id" - }, - "output-key-mapping": { - "k8s-rb-profile-name": "value" - }, - "key-dependencies": [ - "service-instance-id", - "vnf-id" - ] - } } } }, @@ -329,6 +309,25 @@ } } }, + "k8s-rb-profile-source": { + "tags": "k8s, cnf, profile, k8s-rb-profile-source", + "name": "k8s-rb-profile-source", + "property": { + "description": "The source folder or file relative to 'Templates/k8s-profiles' folder", + "type": "string" + }, + "group": "default", + "updated-by": "Rajewski, Lukasz ", + "sources": { + "input": { + "type": "source-input" + }, + "default": { + "type": "source-default", + "properties": {} + } + } + }, "management-prefix-id": { "tags": "management-prefix-id", "name": "management-prefix-id", @@ -927,7 +926,7 @@ "name": "vpg-management-port", "property": { "description": "vpg-management-port", - "type": "string" + "type": "integer" }, "group": "default", "updated-by": "Rajewski, Lukasz ", diff --git a/heat/vFW_CNF_CDS/templates/cba/Definitions/vFW_CNF_CDS.json b/heat/vFW_CNF_CDS/templates/cba/Definitions/vFW_CNF_CDS.json index 077bbc8e..3fa4e87e 100644 --- a/heat/vFW_CNF_CDS/templates/cba/Definitions/vFW_CNF_CDS.json +++ b/heat/vFW_CNF_CDS/templates/cba/Definitions/vFW_CNF_CDS.json @@ -2,11 +2,11 @@ "tosca_definitions_version": "controller_blueprint_1_0_0", "metadata": { "template_author": "Samuli Silvius ", - "author-email": "abdelmuhaimen.seaudi@orange.com", + "author-email": "lukasz.rajewski@orange.com", "user-groups": "ADMIN, OPERATION", "template_name": "vFW_CNF_CDS", - "template_version": "1.0.45", - "template_tags": "Samuli Silvius, vFW_CNF_CDS", + "template_version": "7.0.0", + "template_tags": "Samuli Silvius, Lukasz Rajewski, vFW_CNF_CDS", "template_type": "DEFAULT" }, "imports": [ @@ -33,30 +33,6 @@ "username": "admin", "password": "admin" }, - "multicloud-k8s-api": { - "type": "basic-auth", - "username": "admin", - "password": "admin", - "url": "http://multicloud-k8s:9015" - }, - "profile-upload-properties": { - "assignment-params": { - "get_attribute": [ - "resource-assignment", - "assignment-params" - ] - }, - "profile-modification-decision-data": { - "get_input": "vpg-management-port" - }, - "profile-artifacts": { - "get_attribute": [ - "profile-modification", - "assignment-params" - ] - }, - "api-access": "*multicloud-k8s-api" - }, "config-deploy-properties": { "resolution-key": { "get_input": "resolution-key" @@ -75,25 +51,13 @@ "call_operation": "ResourceResolutionComponent.process" } ], - "on_success": [ - "profile-modification" - ] - }, - "profile-modification": { - "description": "Profile Modification Resources", - "target": "profile-modification", - "activities": [ - { - "call_operation": "ResourceResolutionComponent.process" - } - ], "on_success": [ "profile-upload" ] }, "profile-upload": { - "description": "Upload K8s Profile", - "target": "profile-upload", + "description": "Generate and upload K8s Profile", + "target": "k8s-profile-upload", "activities": [ { "call_operation": "ComponentScriptExecutor.process" @@ -220,45 +184,39 @@ } } }, - "profile-modification": { - "type": "component-resource-resolution", + "k8s-profile-upload": { + "type": "component-k8s-profile-upload", "interfaces": { - "ResourceResolutionComponent": { + "K8sProfileUploadComponent": { "operations": { "process": { "inputs": { - "artifact-prefix-names": [ - "ssh-service" - ] + "artifact-prefix-names": { + "get_input": "template-prefix" + }, + "resource-assignment-map": { + "get_attribute": [ + "resource-assignment", + "assignment-map" + ] + } } } } } }, "artifacts": { - "ssh-service-template": { - "type": "artifact-template-velocity", - "file": "Templates/k8s-profiles/ssh-service-template.vtl" + "vfw-cnf-cds-base-profile": { + "type": "artifact-k8sprofile-content", + "file": "Templates/k8s-profiles/vfw-cnf-cds-base-profile.tar.gz" + }, + "vfw-cnf-cds-vpkg-profile": { + "type": "artifact-k8sprofile-content", + "file": "Templates/k8s-profiles/vfw-cnf-cds-vpkg-profile" }, - "ssh-service-mapping": { + "vfw-cnf-cds-vpkg-profile-mapping": { "type": "artifact-mapping-resource", - "file": "Templates/k8s-profiles/ssh-service-mapping.json" - } - } - }, - "profile-upload": { - "type": "component-script-executor", - "interfaces": { - "ComponentScriptExecutor": { - "operations": { - "process": { - "inputs": { - "script-type": "kotlin", - "script-class-reference": "org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts.K8sProfileUpload", - "dynamic-properties": "*profile-upload-properties" - } - } - } + "file": "Templates/k8s-profiles/vfw-cnf-cds-vpkg-profile/ssh-service-mapping.json" } } }, diff --git a/heat/vFW_CNF_CDS/templates/cba/Scripts/kotlin/KotlinK8sProfileUpload.kt b/heat/vFW_CNF_CDS/templates/cba/Scripts/kotlin/KotlinK8sProfileUpload.kt deleted file mode 100644 index d47b476a..00000000 --- a/heat/vFW_CNF_CDS/templates/cba/Scripts/kotlin/KotlinK8sProfileUpload.kt +++ /dev/null @@ -1,379 +0,0 @@ -/* - * Copyright © 2019 Orange - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts - -import com.fasterxml.jackson.databind.node.ObjectNode -import com.fasterxml.jackson.databind.ObjectMapper -import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput -import org.onap.ccsdk.cds.blueprintsprocessor.rest.BasicAuthRestClientProperties -import org.onap.ccsdk.cds.blueprintsprocessor.rest.RestClientProperties -import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BasicAuthRestClientService -import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService -import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.RestLoggerService -import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction -import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils -import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintArchiveUtils -import org.onap.ccsdk.cds.controllerblueprints.core.utils.ArchiveType -import org.apache.commons.io.IOUtils -import org.apache.commons.io.FilenameUtils -import org.apache.http.client.entity.EntityBuilder -import org.apache.http.entity.ContentType -import org.apache.http.message.BasicHeader -import org.apache.http.client.methods.HttpPost -import org.apache.http.client.methods.HttpUriRequest -import org.apache.http.client.ClientProtocolException -import org.slf4j.LoggerFactory -import org.springframework.http.HttpMethod -import org.springframework.web.client.RestTemplate -import com.fasterxml.jackson.annotation.JsonIgnore -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.ArrayList -import java.util.LinkedHashMap -import java.io.IOException -import java.io.File -import java.nio.file.Files -import java.nio.file.Paths -import java.nio.file.Path -import org.springframework.http.HttpHeaders -import org.springframework.http.MediaType -import java.nio.charset.Charset -import java.util.Base64 -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException -import org.yaml.snakeyaml.Yaml - -open class K8sProfileUpload : AbstractScriptComponentFunction() { - - private val log = LoggerFactory.getLogger(K8sProfileUpload::class.java)!! - - override fun getName(): String { - return "K8sProfileUpload" - } - - override suspend fun processNB(executionRequest: ExecutionServiceInput) { - log.info("executing K8s Profile Upload script") - - val baseK8sApiUrl = getDynamicProperties("api-access").get("url").asText() - val k8sApiUsername = getDynamicProperties("api-access").get("username").asText() - val k8sApiPassword = getDynamicProperties("api-access").get("password").asText() - - val prefixList: ArrayList = getTemplatePrefixList(executionRequest) - - for (prefix in prefixList) { - if (prefix.toLowerCase().equals("vnf")) { - log.info("For vnf-level resource-assignment, profile upload is not performed") - continue - } - - val assignmentParams = getDynamicProperties("assignment-params") - val payloadObject = JacksonUtils.jsonNode(assignmentParams.get(prefix).asText()) as ObjectNode - - log.info("Uploading K8S profile for template prefix $prefix") - - val vfModuleModelInvariantUuid: String = getResolvedParameter(payloadObject, "vf-module-model-invariant-uuid") - val vfModuleModelUuid: String = getResolvedParameter(payloadObject, "vf-module-model-version") - val k8sRbProfileName: String = getResolvedParameter(payloadObject, "k8s-rb-profile-name") - val k8sRbProfileNamespace: String = getResolvedParameter(payloadObject, "k8s-rb-profile-namespace") - - val api = K8sApi(k8sApiUsername, k8sApiPassword, baseK8sApiUrl, vfModuleModelInvariantUuid, vfModuleModelUuid) - - if (!api.hasDefinition()) { - throw BluePrintProcessorException("K8s RB Definition (${vfModuleModelInvariantUuid}/${vfModuleModelUuid}) not found ") - } - - log.info("k8s-rb-profile-name: $k8sRbProfileName") - if (k8sRbProfileName.equals("")) { - throw BluePrintProcessorException("K8s rb profile name is empty! Either define profile name to use or choose default") - } - if (k8sRbProfileName.equals("default") and api.hasProfile(k8sRbProfileName)) { - log.info("Using default profile - skipping upload") - } else { - if (api.hasProfile(k8sRbProfileName)) { - log.info("Profile Already Existing - skipping upload") - } else { - val profileFilePath: Path = prepareProfileFile(k8sRbProfileName, prefix.equals("vpkg")) - - var profile = K8sProfile() - profile.profileName = k8sRbProfileName - profile.rbName = vfModuleModelInvariantUuid - profile.rbVersion = vfModuleModelUuid - profile.namespace = k8sRbProfileNamespace - api.createProfile(profile) - api.uploadProfileContent(profile, profileFilePath) - - log.info("K8s Profile Upload Completed") - } - } - } - } - - fun prepareProfileFile(k8sRbProfileName: String, profileModificationAllowed: Boolean): Path { - val bluePrintContext = bluePrintRuntimeService.bluePrintContext() - val bluePrintBasePath: String = bluePrintContext.rootPath - var profileFilePath: Path = Paths.get(bluePrintBasePath.plus(File.separator).plus("Templates").plus(File.separator).plus("k8s-profiles").plus(File.separator).plus("${k8sRbProfileName}.tar.gz")) - log.info("Reading K8s profile file: ${profileFilePath}") - - val profileFile = profileFilePath.toFile() - - if (!profileFile.exists()) - throw BluePrintProcessorException("K8s Profile template file ${profileFilePath} does not exists") - - val tempMainPath: File = createTempDir("k8s-profile-", "") - val tempProfilePath: File = createTempDir("${k8sRbProfileName}-", "", tempMainPath) - log.info("Decompressing profile to ${tempProfilePath.toString()}") - - val decompressedProfile: File = BluePrintArchiveUtils.deCompress(profileFilePath.toFile(), - "${tempProfilePath.toString()}", ArchiveType.TarGz) - - log.info("${profileFilePath.toString()} decompression completed") - - if (profileModificationAllowed) { - //Here we can add extra files inside the archive - val profileModificationDecisionData = getDynamicProperties("profile-modification-decision-data") - log.info("Profile modification decision data: ${profileModificationDecisionData}") - if (profileModificationDecisionData != null && profileModificationDecisionData.asText().toInt() > 0) { - log.info("Modification of profile content") - - val profileArtifacts = getDynamicProperties("profile-artifacts") - val sshServiceFileContent = profileArtifacts.get("ssh-service").asText() - val sshServiceFileName = "ssh-service.yaml" - val serviceFilePath = tempProfilePath.toString().plus(File.separator).plus(sshServiceFileName) - File(serviceFilePath).bufferedWriter().use { out -> out.write(sshServiceFileContent) } - val manifestFileName = tempProfilePath.toString().plus(File.separator).plus("manifest.yaml") - var finalManifest = "" - File(manifestFileName).bufferedReader().use { inr -> - val manifestYaml = Yaml() - val manifestObject: Map = manifestYaml.load(inr) - val typeObject: MutableMap = manifestObject.get("type") as MutableMap - if (!typeObject.containsKey("configresource")) - typeObject.put("configresource", ArrayList>()) - val configFiles: MutableList> = typeObject.get("configresource") as MutableList> - val sshConfigFile = LinkedHashMap() - sshConfigFile.put("filepath", sshServiceFileName) - sshConfigFile.put("chartpath", "vpkg/templates/${sshServiceFileName}") - configFiles.add(sshConfigFile) - finalManifest = manifestYaml.dump(manifestObject) - } - File(manifestFileName).bufferedWriter().use { out -> out.write(finalManifest) } - log.info("Modified K8s profile manifest file") - log.info(finalManifest) - log.info("Modification of profile completed") - } - } - - profileFilePath = Paths.get(tempMainPath.toString().plus(File.separator).plus("${k8sRbProfileName}.tar.gz")) - - if (!BluePrintArchiveUtils.compress(decompressedProfile, profileFilePath.toFile(), - ArchiveType.TarGz)) { - throw BluePrintProcessorException("Profile compression has failed") - } - - log.info("${profileFilePath.toString()} compression completed") - - return profileFilePath - } - - fun getTemplatePrefixList(executionRequest: ExecutionServiceInput): ArrayList { - val result = ArrayList() - for (prefix in executionRequest.payload.get("resource-assignment-request").get("template-prefix").elements()) - result.add(prefix.asText()) - return result - } - - fun getResolvedParameter(payload: ObjectNode, keyName: String): String { - for (node in payload.get("resource-accumulator-resolved-data").elements()) { - if (node.get("param-name").asText().equals(keyName)) { - return node.get("param-value").asText() - } - } - return "" - } - - override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { - log.info("Executing Recovery") - bluePrintRuntimeService.getBluePrintError().addError("${runtimeException.message}") - } - - inner class K8sApi(val username: String, val password: String, val baseUrl: String, val definition: String, - val definitionVersion: String) { - private val service: UploadFileRestClientService //BasicAuthRestClientService - - init { - var mapOfHeaders = hashMapOf() - mapOfHeaders.put("Accept", "application/json") - mapOfHeaders.put("Content-Type", "application/json") - mapOfHeaders.put("cache-control", " no-cache") - mapOfHeaders.put("Accept", "application/json") - var basicAuthRestClientProperties: BasicAuthRestClientProperties = BasicAuthRestClientProperties() - basicAuthRestClientProperties.username = username - basicAuthRestClientProperties.password = password - basicAuthRestClientProperties.url = "$baseUrl/v1/rb/definition/${definition}/${definitionVersion}" - basicAuthRestClientProperties.additionalHeaders = mapOfHeaders - - this.service = UploadFileRestClientService(basicAuthRestClientProperties) - } - - fun hasDefinition(): Boolean { - try { - val result: BlueprintWebClientService.WebClientResponse = service.exchangeResource(HttpMethod.GET.name, "", "") - print(result) - if (result.status >= 200 && result.status < 300) - return true - else - return false - } catch (e: Exception) { - log.info("Caught exception trying to get k8s rb definition") - throw BluePrintProcessorException("${e.message}") - } - } - - fun hasProfile(profileName: String): Boolean { - try { - val result: BlueprintWebClientService.WebClientResponse = service.exchangeResource(HttpMethod.GET.name, - "/profile/$profileName", "") - if (result.status >= 200 && result.status < 300) - return true - else { - print(result) - return false - } - } catch (e: Exception) { - log.info("Caught exception trying to get k8s rb profile") - throw BluePrintProcessorException("${e.message}") - } - } - - fun createProfile(profile: K8sProfile) { - val objectMapper = ObjectMapper() - val profileJsonString: String = objectMapper.writeValueAsString(profile) - try { - val result: BlueprintWebClientService.WebClientResponse = service.exchangeResource(HttpMethod.POST.name, - "/profile", profileJsonString) - if (result.status < 200 || result.status >= 300) { - throw Exception(result.body) - } - } catch (e: Exception) { - log.info("Caught exception trying to create k8s rb profile ${profile.profileName}") - throw BluePrintProcessorException("${e.message}") - } - } - - fun uploadProfileContent(profile: K8sProfile, filePath: Path) { - try { - val result: BlueprintWebClientService.WebClientResponse = service.uploadBinaryFile( - "/profile/${profile.profileName}/content", filePath) - if (result.status < 200 || result.status >= 300) { - throw Exception(result.body) - } - } catch (e: Exception) { - log.info("Caught exception trying to upload k8s rb profile ${profile.profileName}") - throw BluePrintProcessorException("${e.message}") - } - } - } -} - -class UploadFileRestClientService( - private val restClientProperties: - BasicAuthRestClientProperties -) : BlueprintWebClientService { - - override fun defaultHeaders(): Map { - - val encodedCredentials = setBasicAuth( - restClientProperties.username, - restClientProperties.password - ) - return mapOf( - HttpHeaders.CONTENT_TYPE to MediaType.APPLICATION_JSON_VALUE, - HttpHeaders.ACCEPT to MediaType.APPLICATION_JSON_VALUE, - HttpHeaders.AUTHORIZATION to "Basic $encodedCredentials" - ) - } - - override fun host(uri: String): String { - return restClientProperties.url + uri - } - - override fun convertToBasicHeaders(headers: Map): - Array { - val customHeaders: MutableMap = headers.toMutableMap() - // inject additionalHeaders - customHeaders.putAll(verifyAdditionalHeaders(restClientProperties)) - - if (!headers.containsKey(HttpHeaders.AUTHORIZATION)) { - val encodedCredentials = setBasicAuth( - restClientProperties.username, - restClientProperties.password - ) - customHeaders[HttpHeaders.AUTHORIZATION] = - "Basic $encodedCredentials" - } - return super.convertToBasicHeaders(customHeaders) - } - - private fun setBasicAuth(username: String, password: String): String { - val credentialsString = "$username:$password" - return Base64.getEncoder().encodeToString( - credentialsString.toByteArray(Charset.defaultCharset()) - ) - } - - @Throws(IOException::class, ClientProtocolException::class) - private fun performHttpCall(httpUriRequest: HttpUriRequest): BlueprintWebClientService.WebClientResponse { - val httpResponse = httpClient().execute(httpUriRequest) - val statusCode = httpResponse.statusLine.statusCode - httpResponse.entity.content.use { - val body = IOUtils.toString(it, Charset.defaultCharset()) - return BlueprintWebClientService.WebClientResponse(statusCode, body) - } - } - - fun uploadBinaryFile(path: String, filePath: Path): BlueprintWebClientService.WebClientResponse { - val convertedHeaders: Array = convertToBasicHeaders(defaultHeaders()) - val httpPost = HttpPost(host(path)) - val entity = EntityBuilder.create().setBinary(Files.readAllBytes(filePath)).build() - httpPost.setEntity(entity) - RestLoggerService.httpInvoking(convertedHeaders) - httpPost.setHeaders(convertedHeaders) - return performHttpCall(httpPost) - } -} - -class K8sProfile { - @get:JsonProperty("rb-name") - var rbName: String? = null - @get:JsonProperty("rb-version") - var rbVersion: String? = null - @get:JsonProperty("profile-name") - var profileName: String? = null - @get:JsonProperty("namespace") - var namespace: String? = "default" - - override fun toString(): String { - return "$rbName:$rbVersion:$profileName" - } - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (javaClass != other?.javaClass) return false - return true - } - - override fun hashCode(): Int { - return javaClass.hashCode() - } -} diff --git a/heat/vFW_CNF_CDS/templates/cba/TOSCA-Metadata/TOSCA.meta b/heat/vFW_CNF_CDS/templates/cba/TOSCA-Metadata/TOSCA.meta index 80d82af3..fd11bfbc 100644 --- a/heat/vFW_CNF_CDS/templates/cba/TOSCA-Metadata/TOSCA.meta +++ b/heat/vFW_CNF_CDS/templates/cba/TOSCA-Metadata/TOSCA.meta @@ -3,6 +3,6 @@ CSAR-Version: 1.0 Created-By: Samuli Silvius Entry-Definitions: Definitions/vFW_CNF_CDS.json Template-Name: vFW_CNF_CDS -Template-Version: 1.0.45 +Template-Version: 7.0.0 Template-Type: DEFAULT -Template-Tags: Samuli Silvius, vFW_CNF_CDS +Template-Tags: Samuli Silvius, Lukasz Rajewski, vFW_CNF_CDS diff --git a/heat/vFW_CNF_CDS/templates/cba/Templates/base_template-mapping.json b/heat/vFW_CNF_CDS/templates/cba/Templates/base_template-mapping.json index dd49ad28..53cd0f71 100644 --- a/heat/vFW_CNF_CDS/templates/cba/Templates/base_template-mapping.json +++ b/heat/vFW_CNF_CDS/templates/cba/Templates/base_template-mapping.json @@ -138,29 +138,73 @@ { "name": "k8s-rb-profile-namespace", "property": { - "description": "K8s namespace to create helm chart for specified profile", - "type": "string" + "description": "K8s namespace to create helm chart for specified RB profile", + "type": "string", + "required": false, + "default": "default" }, "input-param": false, "dictionary-name": "k8s-rb-profile-namespace", "dictionary-source": "sdnc", - "dependencies": [ - "service-instance-id", - "vnf-id" - ] + "dependencies": [] }, { "name": "k8s-rb-profile-name", "property": { - "description": "Profile name used in multicloud/k8s plugin to identify Helm chart(s) where this mapping is providing override values.", - "type": "string" + "description": "RB Profile name used in k8s plugin to identify Helm chart(s) where this mapping is providing override values.", + "type": "string", + "required": false, + "default": "default" }, "input-param": false, "dictionary-name": "k8s-rb-profile-name", - "dictionary-source": "sdnc", + "dictionary-source": "default", + "dependencies": [] + }, + { + "name": "k8s-rb-definition-name", + "property": { + "description": "RB Name identifier of Helm chart(s) in k8s plugin", + "type": "string", + "required": false, + "metadata": { + "transform-template": "${vf-module-model-invariant-uuid}" + } + }, + "input-param": false, + "dictionary-name": "k8s-rb-definition-name", + "dictionary-source": "default", "dependencies": [ - "service-instance-id", - "vnf-id" + "vf-module-model-invariant-uuid" ] + }, + { + "name": "k8s-rb-definition-version", + "property": { + "description": "RB Version identifier of Helm chart(s) in k8s plugin", + "type": "string", + "required": false, + "metadata": { + "transform-template": "${vf-module-model-version}" + } + }, + "input-param": false, + "dictionary-name": "k8s-rb-definition-version", + "dictionary-source": "default", + "dependencies": [ + "vf-module-model-version" + ] + }, + { + "name": "k8s-rb-profile-source", + "property": { + "description": "The source folder or file relative to 'Templates/k8s-profiles' folder", + "type": "string", + "required": true + }, + "input-param": false, + "dictionary-name": "k8s-rb-profile-source", + "dictionary-source": "default", + "dependencies": [] } ] diff --git a/heat/vFW_CNF_CDS/templates/cba/Templates/base_template-template.vtl b/heat/vFW_CNF_CDS/templates/cba/Templates/base_template-template.vtl index 401a0bd7..a6bc57b5 100644 --- a/heat/vFW_CNF_CDS/templates/cba/Templates/base_template-template.vtl +++ b/heat/vFW_CNF_CDS/templates/cba/Templates/base_template-template.vtl @@ -107,10 +107,6 @@ "param-name": "k8s-rb-profile-name", "param-value": "${k8s-rb-profile-name}" }, - { - "param-name": "k8s-rb-profile-namespace", - "param-value": "${k8s-rb-profile-namespace}" - }, { "param-name": "int_private1_subnet_id", "param-value": "unprotected-network-subnet-1" diff --git a/heat/vFW_CNF_CDS/templates/cba/Templates/k8s-profiles/vfw-cnf-cds-vpkg-profile/manifest.yaml b/heat/vFW_CNF_CDS/templates/cba/Templates/k8s-profiles/vfw-cnf-cds-vpkg-profile/manifest.yaml new file mode 100644 index 00000000..adb9f86c --- /dev/null +++ b/heat/vFW_CNF_CDS/templates/cba/Templates/k8s-profiles/vfw-cnf-cds-vpkg-profile/manifest.yaml @@ -0,0 +1,7 @@ +--- +version: v1 +type: + values: "override_values.yaml" + configresource: + - filepath: ssh-service-template.yaml + chartpath: vpkg/templates/ssh-service-template.yaml diff --git a/heat/vFW_CNF_CDS/templates/cba/Templates/k8s-profiles/vfw-cnf-cds-vpkg-profile/override_values.yaml b/heat/vFW_CNF_CDS/templates/cba/Templates/k8s-profiles/vfw-cnf-cds-vpkg-profile/override_values.yaml new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/heat/vFW_CNF_CDS/templates/cba/Templates/k8s-profiles/vfw-cnf-cds-vpkg-profile/override_values.yaml @@ -0,0 +1 @@ + diff --git a/heat/vFW_CNF_CDS/templates/cba/Templates/k8s-profiles/ssh-service-mapping.json b/heat/vFW_CNF_CDS/templates/cba/Templates/k8s-profiles/vfw-cnf-cds-vpkg-profile/ssh-service-mapping.json similarity index 78% rename from heat/vFW_CNF_CDS/templates/cba/Templates/k8s-profiles/ssh-service-mapping.json rename to heat/vFW_CNF_CDS/templates/cba/Templates/k8s-profiles/vfw-cnf-cds-vpkg-profile/ssh-service-mapping.json index 34be0c48..47db31da 100644 --- a/heat/vFW_CNF_CDS/templates/cba/Templates/k8s-profiles/ssh-service-mapping.json +++ b/heat/vFW_CNF_CDS/templates/cba/Templates/k8s-profiles/vfw-cnf-cds-vpkg-profile/ssh-service-mapping.json @@ -2,8 +2,8 @@ { "name": "vpg-management-port", "property": { - "description": "The number of node port for ssh service of vpg. 0 means that ssh service will not be exposed", - "type": "string", + "description": "The number of node port for ssh service of vpg", + "type": "integer", "default": "0" }, "input-param": false, diff --git a/heat/vFW_CNF_CDS/templates/cba/Templates/k8s-profiles/ssh-service-template.vtl b/heat/vFW_CNF_CDS/templates/cba/Templates/k8s-profiles/vfw-cnf-cds-vpkg-profile/ssh-service-template.yaml.vtl similarity index 100% rename from heat/vFW_CNF_CDS/templates/cba/Templates/k8s-profiles/ssh-service-template.vtl rename to heat/vFW_CNF_CDS/templates/cba/Templates/k8s-profiles/vfw-cnf-cds-vpkg-profile/ssh-service-template.yaml.vtl diff --git a/heat/vFW_CNF_CDS/templates/cba/Templates/vfw-mapping.json b/heat/vFW_CNF_CDS/templates/cba/Templates/vfw-mapping.json index 2eae129f..ff3dfd8e 100644 --- a/heat/vFW_CNF_CDS/templates/cba/Templates/vfw-mapping.json +++ b/heat/vFW_CNF_CDS/templates/cba/Templates/vfw-mapping.json @@ -138,29 +138,73 @@ { "name": "k8s-rb-profile-namespace", "property": { - "description": "K8s namespace to create helm chart for specified profile", - "type": "string" + "description": "K8s namespace to create helm chart for specified RB profile", + "type": "string", + "required": false, + "default": "default" }, "input-param": false, "dictionary-name": "k8s-rb-profile-namespace", "dictionary-source": "sdnc", - "dependencies": [ - "service-instance-id", - "vnf-id" - ] + "dependencies": [] }, { "name": "k8s-rb-profile-name", "property": { - "description": "Profile name used in multicloud/k8s plugin to identify Helm chart(s) where this mapping is providing override values.", - "type": "string" + "description": "RB Profile name used in k8s plugin to identify Helm chart(s) where this mapping is providing override values.", + "type": "string", + "required": false, + "default": "default" }, "input-param": false, "dictionary-name": "k8s-rb-profile-name", - "dictionary-source": "sdnc", + "dictionary-source": "default", + "dependencies": [] + }, + { + "name": "k8s-rb-definition-name", + "property": { + "description": "RB Name identifier of Helm chart(s) in k8s plugin", + "type": "string", + "required": false, + "metadata": { + "transform-template": "${vf-module-model-invariant-uuid}" + } + }, + "input-param": false, + "dictionary-name": "k8s-rb-definition-name", + "dictionary-source": "default", "dependencies": [ - "service-instance-id", - "vnf-id" + "vf-module-model-invariant-uuid" ] + }, + { + "name": "k8s-rb-definition-version", + "property": { + "description": "RB Version identifier of Helm chart(s) in k8s plugin", + "type": "string", + "required": false, + "metadata": { + "transform-template": "${vf-module-model-version}" + } + }, + "input-param": false, + "dictionary-name": "k8s-rb-definition-version", + "dictionary-source": "default", + "dependencies": [ + "vf-module-model-version" + ] + }, + { + "name": "k8s-rb-profile-source", + "property": { + "description": "The source folder or file relative to 'Templates/k8s-profiles' folder", + "type": "string", + "required": true + }, + "input-param": false, + "dictionary-name": "k8s-rb-profile-source", + "dictionary-source": "default", + "dependencies": [] } ] diff --git a/heat/vFW_CNF_CDS/templates/cba/Templates/vfw-template.vtl b/heat/vFW_CNF_CDS/templates/cba/Templates/vfw-template.vtl index d65b6f92..55f9451c 100644 --- a/heat/vFW_CNF_CDS/templates/cba/Templates/vfw-template.vtl +++ b/heat/vFW_CNF_CDS/templates/cba/Templates/vfw-template.vtl @@ -119,10 +119,6 @@ { "param-name": "k8s-rb-profile-name", "param-value": "${k8s-rb-profile-name}" - }, - { - "param-name": "k8s-rb-profile-namespace", - "param-value": "${k8s-rb-profile-namespace}" } ] } 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 bee80d14..c6411d71 100644 --- a/heat/vFW_CNF_CDS/templates/cba/Templates/vnf-mapping.json +++ b/heat/vFW_CNF_CDS/templates/cba/Templates/vnf-mapping.json @@ -159,18 +159,6 @@ "dependencies": [], "version": 0 }, - { - "name": "k8s-rb-profile-name", - "property": { - "description": "Profile name used in multicloud/k8s plugin to identify Helm chart(s) where this mapping is providing override values.", - "type": "string", - "default": "vfw-cnf-cds-base-profile" - }, - "input-param": false, - "dictionary-name": "k8s-rb-profile-name", - "dictionary-source": "default", - "dependencies": [] - }, { "name": "k8s-rb-profile-namespace", "property": { diff --git a/heat/vFW_CNF_CDS/templates/cba/Templates/vnf-template.vtl b/heat/vFW_CNF_CDS/templates/cba/Templates/vnf-template.vtl index 7acdc544..9e23665f 100644 --- a/heat/vFW_CNF_CDS/templates/cba/Templates/vnf-template.vtl +++ b/heat/vFW_CNF_CDS/templates/cba/Templates/vnf-template.vtl @@ -254,14 +254,6 @@ { "param-name": "demo_artifacts_version", "param-value": "${demo_artifacts_version}" - }, - { - "param-name": "k8s-rb-profile-name", - "param-value": "${k8s-rb-profile-name}" - }, - { - "param-name": "k8s-rb-profile-namespace", - "param-value": "${k8s-rb-profile-namespace}" } ] } diff --git a/heat/vFW_CNF_CDS/templates/cba/Templates/vpkg-mapping.json b/heat/vFW_CNF_CDS/templates/cba/Templates/vpkg-mapping.json index 4a1b9150..86217c16 100644 --- a/heat/vFW_CNF_CDS/templates/cba/Templates/vpkg-mapping.json +++ b/heat/vFW_CNF_CDS/templates/cba/Templates/vpkg-mapping.json @@ -138,29 +138,73 @@ { "name": "k8s-rb-profile-namespace", "property": { - "description": "K8s namespace to create helm chart for specified profile", - "type": "string" + "description": "K8s namespace to create helm chart for specified RB profile", + "type": "string", + "required": false, + "default": "default" }, "input-param": false, "dictionary-name": "k8s-rb-profile-namespace", "dictionary-source": "sdnc", - "dependencies": [ - "service-instance-id", - "vnf-id" - ] + "dependencies": [] }, { "name": "k8s-rb-profile-name", "property": { - "description": "Profile name used in multicloud/k8s plugin to identify Helm chart(s) where this mapping is providing override values.", - "type": "string" + "description": "RB Profile name used in k8s plugin to identify Helm chart(s) where this mapping is providing override values.", + "type": "string", + "required": false, + "default": "default" }, "input-param": false, "dictionary-name": "k8s-rb-profile-name", - "dictionary-source": "sdnc", + "dictionary-source": "default", + "dependencies": [] + }, + { + "name": "k8s-rb-definition-name", + "property": { + "description": "RB Name identifier of Helm chart(s) in k8s plugin", + "type": "string", + "required": false, + "metadata": { + "transform-template": "${vf-module-model-invariant-uuid}" + } + }, + "input-param": false, + "dictionary-name": "k8s-rb-definition-name", + "dictionary-source": "default", "dependencies": [ - "service-instance-id", - "vnf-id" + "vf-module-model-invariant-uuid" ] + }, + { + "name": "k8s-rb-definition-version", + "property": { + "description": "RB Version identifier of Helm chart(s) in k8s plugin", + "type": "string", + "required": false, + "metadata": { + "transform-template": "${vf-module-model-version}" + } + }, + "input-param": false, + "dictionary-name": "k8s-rb-definition-version", + "dictionary-source": "default", + "dependencies": [ + "vf-module-model-version" + ] + }, + { + "name": "k8s-rb-profile-source", + "property": { + "description": "The source folder or file relative to 'Templates/k8s-profiles' folder", + "type": "string", + "required": true + }, + "input-param": false, + "dictionary-name": "k8s-rb-profile-source", + "dictionary-source": "default", + "dependencies": [] } ] diff --git a/heat/vFW_CNF_CDS/templates/cba/Templates/vpkg-template.vtl b/heat/vFW_CNF_CDS/templates/cba/Templates/vpkg-template.vtl index 18511d54..2a6b7985 100644 --- a/heat/vFW_CNF_CDS/templates/cba/Templates/vpkg-template.vtl +++ b/heat/vFW_CNF_CDS/templates/cba/Templates/vpkg-template.vtl @@ -119,10 +119,6 @@ { "param-name": "k8s-rb-profile-name", "param-value": "${k8s-rb-profile-name}" - }, - { - "param-name": "k8s-rb-profile-namespace", - "param-value": "${k8s-rb-profile-namespace}" } ] } diff --git a/heat/vFW_CNF_CDS/templates/cba/Templates/vsn-mapping.json b/heat/vFW_CNF_CDS/templates/cba/Templates/vsn-mapping.json index 3d3bbd22..edd834c5 100644 --- a/heat/vFW_CNF_CDS/templates/cba/Templates/vsn-mapping.json +++ b/heat/vFW_CNF_CDS/templates/cba/Templates/vsn-mapping.json @@ -138,29 +138,73 @@ { "name": "k8s-rb-profile-namespace", "property": { - "description": "K8s namespace to create helm chart for specified profile", - "type": "string" + "description": "K8s namespace to create helm chart for specified RB profile", + "type": "string", + "required": false, + "default": "default" }, "input-param": false, "dictionary-name": "k8s-rb-profile-namespace", "dictionary-source": "sdnc", - "dependencies": [ - "service-instance-id", - "vnf-id" - ] + "dependencies": [] }, { "name": "k8s-rb-profile-name", "property": { - "description": "Profile name used in multicloud/k8s plugin to identify Helm chart(s) where this mapping is providing override values.", - "type": "string" + "description": "RB Profile name used in k8s plugin to identify Helm chart(s) where this mapping is providing override values.", + "type": "string", + "required": false, + "default": "default" }, "input-param": false, "dictionary-name": "k8s-rb-profile-name", - "dictionary-source": "sdnc", + "dictionary-source": "default", + "dependencies": [] + }, + { + "name": "k8s-rb-definition-name", + "property": { + "description": "RB Name identifier of Helm chart(s) in k8s plugin", + "type": "string", + "required": false, + "metadata": { + "transform-template": "${vf-module-model-invariant-uuid}" + } + }, + "input-param": false, + "dictionary-name": "k8s-rb-definition-name", + "dictionary-source": "default", "dependencies": [ - "service-instance-id", - "vnf-id" + "vf-module-model-invariant-uuid" ] + }, + { + "name": "k8s-rb-definition-version", + "property": { + "description": "RB Version identifier of Helm chart(s) in k8s plugin", + "type": "string", + "required": false, + "metadata": { + "transform-template": "${vf-module-model-version}" + } + }, + "input-param": false, + "dictionary-name": "k8s-rb-definition-version", + "dictionary-source": "default", + "dependencies": [ + "vf-module-model-version" + ] + }, + { + "name": "k8s-rb-profile-source", + "property": { + "description": "The source folder or file relative to 'Templates/k8s-profiles' folder", + "type": "string", + "required": true + }, + "input-param": false, + "dictionary-name": "k8s-rb-profile-source", + "dictionary-source": "default", + "dependencies": [] } ] diff --git a/heat/vFW_CNF_CDS/templates/cba/Templates/vsn-template.vtl b/heat/vFW_CNF_CDS/templates/cba/Templates/vsn-template.vtl index 3e2d8c1c..4768ab80 100644 --- a/heat/vFW_CNF_CDS/templates/cba/Templates/vsn-template.vtl +++ b/heat/vFW_CNF_CDS/templates/cba/Templates/vsn-template.vtl @@ -119,10 +119,6 @@ { "param-name": "k8s-rb-profile-name", "param-value": "${k8s-rb-profile-name}" - }, - { - "param-name": "k8s-rb-profile-namespace", - "param-value": "${k8s-rb-profile-namespace}" } ] } diff --git a/heat/vFW_CNF_CDS/templates/cba/pom.xml b/heat/vFW_CNF_CDS/templates/cba/pom.xml new file mode 100644 index 00000000..26bf93e1 --- /dev/null +++ b/heat/vFW_CNF_CDS/templates/cba/pom.xml @@ -0,0 +1,43 @@ + + + + + 4.0.0 + + + org.onap.ccsdk.cds.blueprintsprocessor + test-blueprint-kotlin-parent + 1.0.0-SNAPSHOT + + + vFW_CNF_CDS + 1.0.0-SNAPSHOT + pom + + + + ccsdkapps + ccsdkapps + + + -- 2.16.6