Consider SERVICE_NAME from the yaml file 25/112625/1
authormrichomme <morgan.richomme@orange.com>
Mon, 14 Sep 2020 15:29:57 +0000 (17:29 +0200)
committermrichomme <morgan.richomme@orange.com>
Mon, 14 Sep 2020 15:29:57 +0000 (17:29 +0200)
avoid duplication in yaml and settings
if not defined in Yaml, possibility to set it up manually

Issue-ID: TEST-240

Signed-off-by: mrichomme <morgan.richomme@orange.com>
Change-Id: Ib005eaea78e109b6917f2a09ae04ce0c2c511660

run_basicvm_nomulticloud.py
src/onaptests/configuration/ubuntu16_nomulticloud_settings.py [moved from src/onaptests/configuration/ubuntu16_nomulticloud_noyaml_settings.py with 81% similarity]

index e7f63c0..03246cc 100644 (file)
@@ -1,24 +1,13 @@
-# import logging
+import logging.config
+from onapsdk.configuration import settings
+from onaptests.steps.instantiate.vf_module_ala_carte import YamlTemplateVfModuleAlaCarteInstantiateStep
 
-from onaptests.steps.instantiate.module import ModuleInstantiateStep
-
-# from onapsdk.sdc.vendor import Vendor
-
-
-# Configure logging
-# logger = logging.getLogger("")
-# logger.setLevel(logging.INFO)
-# fh = logging.StreamHandler()
-# fh_formatter = logging.Formatter(
-#     "%(asctime)s %(levelname)s %(name)s %(lineno)d:%(filename)s(%(process)d) - %(message)s"
-# )
-# fh.setFormatter(fh_formatter)
-# logger.addHandler(fh)
-# Vendor.set_proxy({ 'http': 'socks5h://127.0.0.1:8083', 'https': 'socks5h://127.0.0.1:8083'})
 
 
 if __name__ == "__main__":
-    basic_vm_instantiate = ModuleInstantiateStep()
+    # logging configuration for onapsdk, it is not requested for onaptests
+    # Correction requested in onapsdk to avoid having this duplicate code
+    logging.config.dictConfig(settings.LOG_CONFIG)
+
+    basic_vm_instantiate = YamlTemplateVfModuleAlaCarteInstantiateStep()
     basic_vm_instantiate.execute()
-    # service_onboard = YamlTemplateServiceOnboardStep()
-    # service_onboard.execute()
@@ -1,5 +1,6 @@
 import os
 import openstack
+from yaml import load
 
 from .settings import * # pylint: disable=W0614
 
@@ -8,10 +9,18 @@ from .settings import * # pylint: disable=W0614
 # pylint: disable=bad-whitespace
 # The ONAP part
 USE_MULTICLOUD = False
+SERVICE_YAML_TEMPLATE = "templates/vnf-services/ubuntu16test-service.yaml"
 
 VENDOR_NAME = "basicvm_vendor"
 VSP_NAME = "basicvm_ubuntu_vsp"
-SERVICE_NAME = "basicvm-ubuntu-service"
+try:
+    # Try to retrieve the SERVICE NAME from the yaml file
+    with open(SERVICE_YAML_TEMPLATE, "r") as yaml_template:
+        yaml_config_file = load(yaml_template)
+        SERVICE_NAME = next(iter(yaml_config_file.keys()))
+except ValueError:
+    SERVICE_NAME = "" # Fill me
+
 VF_NAME = "basicvm_ubuntu_vf"
 
 CLOUD_REGION_CLOUD_OWNER = "basicvm-cloud-owner"
@@ -30,10 +39,11 @@ PROJECT = "basicvm-project"
 LINE_OF_BUSINESS = "basicvm-lob"
 PLATFORM = "basicvm-platform"
 
-SERVICE_INSTANCE_NAME = "basicvm_ubuntu16_service_instance"
+SERVICE_INSTANCE_NAME = "basicvm_ubuntu16_service_instance_3"
 
 VSP_FILE_PATH = "templates/heat_files/ubuntu16/ubuntu16.zip"
 
+
 # The cloud Part
 # Assuming a cloud.yaml is available, use the openstack client
 # to retrieve cloud info and avoid data duplication