From 575ac80f1bbfdb71436135d5a9762df51de05b83 Mon Sep 17 00:00:00 2001 From: hariharan97 Date: Tue, 9 Mar 2021 11:18:40 +0530 Subject: [PATCH] Fix for has to communicate with SDC for Nst-selection enhancements Issue-ID: OPTFRA-928 Signed-off-by: hariharan97 Change-Id: I6d661e5482194d1ecd8e583c065ce1e77fa52b80 --- conductor/conductor/common/sms.py | 27 +++++++++++++--------- .../data/plugins/inventory_provider/sdc.py | 7 ++++-- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/conductor/conductor/common/sms.py b/conductor/conductor/common/sms.py index 35ca644..49f6411 100644 --- a/conductor/conductor/common/sms.py +++ b/conductor/conductor/common/sms.py @@ -20,13 +20,10 @@ '''Secret Management Service Integration''' from conductor.common import config_loader from onapsmsclient import Client - from oslo_config import cfg from oslo_log import log -import conductor.data.plugins.inventory_provider.aai -import conductor.api.controllers.v1.plans -import conductor.common.music.api -import conductor.data.plugins.service_controller.sdnc + + from conductor.common.utils import cipherUtils LOG = log.getLogger(__name__) @@ -35,8 +32,8 @@ CONF = cfg.CONF AAF_SMS_OPTS = [ cfg.BoolOpt('is_enabled', - default=True, - help='Is Secret Management service enabled'), + default=True, + help='Is Secret Management service enabled'), cfg.StrOpt('aaf_sms_url', default='https://aaf-sms.onap:10443', help='Base URL for SMS, up to and not including ' @@ -61,9 +58,12 @@ config_spec = { def preload_secrets(): - """ This is intended to load the secrets required for testing Application + """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""" + + in sync + """ preload_config = config_loader.load_config_file( config_spec.get("preload_secrets")) domain = preload_config.get("domain") @@ -113,6 +113,8 @@ def load_secrets(): config.set_override('username', secret_dict['aaf_api']['username'], 'aaf_api') config.set_override('password', decrypt_pass(secret_dict['aaf_api']['password']), 'aaf_api') config.set_override('aaf_conductor_user', secret_dict['aaf_api']['aaf_conductor_user'], 'aaf_api') + config.set_override('username', secret_dict['sdc']['username'], 'sdc') + config.set_override('password', decrypt_pass(secret_dict['sdc']['password']), 'sdc') def decrypt_pass(passwd): @@ -123,9 +125,12 @@ def decrypt_pass(passwd): def delete_secrets(): - """ This is intended to delete the secrets for a clean initialization for + """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""" + + Make sure the config is in sync + """ config = CONF.aaf_sms sms_url = config.aaf_sms_url timeout = config.aaf_sms_timeout diff --git a/conductor/conductor/data/plugins/inventory_provider/sdc.py b/conductor/conductor/data/plugins/inventory_provider/sdc.py index 6f3cb4f..c69d7b0 100644 --- a/conductor/conductor/data/plugins/inventory_provider/sdc.py +++ b/conductor/conductor/data/plugins/inventory_provider/sdc.py @@ -57,7 +57,7 @@ SDC_OPTS = [ default='certificate_key.pem', help='Private Certificate Key file in pem format.'), cfg.StrOpt('certificate_authority_bundle_file', - default='certificate_authority_bundle.pem', + default='', help='Certificate Authority Bundle file in pem format. ' 'Must contain the appropriate trust chain for the ' 'Certificate file.'), @@ -108,14 +108,16 @@ class SDC(object): context=None, value=None): """Performs HTTP request.""" headers = { - 'X-FromAppId': 'CONDUCTOR', + 'X-FromAppId': 'AAI', 'X-TransactionId': str(uuid.uuid4()), + 'X-ECOMP-InstanceID': 'AAI', } kwargs = { "method": method, "path": path, "headers": headers, "data": data, + "content_type": "application/octet-stream" } # TODO(jdandrea): Move timing/response logging into the rest helper? @@ -144,6 +146,7 @@ class SDC(object): "username": self.username, "password": self.password, "read_timeout": self.timeout, + "ca_bundle_file": self.verify, } self.rest = rest.REST(**kwargs) -- 2.16.6