[OSDF] Enable OSDF in ServiceMesh deployment 55/131755/21
authorAndreas Geissler <andreas-geissler@telekom.de>
Mon, 24 Oct 2022 12:26:35 +0000 (14:26 +0200)
committerLukasz Rajewski <lukasz.rajewski@t-mobile.pl>
Wed, 15 Feb 2023 21:27:49 +0000 (22:27 +0100)
In case AAF is disabled the secret loading via AAF-SMS should not be called

Issue-ID: OPTFRA-1099

Signed-off-by: Andreas Geissler <andreas-geissler@telekom.de>
Signed-off-by: Lukasz Rajewski <lukasz.rajewski@t-mobile.pl>
Change-Id: Ifca03215a36705b1c160b2cbf708389bd2162301

config/opteng_config.yaml
csit/scripts/simulator_script.sh
osdf/adapters/aaf/sms.py
pom.xml
requirements-opteng.txt
requirements-sim.txt [new file with mode: 0644]
test/functest/simulators/build_sim_image.sh
test/functest/simulators/simulated-config/opteng_config.yaml
test/functest/simulators/start_sim.sh
version.properties

index d6be7ed..6b61eb0 100755 (executable)
@@ -22,4 +22,4 @@ osdfDatabasePassword: osdf
 osdfDatabasePort: 3306
 
 #key
-appkey: os35@rrtky400fdntc#001t5
\ No newline at end of file
+appkey: os35@rrtky400fdntc#001t5
index e146cb9..f6daab6 100755 (executable)
@@ -44,9 +44,20 @@ chmod +x ./build_sim_image.sh
 # run osdf_sim
 docker run -d --name osdf_sim -p "5000:5000"  osdf_sim:latest;
 
+#wait for docker setup a while
+sleep 10
+
+docker ps -a
+
+echo "logs of the osdf_sim"
+sudo cat `docker inspect -f '{{.LogPath}}' osdf_sim`
+
+
 OSDF_SIM_IP=`${WORKSPACE}/scripts/get-instance-ip.sh osdf_sim`
 echo "OSDF_SIM_IP=${OSDF_SIM_IP}"
 
+docker inspect osdf_sim
+
 ${WORKSPACE}/scripts/wait_for_port.sh ${OSDF_SIM_IP} 5000
 
 
@@ -54,5 +65,4 @@ ${WORKSPACE}/scripts/wait_for_port.sh ${OSDF_SIM_IP} 5000
 sleep 2
 
 echo "inspect docker things for tracing purpose"
-docker inspect osdf_sim
 
index bcc449c..031fee4 100644 (file)
@@ -23,9 +23,9 @@
 from onapsmsclient import Client
 
 import osdf.config.base as cfg_base
+from osdf.config.base import osdf_config
 import osdf.config.credentials as creds
 import osdf.config.loader as config_loader
-from osdf.config.base import osdf_config
 from osdf.logging.osdf_logging import debug_log
 from osdf.utils import cipherUtils
 
@@ -35,9 +35,12 @@ config_spec = {
 
 
 def preload_secrets():
-    """ This is intended to load the secrets required for testing Application
-        Actual deployment will have a preload script. Make sure the config is
-        in sync"""
+    """preload_secrets()
+
+    This is intended to load the secrets required for testing Application
+    Actual deployment will have a preload script. Make sure the config is
+    in sync
+    """
     preload_config = config_loader.load_config_file(
         config_spec.get("preload_secrets"))
     domain = preload_config.get("domain")
@@ -45,6 +48,9 @@ def preload_secrets():
     sms_url = config["aaf_sms_url"]
     timeout = config["aaf_sms_timeout"]
     cacert = config["aaf_ca_certs"]
+    if not sms_url:
+        debug_log.debug("SMS Disabled")
+        return
     sms_client = Client(url=sms_url, timeout=timeout, cacert=cacert)
     domain_uuid = sms_client.createDomain(domain)
     debug_log.debug(
@@ -64,46 +70,50 @@ def retrieve_secrets():
     timeout = config["aaf_sms_timeout"]
     cacert = config["aaf_ca_certs"]
     domain = config["secret_domain"]
-    sms_client = Client(url=sms_url, timeout=timeout, cacert=cacert)
-    secrets = sms_client.getSecretNames(domain)
-    for secret in secrets:
-        values = sms_client.getSecret(domain, secret)
-        secret_dict[secret] = values
-    debug_log.debug("Secret Dictionary Retrieval Success")
+    if sms_url:
+        sms_client = Client(url=sms_url, timeout=timeout, cacert=cacert)
+        secrets = sms_client.getSecretNames(domain)
+        for secret in secrets:
+            values = sms_client.getSecret(domain, secret)
+            secret_dict[secret] = values
+        debug_log.debug("Secret Dictionary Retrieval Success")
+    else:
+        debug_log.debug("SMS Disabled. Secrets not loaded")
     return secret_dict
 
 
 def load_secrets():
     config = osdf_config.deployment
     secret_dict = retrieve_secrets()
-    config['soUsername'] = secret_dict['so']['UserName']
-    config['soPassword'] = decrypt_pass(secret_dict['so']['Password'])
-    config['conductorUsername'] = secret_dict['conductor']['UserName']
-    config['conductorPassword'] = decrypt_pass(secret_dict['conductor']['Password'])
-    config['policyPlatformUsername'] = secret_dict['policyPlatform']['UserName']
-    config['policyPlatformPassword'] = decrypt_pass(secret_dict['policyPlatform']['Password'])
-    config['policyClientUsername'] = secret_dict['policyPlatform']['UserName']
-    config['policyClientPassword'] = decrypt_pass(secret_dict['policyPlatform']['Password'])
-    config['messageReaderAafUserId'] = secret_dict['dmaap']['UserName']
-    config['messageReaderAafPassword'] = decrypt_pass(secret_dict['dmaap']['Password'])
-    config['sdcUsername'] = secret_dict['sdc']['UserName']
-    config['sdcPassword'] = decrypt_pass(secret_dict['sdc']['Password'])
-    config['osdfPlacementUsername'] = secret_dict['osdfPlacement']['UserName']
-    config['osdfPlacementPassword'] = decrypt_pass(secret_dict['osdfPlacement']['Password'])
-    config['osdfPlacementSOUsername'] = secret_dict['osdfPlacementSO']['UserName']
-    config['osdfPlacementSOPassword'] = decrypt_pass(secret_dict['osdfPlacementSO']['Password'])
-    config['osdfPlacementVFCUsername'] = secret_dict['osdfPlacementVFC']['UserName']
-    config['osdfPlacementVFCPassword'] = decrypt_pass(secret_dict['osdfPlacementVFC']['Password'])
-    config['osdfCMSchedulerUsername'] = secret_dict['osdfCMScheduler']['UserName']
-    config['osdfCMSchedulerPassword'] = decrypt_pass(secret_dict['osdfCMScheduler']['Password'])
-    config['configDbUserName'] = secret_dict['configDb']['UserName']
-    config['configDbPassword'] = decrypt_pass(secret_dict['configDb']['Password'])
-    config['pciHMSUsername'] = secret_dict['pciHMS']['UserName']
-    config['pciHMSPassword'] = decrypt_pass(secret_dict['pciHMS']['Password'])
-    config['osdfPCIOptUsername'] = secret_dict['osdfPCIOpt']['UserName']
-    config['osdfPCIOptPassword'] = decrypt_pass(secret_dict['osdfPCIOpt']['Password'])
-    config['osdfOptEngineUsername'] = secret_dict['osdfOptEngine']['UserName']
-    config['osdfOptEnginePassword'] = decrypt_pass(secret_dict['osdfOptEngine']['Password'])
+    if secret_dict:
+        config['soUsername'] = secret_dict['so']['UserName']
+        config['soPassword'] = decrypt_pass(secret_dict['so']['Password'])
+        config['conductorUsername'] = secret_dict['conductor']['UserName']
+        config['conductorPassword'] = decrypt_pass(secret_dict['conductor']['Password'])
+        config['policyPlatformUsername'] = secret_dict['policyPlatform']['UserName']
+        config['policyPlatformPassword'] = decrypt_pass(secret_dict['policyPlatform']['Password'])
+        config['policyClientUsername'] = secret_dict['policyPlatform']['UserName']
+        config['policyClientPassword'] = decrypt_pass(secret_dict['policyPlatform']['Password'])
+        config['messageReaderAafUserId'] = secret_dict['dmaap']['UserName']
+        config['messageReaderAafPassword'] = decrypt_pass(secret_dict['dmaap']['Password'])
+        config['sdcUsername'] = secret_dict['sdc']['UserName']
+        config['sdcPassword'] = decrypt_pass(secret_dict['sdc']['Password'])
+        config['osdfPlacementUsername'] = secret_dict['osdfPlacement']['UserName']
+        config['osdfPlacementPassword'] = decrypt_pass(secret_dict['osdfPlacement']['Password'])
+        config['osdfPlacementSOUsername'] = secret_dict['osdfPlacementSO']['UserName']
+        config['osdfPlacementSOPassword'] = decrypt_pass(secret_dict['osdfPlacementSO']['Password'])
+        config['osdfPlacementVFCUsername'] = secret_dict['osdfPlacementVFC']['UserName']
+        config['osdfPlacementVFCPassword'] = decrypt_pass(secret_dict['osdfPlacementVFC']['Password'])
+        config['osdfCMSchedulerUsername'] = secret_dict['osdfCMScheduler']['UserName']
+        config['osdfCMSchedulerPassword'] = decrypt_pass(secret_dict['osdfCMScheduler']['Password'])
+        config['configDbUserName'] = secret_dict['configDb']['UserName']
+        config['configDbPassword'] = decrypt_pass(secret_dict['configDb']['Password'])
+        config['pciHMSUsername'] = secret_dict['pciHMS']['UserName']
+        config['pciHMSPassword'] = decrypt_pass(secret_dict['pciHMS']['Password'])
+        config['osdfPCIOptUsername'] = secret_dict['osdfPCIOpt']['UserName']
+        config['osdfPCIOptPassword'] = decrypt_pass(secret_dict['osdfPCIOpt']['Password'])
+        config['osdfOptEngineUsername'] = secret_dict['osdfOptEngine']['UserName']
+        config['osdfOptEnginePassword'] = decrypt_pass(secret_dict['osdfOptEngine']['Password'])
     cfg_base.http_basic_auth_credentials = creds.load_credentials(osdf_config)
     cfg_base.dmaap_creds = creds.dmaap_creds()
 
@@ -117,17 +127,23 @@ def decrypt_pass(passwd):
 
 
 def delete_secrets():
-    """ This is intended to delete the secrets for a clean initialization for
-        testing Application. Actual deployment will have a preload script.
-        Make sure the config is in sync"""
+    """delete_secrets()
+
+    This is intended to delete the secrets for a clean initialization for
+    testing Application. Actual deployment will have a preload script.
+    Make sure the config is in sync
+    """
     config = osdf_config.deployment
     sms_url = config["aaf_sms_url"]
     timeout = config["aaf_sms_timeout"]
     cacert = config["aaf_ca_certs"]
     domain = config["secret_domain"]
-    sms_client = Client(url=sms_url, timeout=timeout, cacert=cacert)
-    ret_val = sms_client.deleteDomain(domain)
-    debug_log.debug("Clean up complete")
+    if sms_url:
+        sms_client = Client(url=sms_url, timeout=timeout, cacert=cacert)
+        ret_val = sms_client.deleteDomain(domain)
+        debug_log.debug("Clean up complete")
+    else:
+        debug_log.debug("SMS Disabled. Secrets delete skipped")
     return ret_val
 
 
diff --git a/pom.xml b/pom.xml
index de87383..bd31f85 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -29,7 +29,7 @@ http://maven.apache.org/POM/4.0.0 ">
        <groupId>org.onap.optf.osdf</groupId>
        <artifactId>optf-osdf</artifactId>
        <name>optf-osdf</name>
-       <version>3.0.7-SNAPSHOT</version>
+       <version>3.0.8-SNAPSHOT</version>
        <description>Optimization Service Design Framework</description>
 
        <properties>
index 6d0b524..a20435b 100644 (file)
@@ -1 +1 @@
-mysql-connector-python>=8.0.12
\ No newline at end of file
+mysql-connector-python==8.0.31
diff --git a/requirements-sim.txt b/requirements-sim.txt
new file mode 100644 (file)
index 0000000..56a8931
--- /dev/null
@@ -0,0 +1,18 @@
+cryptography==3.3.2
+docutils>=0.12
+docopt>=0.6.2
+Flask>=0.11.1
+Flask-HTTPAuth>=3.2.2
+jsonschema>=2.5.1
+lxml>=3.6.4
+python-dateutil>=2.5.3
+PyYAML==5.4.1
+requests>=2.14.2
+schematics>=2.0.0
+onapsmsclient>=0.0.4
+pymzn>=0.18.3
+onappylog>=1.0.9
+pathtools>=0.1.2
+pycryptodome>=3.9.6
+python-consul>=1.1.0
+tornado>=6.1
index 6a71d3c..561db19 100755 (executable)
@@ -31,6 +31,10 @@ SIMULATORS_DIR=$FUNC_TEST_DIR/simulators
 OSDF_DIR=$(dirname $TEST_DIR)
 DOCKER_DIR=$SIMULATORS_DIR/tmp_docker
 
+echo "Before Docker Build"
+cat $OSDF_DIR/requirements-sim.txt
+echo $OSDF_DIR
+
 mkdir -p $DOCKER_DIR/sim/osdf/policy/response-payloads/pdp-has-vcpe-good
 
 cp $SIMULATORS_DIR/Dockerfile $DOCKER_DIR/.
@@ -47,7 +51,7 @@ cp -r $SIMULATORS_DIR/aai $DOCKER_DIR/sim
 cp $TEST_DIR/policy-local-files/*.json $DOCKER_DIR/sim/policy/response-payloads/pdp-has-vcpe-good
 cp $TEST_DIR/placement-tests/policy_response.json $DOCKER_DIR/sim/policy/response-payloads/
 cp $SIMULATORS_DIR/oof_dependencies_simulators.py $DOCKER_DIR/sim/oof_dependencies_simulators.py
-cp $OSDF_DIR/requirements.txt $DOCKER_DIR
+cp $OSDF_DIR/requirements-sim.txt $DOCKER_DIR/requirements.txt
 cp -r $SIMULATORS_DIR/start_sim.sh $DOCKER_DIR/
 
 cd $DOCKER_DIR
index 4a7e57d..0dfb536 100755 (executable)
@@ -22,4 +22,4 @@ osdfDatabasePassword: osdf
 osdfDatabasePort: 3306
 
 #key
-appkey: os35@rrtky400fdntc#001t5
\ No newline at end of file
+appkey: os35@rrtky400fdntc#001t5
index 1d17d65..f5935da 100755 (executable)
@@ -1,4 +1,4 @@
 #!/usr/bin/env bash
 
 cd /sim
-python oof_dependencies_simulators.py > simulator-logs 2>&1
\ No newline at end of file
+python oof_dependencies_simulators.py
index 8abfb34..18c199b 100644 (file)
@@ -19,7 +19,7 @@
 
 major=3
 minor=0
-patch=7
+patch=8
 
 base_version=${major}.${minor}.${patch}