Fixed issue of subscription name for pnf macro 92/137192/1
authorLukasz Rajewski <lukasz.rajewski@t-mobile.pl>
Thu, 8 Feb 2024 15:27:34 +0000 (16:27 +0100)
committerLukasz Rajewski <lukasz.rajewski@t-mobile.pl>
Thu, 8 Feb 2024 15:28:17 +0000 (16:28 +0100)
Fixed issue of subscription name for pnf macro

Issue-ID: TEST-404
Signed-off-by: Lukasz Rajewski <lukasz.rajewski@t-mobile.pl>
Change-Id: Ib32763b8e5922c71bbd10f680e5a00d52fddcda2

src/onaptests/configuration/pnf_macro_settings.py

index e568ec3..7ce67a0 100644 (file)
@@ -1,6 +1,9 @@
 from pathlib import Path
 from uuid import uuid4
 
+from yaml import SafeLoader, load
+
+import onaptests.utils.exceptions as onap_test_exceptions
 from onaptests.utils.resources import get_resource_location
 
 from .settings import *  # noqa
@@ -10,14 +13,22 @@ CLEANUP_FLAG = True
 USE_MULTICLOUD = False
 
 VENDOR_NAME = "pnf_macro_vendor"
-SERVICE_NAME = "test_pnf_macro"
 SERVICE_DETAILS = "Onboarding, distribution and registration of PNF using macro"
 SERVICE_INSTANCE_NAME = "TestPNFMacroInstantiation"
+
 SERVICE_YAML_TEMPLATE = Path(get_resource_location("templates/vnf-services/pnf-service.yaml"))
 generate_service_config_yaml_file(service_name="pnf_macro",  # noqa
                                   service_template="pnf-service.yaml.j2",
                                   service_config=SERVICE_YAML_TEMPLATE)
 
+try:
+    # Try to retrieve the SERVICE NAME from the yaml file
+    with open(SERVICE_YAML_TEMPLATE, "r", encoding="utf-8") as yaml_template:
+        yaml_config_file = load(yaml_template, SafeLoader)
+        SERVICE_NAME = next(iter(yaml_config_file.keys()))
+except (FileNotFoundError, ValueError) as exc:
+    raise onap_test_exceptions.TestConfigurationException from exc
+
 CDS_DD_FILE = Path(get_resource_location("templates/artifacts/dd.json"))
 CDS_CBA_UNENRICHED = Path(get_resource_location("templates/artifacts/PNF_DEMO.zip"))
 CDS_CBA_ENRICHED = "/tmp/PNF_DEMO_enriched.zip"