summaryrefslogtreecommitdiffstats
path: root/dmaap/dmaapplugin/__init__.py
diff options
context:
space:
mode:
authorxufeiliu <xl085b@att.com>2018-12-17 20:50:16 +0000
committerxufeiliu <xl085b@att.com>2018-12-17 20:50:37 +0000
commitf429e8f161c95c35d7247f928482dba5491d3665 (patch)
treeaac7eea964c58f3666f5c22ef7eb25124a10236b /dmaap/dmaapplugin/__init__.py
parent2e93164490b3ad9cd85f63ad6619ec02947dd3a3 (diff)
sync ONAP DMaaP-plugin with AT&T internal
Changes: security enhancement, support topic-name, more logs Change-Id: I7649505847a49b32d56d6e891aebb2521b54a7bd Issue-ID: CCSDK-794 Signed-off-by: xufeiliu <xl085b@att.com>
Diffstat (limited to 'dmaap/dmaapplugin/__init__.py')
-rw-r--r--dmaap/dmaapplugin/__init__.py45
1 files changed, 40 insertions, 5 deletions
diff --git a/dmaap/dmaapplugin/__init__.py b/dmaap/dmaapplugin/__init__.py
index 130c0bf..24466e9 100644
--- a/dmaap/dmaapplugin/__init__.py
+++ b/dmaap/dmaapplugin/__init__.py
@@ -19,28 +19,63 @@
## Get parameters for accessing the DMaaP controller
from consulif.consulif import ConsulHandle
from cloudify.exceptions import NonRecoverableError
+import os
+import pkcrypto
+
+os.environ["REQUESTS_CA_BUNDLE"]="/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt" # This is to handle https request thru plugin
CONSUL_HOST = "127.0.0.1" # Should always be a local consul agent on Cloudify Manager
-CM_SERVICE_NAME = "cloudify_manager" # Name under which CM is registered, used as key to get config
+DBCL_KEY_NAME = "dmaap_dbcl_info" # Consul key containing DMaaP data bus credentials
DBC_SERVICE_NAME= "dmaap_bus_controller" # Name under which the DMaaP bus controller is registered
try:
_ch = ConsulHandle("http://{0}:8500".format(CONSUL_HOST), None, None, None)
- config = _ch.get_config(CM_SERVICE_NAME)
+except Exception as e:
+ raise NonRecoverableError("Error getting ConsulHandle when configuring dmaap plugin: {0}".format(e))
+
+try:
+ config = _ch.get_config(DBCL_KEY_NAME)
+except Exception as e:
+ raise NonRecoverableError("Error getting config for '{0}' from ConsulHandle when configuring dmaap plugin: {1}".format(DBCL_KEY_NAME, e))
+
+try:
DMAAP_USER = config['dmaap']['username']
- DMAAP_PASS = config['dmaap']['password']
+except Exception as e:
+ raise NonRecoverableError("Error setting DMAAP_USER while configuring dmaap plugin: {0}".format(e))
+
+try:
+ DMAAP_PASS = pkcrypto.decrypt_obj(config['dmaap']['password'])
+except Exception as e:
+ raise NonRecoverableError("Error setting DMAAP_PASS while configuring dmaap plugin: {0}".format(e))
+
+try:
DMAAP_OWNER = config['dmaap']['owner']
+except Exception as e:
+ raise NonRecoverableError("Error setting DMAAP_OWNER while configuring dmaap plugin: {0}".format(e))
+
+try:
if 'protocol' in config['dmaap']:
DMAAP_PROTOCOL = config['dmaap']['protocol']
else:
DMAAP_PROTOCOL = 'https' # Default to https (service discovery should give us this but doesn't
+except Exception as e:
+ raise NonRecoverableError("Error setting DMAAP_PROTOCOL while configuring dmaap plugin: {0}".format(e))
+
+try:
if 'path' in config['dmaap']:
DMAAP_PATH = config['dmaap']['path']
else:
DMAAP_PATH = 'webapi' # SHould come from service discovery but Consul doesn't support it
+except Exception as e:
+ raise NonRecoverableError("Error setting DMAAP_PATH while configuring dmaap plugin: {0}".format(e))
+try:
service_address, service_port = _ch.get_service(DBC_SERVICE_NAME)
- DMAAP_API_URL = '{0}://{1}:{2}/{3}'.format(DMAAP_PROTOCOL, service_address, service_port, DMAAP_PATH)
+except Exception as e:
+ raise NonRecoverableError("Error getting service_address and service_port for '{0}' from ConsulHandle when configuring dmaap plugin: {1}".format(DBC_SERVICE_NAME, e))
+try:
+ DMAAP_API_URL = '{0}://{1}:{2}/{3}'.format(DMAAP_PROTOCOL, service_address, service_port, DMAAP_PATH)
except Exception as e:
- raise NonRecoverableError("Error configuring dmaap plugin: {0}".format(e))
+ raise NonRecoverableError("Error setting DMAAP_API_URL while configuring dmaap plugin: {0}".format(e))
+