diff options
author | Lukasz Rajewski <lukasz.rajewski@orange.com> | 2021-03-24 19:15:31 +0100 |
---|---|---|
committer | Lukasz Rajewski <lukasz.rajewski@orange.com> | 2021-03-28 22:21:25 +0200 |
commit | 06bf0ac45889ffe00fc6e27e68ffa15c2f519e6f (patch) | |
tree | ecf4c17542c62ee6c0433edcbccac5707370a8f1 /heat/vFW_CNF_CDS/automation | |
parent | d2c5f361fa3a246dfa23c2c582ec498322a97282 (diff) |
Real vFW CNF config-assign and config-deploy
Implementation of vFW CNF config-assign and config-deploy with
utilization of CDS native components for configuration API
Change-Id: I016b186e1fcad0bf1285292f2e93e12a1d96b63e
Issue-ID: INT-1868
Signed-off-by: Lukasz Rajewski <lukasz.rajewski@orange.com>
Diffstat (limited to 'heat/vFW_CNF_CDS/automation')
-rwxr-xr-x | heat/vFW_CNF_CDS/automation/config.py | 17 | ||||
-rw-r--r--[-rwxr-xr-x] | heat/vFW_CNF_CDS/automation/create_k8s_region.py | 15 | ||||
-rwxr-xr-x | heat/vFW_CNF_CDS/automation/instantiate.py | 7 |
3 files changed, 23 insertions, 16 deletions
diff --git a/heat/vFW_CNF_CDS/automation/config.py b/heat/vFW_CNF_CDS/automation/config.py index 96b098dd..a7aae02c 100755 --- a/heat/vFW_CNF_CDS/automation/config.py +++ b/heat/vFW_CNF_CDS/automation/config.py @@ -19,10 +19,10 @@ class Config: #### REGION DETAILS #### COMPLEX_ID = "complex" CLOUD_OWNER = "k8sCloudOwner" - CLOUD_REGION = "k8s-region-1" + CLOUD_REGION = "kud-1" AVAILABILITY_ZONE_NAME = "k8s-availability-zone" HYPERVISOR_TYPE = "k8s" - TENANT_NAME = "k8s-tenant-1" + TENANT_NAME = "kud-1" K8S_NAMESPACE = "vfirewall" CUSTOMER_RESOURCE_DEFINITIONS = [] # Uncomment, if you want to run on non KUD k8s cluster @@ -41,6 +41,7 @@ class Config: PROFILE_NAME = "vfw-cnf-cds-base-profile" PROFILE_SOURCE = PROFILE_NAME + RELEASE_NAME = "vfw-1" VENDOR = "vendor_cnf" SERVICENAME = "vfw_k8s_demo_CNF" @@ -50,7 +51,9 @@ class Config: SDNC_ARTIFACT_NAME = "vnf" # INSERT PARAMS FOR VNF HERE AS "name" : "value" PAIR - VNF_PARAM_LIST = {} + VNF_PARAM_LIST = { + "k8s-rb-profile-namespace": K8S_NAMESPACE + } VF_MODULE_PREFIX = "" if NATIVE: @@ -60,22 +63,22 @@ class Config: VF_MODULE_PREFIX + "base_template": { "k8s-rb-profile-name": PROFILE_NAME, "k8s-rb-profile-source": PROFILE_SOURCE, - "k8s-rb-profile-namespace": K8S_NAMESPACE + "k8s-rb-instance-release-name": RELEASE_NAME + "-base" }, VF_MODULE_PREFIX + "vfw": { "k8s-rb-profile-name": PROFILE_NAME, "k8s-rb-profile-source": PROFILE_SOURCE, - "k8s-rb-profile-namespace": K8S_NAMESPACE + "k8s-rb-instance-release-name": RELEASE_NAME + "-vfw" }, VF_MODULE_PREFIX + "vpkg": { "k8s-rb-profile-name": PROFILE_NAME, "k8s-rb-profile-source": PROFILE_SOURCE, - "k8s-rb-profile-namespace": K8S_NAMESPACE + "k8s-rb-instance-release-name": RELEASE_NAME + "-vpkg" }, VF_MODULE_PREFIX + "vsn": { "k8s-rb-profile-name": PROFILE_NAME, "k8s-rb-profile-source": PROFILE_SOURCE, - "k8s-rb-profile-namespace": K8S_NAMESPACE + "k8s-rb-instance-release-name": RELEASE_NAME + "-vsn" } } diff --git a/heat/vFW_CNF_CDS/automation/create_k8s_region.py b/heat/vFW_CNF_CDS/automation/create_k8s_region.py index cfbec8cc..ca680cf1 100755..100644 --- a/heat/vFW_CNF_CDS/automation/create_k8s_region.py +++ b/heat/vFW_CNF_CDS/automation/create_k8s_region.py @@ -21,7 +21,7 @@ from uuid import uuid4 from config import Config from k8s_client import K8sClient -from so_db_adapter import SoDBAdapter +from so_db_adapter import SoDBUpdate from onapsdk.aai.business import Customer from onapsdk.aai.cloud_infrastructure import Complex, CloudRegion from onapsdk.msb.k8s import ConnectivityInfo @@ -118,10 +118,9 @@ except: #### Add region to SO db #### logger.info("******** SO Database *******") -so_db_adapter = SoDBAdapter(cloud_region_id=Config.CLOUD_REGION, - complex_id=Config.COMPLEX_ID, - onap_kubeconfig_path=Config.ONAP_KUBECONFIG_PATH) -is_region_in_so = so_db_adapter.check_region_in_db() - -if not is_region_in_so: - so_db_adapter.add_region_to_so_db() +result = SoDBUpdate.add_region_to_so_db(cloud_region_id=Config.CLOUD_REGION, + complex_id=Config.COMPLEX_ID) +if result.status_code == 201: + logger.info("Region in SO db created successfully") +else: + logger.error("Creating region in SO db failed") diff --git a/heat/vFW_CNF_CDS/automation/instantiate.py b/heat/vFW_CNF_CDS/automation/instantiate.py index 7363c479..bfc68aa1 100755 --- a/heat/vFW_CNF_CDS/automation/instantiate.py +++ b/heat/vFW_CNF_CDS/automation/instantiate.py @@ -146,7 +146,12 @@ for vnf in service.vnfs: 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_PARAM_LIST[vf_module_label]["k8s-rb-profile-namespace"]: + namespace = None + if "k8s-rb-profile-namespace" in Config.VNF_PARAM_LIST: + namespace = Config.VNF_PARAM_LIST["k8s-rb-profile-namespace"] + if "k8s-rb-profile-namespace" in Config.VF_MODULE_PARAM_LIST[vf_module_label]: + namespace = Config.VF_MODULE_PARAM_LIST[vf_module_label]["k8s-rb-profile-namespace"] + if namespace != None and profile.namespace != namespace: profile.delete() logger.info("Profile: " + profile_name + " for " + vf_module.name + " deleted") else: |