aboutsummaryrefslogtreecommitdiffstats
path: root/heat
diff options
context:
space:
mode:
authorMichał Grzesik <michal.grzesik@orange.com>2021-03-10 17:26:04 +0100
committerLukasz Rajewski <lukasz.rajewski@orange.com>2021-03-10 21:22:15 +0100
commit1ff5827ffde7af1d8aed23890a571455300ade6d (patch)
tree6abdbeba5e1233d06c36e45ff1d4b8f7d30130d5 /heat
parent1e501466e21b774ccaadef19f4618decc0650001 (diff)
Add cofig-assign and config-deploy to cds workflow
Add cofig-assign and config-deploy to cds workflow, cloud region and vf params list updated, exporting onap settings for onapsdk Issue-ID: INT-1868 Signed-off-by: Michal Grzesik <michal.grzesik@orange.com> Change-Id: I68acbc2ecedfafb4d2291707f5fef82e8feab831
Diffstat (limited to 'heat')
-rwxr-xr-xheat/vFW_CNF_CDS/automation/README.md24
-rw-r--r--heat/vFW_CNF_CDS/automation/artifacts/cluster_kubeconfig1
-rw-r--r--heat/vFW_CNF_CDS/automation/artifacts/onap_kubeconfig0
-rwxr-xr-xheat/vFW_CNF_CDS/automation/config.py52
-rwxr-xr-xheat/vFW_CNF_CDS/automation/instantiate.py24
-rwxr-xr-xheat/vFW_CNF_CDS/automation/onap_settings.py27
-rwxr-xr-xheat/vFW_CNF_CDS/automation/onboard.py37
-rwxr-xr-xheat/vFW_CNF_CDS/automation/so_db_adapter.py129
-rw-r--r--heat/vFW_CNF_CDS/templates/cba/Definitions/data_types.json51
-rw-r--r--heat/vFW_CNF_CDS/templates/cba/Definitions/vFW_CNF_CDS.json86
-rw-r--r--heat/vFW_CNF_CDS/templates/cba/Scripts/kotlin/ConfigDeploy.kt59
-rw-r--r--heat/vFW_CNF_CDS/templates/cba/Templates/cnf-mapping.json22
-rw-r--r--heat/vFW_CNF_CDS/templates/cba/Templates/cnf-template.vtl3
13 files changed, 351 insertions, 164 deletions
diff --git a/heat/vFW_CNF_CDS/automation/README.md b/heat/vFW_CNF_CDS/automation/README.md
index e153cc68..a37ec9db 100755
--- a/heat/vFW_CNF_CDS/automation/README.md
+++ b/heat/vFW_CNF_CDS/automation/README.md
@@ -1,10 +1,12 @@
# vFW_CNF_CDS use case automation
+0. Make sure you have python 3.8.x installed and default interpreter, what is required by onap-pythonsdk
1. Install required packages with pipenv `pipenv install`
-2. Run virtual environment `pipenv shell --fancy`
-3. Add kubeconfig files, one for ONAP cluster, and one for k8s cluster that will host vFW:
+2. Run virtual environment `pipenv shell`. In case of problems use `--fancy` option
+
+ **In case of problems with pipenv:** `venv` can be used as well. In that case, please install all required python packages in correct version according the list in `Pipfile`
+3. Add kubeconfig file for k8s cluster that will host vFW
- `artifacts/cluster_kubeconfig`
- - `artifacts/onap_kubeconfig`
4. Prepare onboarding packages `cd ../templates/ && make && cd ../automation/`
5. Modify `config.py`:
- NATIVE - enables native helm orchestration path in SO
@@ -13,7 +15,15 @@
- VENDOR
- SERVICENAME
- CUSTOMER_RESOURCE_DEFINITIONS - add list of CRDs to be installed on non KUD k8s cluster
-6. Run script `python create_k8s_region.py` in order to create **k8s cloud region**
-7. Onboard **vFW** `python onboard.py`
-8. Instantiate **vFW** `python instantiate.py`
-9. Once test is done, **vFW** service instance can be deleted with `python delete.py` command
+ - VNF_PARAM_LIST - list of parameters to pass for VNF creation process
+ - VF_MODULE_PARAM_LIST - list of parameters to pass for VF Module creation
+6. __Important:__ Before running python scripts, some settings for `onapsdk` with information about ONAP endpoints (and socks) have to be exported.
+ All settings for ONAP instance are located in `automation/onap_settings.py` file. To export that settings please run command inside `pipenv` or `venv` shell
+ ```shell
+ (automation) ubuntu@onap:~/automation$ export ONAP_PYTHON_SDK_SETTINGS="onap_settings"
+ ```
+7. Run script `python create_k8s_region.py` in order to create **k8s cloud region**
+8. Onboard **vFW** `python onboard.py`
+9. Instantiate **vFW** `python instantiate.py`
+10. Once test is done, **vFW** service instance can be deleted with `python delete.py` command
+
diff --git a/heat/vFW_CNF_CDS/automation/artifacts/cluster_kubeconfig b/heat/vFW_CNF_CDS/automation/artifacts/cluster_kubeconfig
index e69de29b..8b137891 100644
--- a/heat/vFW_CNF_CDS/automation/artifacts/cluster_kubeconfig
+++ b/heat/vFW_CNF_CDS/automation/artifacts/cluster_kubeconfig
@@ -0,0 +1 @@
+
diff --git a/heat/vFW_CNF_CDS/automation/artifacts/onap_kubeconfig b/heat/vFW_CNF_CDS/automation/artifacts/onap_kubeconfig
deleted file mode 100644
index e69de29b..00000000
--- a/heat/vFW_CNF_CDS/automation/artifacts/onap_kubeconfig
+++ /dev/null
diff --git a/heat/vFW_CNF_CDS/automation/config.py b/heat/vFW_CNF_CDS/automation/config.py
index f5d39c16..96b098dd 100755
--- a/heat/vFW_CNF_CDS/automation/config.py
+++ b/heat/vFW_CNF_CDS/automation/config.py
@@ -1,5 +1,5 @@
# ============LICENSE_START=======================================================
-# Copyright (C) 2020 Orange
+# Copyright (C) 2021 Orange
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -17,7 +17,6 @@
class Config:
#### REGION DETAILS ####
- NATIVE = False
COMPLEX_ID = "complex"
CLOUD_OWNER = "k8sCloudOwner"
CLOUD_REGION = "k8s-region-1"
@@ -31,39 +30,54 @@ class Config:
# "crds/crd2"]
CLUSTER_KUBECONFIG_PATH = "artifacts/cluster_kubeconfig"
- ONAP_KUBECONFIG_PATH = "artifacts/onap_kubeconfig"
#### SERVICE DETAILS ####
+ NATIVE = True
+ SKIP_POST_INSTANTIATION = True
GLOBAL_CUSTOMER_ID = "customer_cnf"
VSPFILE = "vsp/vfw_k8s_demo.zip"
if NATIVE:
VSPFILE = "vsp/native_vfw_k8s_demo.zip"
+
+ PROFILE_NAME = "vfw-cnf-cds-base-profile"
+ PROFILE_SOURCE = PROFILE_NAME
+
VENDOR = "vendor_cnf"
SERVICENAME = "vfw_k8s_demo_CNF"
VSPNAME = "VSP_" + SERVICENAME
VFNAME = "VF_" + SERVICENAME
SERVICE_INSTANCE_NAME = "INSTANCE_" + SERVICENAME
SDNC_ARTIFACT_NAME = "vnf"
+
+ # INSERT PARAMS FOR VNF HERE AS "name" : "value" PAIR
+ VNF_PARAM_LIST = {}
+
VF_MODULE_PREFIX = ""
if NATIVE:
VF_MODULE_PREFIX = "helm_"
- VF_MODULE_LIST = {VF_MODULE_PREFIX + "base_template":
- {"name": VF_MODULE_PREFIX + "base_template",
- "k8s-rb-profile-name": "vfw-cnf-cds-base-profile",
- "k8s-rb-profile-namespace": K8S_NAMESPACE},
- VF_MODULE_PREFIX + "vfw":
- {"name": VF_MODULE_PREFIX + "vfw",
- "k8s-rb-profile-name": "vfw-cnf-cds-base-profile",
- "k8s-rb-profile-namespace": K8S_NAMESPACE},
- VF_MODULE_PREFIX + "vpkg":
- {"name": VF_MODULE_PREFIX + "vpkg",
- "k8s-rb-profile-name": "vfw-cnf-cds-base-profile",
- "k8s-rb-profile-namespace": K8S_NAMESPACE},
- VF_MODULE_PREFIX + "vsn":
- {"name": VF_MODULE_PREFIX + "vsn",
- "k8s-rb-profile-name": "vfw-cnf-cds-base-profile",
- "k8s-rb-profile-namespace": K8S_NAMESPACE}}
+ VF_MODULE_PARAM_LIST = {
+ VF_MODULE_PREFIX + "base_template": {
+ "k8s-rb-profile-name": PROFILE_NAME,
+ "k8s-rb-profile-source": PROFILE_SOURCE,
+ "k8s-rb-profile-namespace": K8S_NAMESPACE
+ },
+ VF_MODULE_PREFIX + "vfw": {
+ "k8s-rb-profile-name": PROFILE_NAME,
+ "k8s-rb-profile-source": PROFILE_SOURCE,
+ "k8s-rb-profile-namespace": K8S_NAMESPACE
+ },
+ VF_MODULE_PREFIX + "vpkg": {
+ "k8s-rb-profile-name": PROFILE_NAME,
+ "k8s-rb-profile-source": PROFILE_SOURCE,
+ "k8s-rb-profile-namespace": K8S_NAMESPACE
+ },
+ VF_MODULE_PREFIX + "vsn": {
+ "k8s-rb-profile-name": PROFILE_NAME,
+ "k8s-rb-profile-source": PROFILE_SOURCE,
+ "k8s-rb-profile-namespace": K8S_NAMESPACE
+ }
+ }
######## DEFAULT VALUES ########
OWNING_ENTITY = "OE-Demonstration"
diff --git a/heat/vFW_CNF_CDS/automation/instantiate.py b/heat/vFW_CNF_CDS/automation/instantiate.py
index fb461862..7363c479 100755
--- a/heat/vFW_CNF_CDS/automation/instantiate.py
+++ b/heat/vFW_CNF_CDS/automation/instantiate.py
@@ -143,10 +143,10 @@ for vnf in service.vnfs:
vf_module_label = vf_module.properties["vf_module_label"]
if vf_module_label == "base_template_dummy_ignore":
continue
- profile_name = Config.VF_MODULE_LIST[vf_module_label]["k8s-rb-profile-name"]
+ profile_name = Config.VF_MODULE_PARAM_LIST[vf_module_label]["k8s-rb-profile-name"]
try:
profile = definition.get_profile_by_name(profile_name)
- if profile.namespace != Config.VF_MODULE_LIST[vf_module_label]["k8s-rb-profile-namespace"]:
+ if profile.namespace != Config.VF_MODULE_PARAM_LIST[vf_module_label]["k8s-rb-profile-namespace"]:
profile.delete()
logger.info("Profile: " + profile_name + " for " + vf_module.name + " deleted")
else:
@@ -155,6 +155,7 @@ for vnf in service.vnfs:
except ValueError:
logger.info("Profile: " + profile_name + " for " + vf_module.name + " not found")
+
# Read SDNC MODEL NAME and VERSION from CBA.zip
logger.info("*******************************")
logger.info("Retrieving SDNC MODEL NAME and VERSION")
@@ -177,23 +178,32 @@ for se in service_subscription.service_instances:
if not service_instance:
logger.info("******** Service Instance not existing: Instantiate *******")
# Instantiate service
- vfmodules_list = Config.VF_MODULE_LIST
+ vfmodules_list = Config.VF_MODULE_PARAM_LIST
+ vnf_param_list = Config.VNF_PARAM_LIST
vnf_param = [
InstantiationParameter(name="sdnc_model_name", value=SDNC_MODEL_NAME),
InstantiationParameter(name="sdnc_model_version", value=SDNC_MODEL_VERSION),
InstantiationParameter(name="sdnc_artifact_name", value=Config.SDNC_ARTIFACT_NAME)]
+ for vnf_param_name, vnf_param_value in vnf_param_list.items():
+ vnf_param.append(
+ InstantiationParameter(name=vnf_param_name, value=vnf_param_value)
+ )
+
vfmodules_param = []
for vfmodule in vfmodules_list:
params = [
- InstantiationParameter(name="k8s-rb-profile-name", value=vfmodules_list[vfmodule]["k8s-rb-profile-name"]),
- InstantiationParameter(name="k8s-rb-profile-namespace", value=vfmodules_list[vfmodule]["k8s-rb-profile-namespace"]),
InstantiationParameter(name="sdnc_model_name", value=SDNC_MODEL_NAME),
InstantiationParameter(name="sdnc_model_version", value=SDNC_MODEL_VERSION),
- InstantiationParameter(name="vf_module_label", value=vfmodules_list[vfmodule]["name"])]
+ InstantiationParameter(name="vf_module_label", value=vfmodule)]
+
+ for vfmodule_param_name, vfmodule_param_value in vfmodules_list[vfmodule].items():
+ params.append(
+ InstantiationParameter(name=vfmodule_param_name, value=vfmodule_param_value)
+ )
- vfmodules_param.append(VfmoduleParameters(vfmodules_list[vfmodule]["name"], params))
+ vfmodules_param.append(VfmoduleParameters(vfmodule, params))
vnf_params = VnfParameters(name=Config.VFNAME, vnf_parameters=vnf_param, vfmodule_parameters=vfmodules_param)
diff --git a/heat/vFW_CNF_CDS/automation/onap_settings.py b/heat/vFW_CNF_CDS/automation/onap_settings.py
new file mode 100755
index 00000000..6580b49d
--- /dev/null
+++ b/heat/vFW_CNF_CDS/automation/onap_settings.py
@@ -0,0 +1,27 @@
+"""Global settings module.""" # pylint: disable=bad-whitespace
+# uncomment if socks is used
+#from onapsdk.onap_service import OnapService
+
+######################
+# #
+# ONAP SERVICES URLS #
+# #
+######################
+
+AAI_URL = "https://aai.api.sparky.simpledemo.onap.org:30233"
+AAI_API_VERSION = "v20"
+CDS_URL = "http://portal.api.simpledemo.onap.org:30449"
+MSB_URL = "https://msb.api.simpledemo.onap.org:30283"
+SDC_BE_URL = "https://sdc.api.be.simpledemo.onap.org:30204"
+SDC_FE_URL = "https://sdc.api.fe.simpledemo.onap.org:30207"
+SDNC_URL = "https://sdnc.api.simpledemo.onap.org:30267"
+SO_URL = "http://so.api.simpledemo.onap.org:30277"
+SO_API_VERSION = "v7"
+VID_URL = "https://vid.api.simpledemo.onap.org:30200"
+VID_API_VERSION = "/vid"
+CLAMP_URL = "https://clamp.api.simpledemo.onap.org:30258"
+VES_URL = "http://ves.api.simpledemo.onap.org:30417"
+DMAAP_URL = "http://dmaap.api.simpledemo.onap.org:3904"
+
+# uncomment if socks is used
+#OnapService.set_proxy({'http': 'socks5h://127.0.0.1:8081', 'https': 'socks5h://127.0.0.1:8081'})
diff --git a/heat/vFW_CNF_CDS/automation/onboard.py b/heat/vFW_CNF_CDS/automation/onboard.py
index c97b3510..0abd2660 100755
--- a/heat/vFW_CNF_CDS/automation/onboard.py
+++ b/heat/vFW_CNF_CDS/automation/onboard.py
@@ -1,5 +1,5 @@
# ============LICENSE_START=======================================================
-# Copyright (C) 2020 Orange
+# Copyright (C) 2021 Orange
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@ from io import BytesIO
import oyaml as yaml
from config import Config
-from onapsdk.sdc.properties import Property
+import onapsdk.constants as const
from onapsdk.sdc.vendor import Vendor
from onapsdk.sdc.vsp import Vsp
@@ -67,18 +67,35 @@ vsp = Vsp(name=Config.VSPNAME, vendor=vendor, package=open(myvspfile, 'rb'))
vsp.onboard()
logger.info("******** Onboard VF *******")
-vf = Vf(name=Config.VFNAME, properties=[
- Property(name="sdnc_model_name", property_type="string", value=SDNC_MODEL_NAME),
- Property(name="sdnc_model_version", property_type="string", value=SDNC_MODEL_VERSION),
- Property(name="sdnc_artifact_name", property_type="string", value=Config.SDNC_ARTIFACT_NAME)
-]
- )
+vf = Vf(name=Config.VFNAME)
vf.vsp = vsp
+vf.create()
vf.onboard()
logger.info("******** Onboard Service *******")
-svc = Service(name=Config.SERVICENAME, resources=[vf], instantiation_type=ServiceInstantiationType.MACRO)
-svc.onboard()
+svc = Service(name=Config.SERVICENAME,
+ instantiation_type=ServiceInstantiationType.MACRO)
+svc.create()
+
+if svc.status == const.DRAFT:
+ svc.add_resource(vf)
+
+ logger.info("******** Set SDNC properties for VF ********")
+ component = svc.get_component(vf)
+ prop = component.get_property("sdnc_model_version")
+ prop.value = SDNC_MODEL_VERSION
+ prop = component.get_property("sdnc_artifact_name")
+ prop.value = Config.SDNC_ARTIFACT_NAME
+ prop = component.get_property("sdnc_model_name")
+ prop.value = SDNC_MODEL_NAME
+ prop = component.get_property("controller_actor")
+ prop.value = "CDS"
+ prop = component.get_property("skip_post_instantiation_configuration")
+ prop.value = Config.SKIP_POST_INSTANTIATION
+
+ logger.info("******** Onboard Service *******")
+ svc.checkin()
+ svc.onboard()
logger.info("******** Check Service Distribution *******")
distribution_completed = False
diff --git a/heat/vFW_CNF_CDS/automation/so_db_adapter.py b/heat/vFW_CNF_CDS/automation/so_db_adapter.py
index a829fbda..621decb1 100755
--- a/heat/vFW_CNF_CDS/automation/so_db_adapter.py
+++ b/heat/vFW_CNF_CDS/automation/so_db_adapter.py
@@ -15,78 +15,81 @@
#
# ============LICENSE_END=========================================================
-import base64
-import os
+from abc import ABC
+from onapsdk.so.so_element import SoElement
+from onapsdk.onap_service import OnapService
+from onapsdk.utils.headers_creator import headers_so_creator
-from kubernetes import config, client
-from kubernetes.stream import stream
+class SoDBUpdate(SoElement, ABC):
-class SoDBAdapter:
+ @classmethod
+ def add_region_to_so_db(cls,
+ cloud_region_id: str,
+ complex_id: str,
+ identity_service_id: str = None,
+ **kwargs
+ ):
+ """Method to add cloud_site data with identity_service to SO db.
- def __init__(self, cloud_region_id, complex_id, onap_kubeconfig_path):
- self.CLOUD_REGION_ID = cloud_region_id
- self.COMPLEX_ID = complex_id
- self.ONAP_KUBECONFIG_PATH = onap_kubeconfig_path
- self.MYPATH = os.path.dirname(os.path.realpath(__file__))
+ Args:
+ cloud_region_id: the name of cloud region
+ complex_id: name of complex
+ identity_service_id: optional - id of identity service
+ **kwargs: keyword arguments with parameters for identity service creation, like below
- config.load_kube_config(config_file=os.path.join(self.MYPATH, self.ONAP_KUBECONFIG_PATH))
- self.api_instance = client.CoreV1Api()
- self.pod_name = self.get_mariadb_pod_name()
- self.password = self.get_mariadb_root_username_password()
+ Important:
+ identity_services data will be overwrite, but in the same time
+ cloud_sites data will not (shouldn't) be overwrite!
- def get_mariadb_pod_name(self):
- pods = self.api_instance.list_namespaced_pod(namespace="onap")
- for pod in pods.items:
- if pod.metadata.name.find("mariadb-galera-0") != -1:
- return pod.metadata.name
+ Return:
+ response object
+ """
- def get_mariadb_root_username_password(self):
- secrets = self.api_instance.list_namespaced_secret(namespace="onap")
- for secret in secrets.items:
- if secret.metadata.name.find("mariadb-galera-db-root-password") != -1:
- base64_password = secret.data["password"]
- base64_bytes = base64_password.encode('ascii')
- password_bytes = base64.b64decode(base64_bytes)
+ if not identity_service_id:
+ identity_service_id = 'Keystone_K8s'
- return password_bytes.decode('ascii')
+ # params for identity_service creation
+ orchestrator = kwargs.get('orchestrator', 'multicloud')
+ identity_url = kwargs.get('identity_url', "http://1.2.3.4:5000/v2.0")
+ mso_id = kwargs.get('mso_id', 'onapsdk_user')
+ mso_pass = kwargs.get('mso_pass', 'mso_pass_onapsdk')
+ project_domain_name = kwargs.get("project_domain_name", None)
+ user_domain_name = kwargs.get("user_domain_name", None)
+ member_role = kwargs.get('member_role', 'admin')
+ admin_tenant = kwargs.get('admin_tenant', 'service')
+ identity_server_type = kwargs.get('identity_server_type', 'KEYSTONE')
+ identity_authentication_type = kwargs.get('identity_authentication_type', 'USERNAME_PASSWORD')
- def run_exec_request(self, exec_command):
- response = stream(self.api_instance.connect_get_namespaced_pod_exec,
- name=self.pod_name,
- # container="container-name",
- namespace="onap",
- command=exec_command,
- stdin=False,
- tty=False,
- stderr=True,
- stdout=True)
- return response
-
- def check_region_in_db(self):
- exec_command = [
- "/bin/sh",
- "-c",
- f"mysql -uroot -p{self.password} catalogdb -e 'SELECT * FROM cloud_sites;'"]
- response = self.run_exec_request(exec_command)
-
- is_region_found = False
- for line in response.split("\n"):
- if line.split("\t")[0] == self.CLOUD_REGION_ID:
- print(line)
- is_region_found = True
- return is_region_found
- return is_region_found
-
- def add_region_to_so_db(self):
- exec_command = [
- "/bin/sh",
- "-c",
- f"mysql -uroot -p{self.password} catalogdb -e "
- f"'insert into cloud_sites(ID, REGION_ID, IDENTITY_SERVICE_ID, CLOUD_VERSION, CLLI, ORCHESTRATOR ) "
- f"values (\"{self.CLOUD_REGION_ID}\", \"{self.CLOUD_REGION_ID}\", \"DEFAULT_KEYSTONE\", \"2.5\", "
- f"\"{self.COMPLEX_ID}\", \"multicloud\");'"]
+ data = {
+ "id": cloud_region_id,
+ "region_id": cloud_region_id,
+ "aic_version": "2.5",
+ "clli": complex_id,
+ "orchestrator": orchestrator,
+ "identityService": {
+ "id": identity_service_id,
+ "identityServerTypeAsString": "KEYSTONE",
+ "hibernateLazyInitializer": {},
+ "identity_url": identity_url,
+ "mso_id": mso_id,
+ "mso_pass": mso_pass,
+ "project_domain_name": project_domain_name,
+ "user_domain_name": user_domain_name,
+ "admin_tenant": admin_tenant,
+ "member_role": member_role,
+ "tenant_metadata": True,
+ "identity_server_type": identity_server_type,
+ "identity_authentication_type": identity_authentication_type
+ }
+ }
- response = self.run_exec_request(exec_command)
+ response = cls.send_message(
+ "POST",
+ "Create a region in SO db",
+ f"{cls.base_url}/cloudSite",
+ json=data,
+ headers=headers_so_creator(OnapService.headers),
+ exception=ValueError)
return response
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 5f3a2c09..b5697555 100644
--- a/heat/vFW_CNF_CDS/templates/cba/Definitions/data_types.json
+++ b/heat/vFW_CNF_CDS/templates/cba/Definitions/data_types.json
@@ -1,33 +1,9 @@
{
"data_types": {
- "dt-config-deploy-properties": {
- "description": "Dynamic DataType definition for workflow(config-deploy).",
+ "dt-config-assign-properties": {
+ "description": "Dynamic DataType definition for workflow(config-assign).",
"version": "1.0.0",
"properties": {
- "vpg_onap_private_ip_0": {
- "description": "",
- "required": false,
- "type": "string",
- "status": "",
- "constraints": [
- {}
- ],
- "entry_schema": {
- "type": ""
- }
- },
- "vnf-id": {
- "description": "",
- "required": false,
- "type": "string",
- "status": "",
- "constraints": [
- {}
- ],
- "entry_schema": {
- "type": ""
- }
- },
"service-instance-id": {
"description": "",
"required": false,
@@ -39,20 +15,15 @@
"entry_schema": {
"type": ""
}
- },
- "active-streams": {
- "description": "",
- "required": false,
- "type": "string",
- "status": "",
- "constraints": [
- {}
- ],
- "entry_schema": {
- "type": ""
- }
- },
- "put-active-streams": {
+ }
+ },
+ "derived_from": "tosca.datatypes.Dynamic"
+ },
+ "dt-config-deploy-properties": {
+ "description": "Dynamic DataType definition for workflow(config-deploy).",
+ "version": "1.0.0",
+ "properties": {
+ "service-instance-id": {
"description": "",
"required": false,
"type": "string",
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 60846f6c..9053c9b2 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
@@ -98,30 +98,51 @@
}
}
},
+ "config-assign": {
+ "steps": {
+ "config-assign": {
+ "description": "Create a message",
+ "target": "config-assign-process",
+ "activities": [
+ {
+ "call_operation": ""
+ }
+ ]
+ }
+ },
+ "inputs": {
+ "resolution-key": {
+ "required": true,
+ "type": "string"
+ },
+ "store-result": {
+ "required": true,
+ "type": "boolean"
+ },
+ "config-assign-properties": {
+ "description": "Dynamic PropertyDefinition for workflow(config-assign).",
+ "required": true,
+ "type": "dt-config-assign-properties"
+ }
+ }
+ },
"config-deploy": {
"steps": {
"config-deploy": {
- "description": "Config Deploy Workflow",
+ "description": "Run kotlin script",
"target": "config-deploy-process"
}
},
"inputs": {
+ "resolution-key": {
+ "required": true,
+ "type": "string"
+ },
"config-deploy-properties": {
"description": "Dynamic PropertyDefinition for workflow(config-deploy).",
"required": true,
"type": "dt-config-deploy-properties"
}
- },
- "outputs": {
- "dry-run": {
- "type": "json",
- "value": {
- "get_attribute": [
- "config-deploy-process",
- "assignment-params"
- ]
- }
- }
}
}
},
@@ -220,29 +241,58 @@
}
}
},
- "config-deploy-process": {
+ "config-assign-process": {
"type": "component-resource-resolution",
"interfaces": {
"ResourceResolutionComponent": {
"operations": {
"process": {
"inputs": {
+ "resolution-key": {
+ "get_input": "resolution-key"
+ },
+ "store-result": true,
"artifact-prefix-names": [
- "nf-params"
+ "cnf"
]
+ },
+ "outputs": {
+ "resource-assignment-params": {
+ "get_attribute": [
+ "SELF",
+ "assignment-params"
+ ]
+ },
+ "status": "success"
}
}
}
}
},
"artifacts": {
- "nf-params-template": {
+ "cnf-template": {
"type": "artifact-template-velocity",
- "file": "Templates/nf-params-template.vtl"
+ "file": "Templates/cnf-template.vtl"
},
- "nf-params-mapping": {
+ "cnf-mapping": {
"type": "artifact-mapping-resource",
- "file": "Templates/nf-params-mapping.json"
+ "file": "Templates/cnf-mapping.json"
+ }
+ }
+ },
+ "config-deploy-process": {
+ "type": "component-script-executor",
+ "interfaces": {
+ "ComponentScriptExecutor": {
+ "operations": {
+ "process": {
+ "inputs": {
+ "script-type": "kotlin",
+ "script-class-reference": "org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts.ConfigDeploy",
+ "dynamic-properties": "*config-deploy-properties"
+ }
+ }
+ }
}
}
}
diff --git a/heat/vFW_CNF_CDS/templates/cba/Scripts/kotlin/ConfigDeploy.kt b/heat/vFW_CNF_CDS/templates/cba/Scripts/kotlin/ConfigDeploy.kt
new file mode 100644
index 00000000..c4849601
--- /dev/null
+++ b/heat/vFW_CNF_CDS/templates/cba/Scripts/kotlin/ConfigDeploy.kt
@@ -0,0 +1,59 @@
+/*
+ * Copyright © 2020 Aarna Networks, Inc.
+ *
+ * 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 org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.storedContentFromResolvedArtifactNB
+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.services.execution.AbstractScriptComponentFunction
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+import org.slf4j.LoggerFactory
+import org.springframework.http.HttpMethod
+import org.springframework.web.client.RestTemplate
+
+open class ConfigDeploy : AbstractScriptComponentFunction() {
+
+ private val log = LoggerFactory.getLogger(ConfigDeploy::class.java)!!
+
+ override suspend fun processNB(executionRequest: ExecutionServiceInput) {
+
+ /*
+ * Resolution key will come as part of config-deploy request payload.
+ */
+
+ val resolution_key = getDynamicProperties("resolution-key").asText()
+ log.info("Got the resolution_key: $resolution_key from config-deploy going to retrive the data from DB")
+
+ // Read the config-assing data using the resolution key + prefix name for the template
+ // We can select the given configuration using the resolution_key
+ val prefix = "cnf"
+ val payload = storedContentFromResolvedArtifactNB(resolution_key, prefix)
+ log.info("cnf configuration data from DB : \n$payload\n")
+
+ println("Run config-deploy")
+ println("$payload")
+
+ }
+
+ override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
+ log.info("Executing Recovery")
+ }
+}
diff --git a/heat/vFW_CNF_CDS/templates/cba/Templates/cnf-mapping.json b/heat/vFW_CNF_CDS/templates/cba/Templates/cnf-mapping.json
new file mode 100644
index 00000000..4e012f95
--- /dev/null
+++ b/heat/vFW_CNF_CDS/templates/cba/Templates/cnf-mapping.json
@@ -0,0 +1,22 @@
+[
+ {
+ "name": "service-instance-id",
+ "property": {
+ "description": "",
+ "required": false,
+ "type": "string",
+ "status": "",
+ "constraints": [
+ {}
+ ],
+ "entry_schema": {
+ "type": ""
+ }
+ },
+ "input-param": false,
+ "dictionary-name": "service-instance-id",
+ "dictionary-source": "input",
+ "dependencies": [],
+ "version": 0
+ }
+]
diff --git a/heat/vFW_CNF_CDS/templates/cba/Templates/cnf-template.vtl b/heat/vFW_CNF_CDS/templates/cba/Templates/cnf-template.vtl
new file mode 100644
index 00000000..459d3c3a
--- /dev/null
+++ b/heat/vFW_CNF_CDS/templates/cba/Templates/cnf-template.vtl
@@ -0,0 +1,3 @@
+{
+ "config deploy results for cnf service instance" : "${service-instance-id}"
+}