summaryrefslogtreecommitdiffstats
path: root/dmaap/dmaapplugin/__init__.py
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2017-09-01 18:08:57 +0000
committerGerrit Code Review <gerrit@onap.org>2017-09-01 18:08:57 +0000
commit602f2b970301da07b90a1f091d5e90e89ca7cf31 (patch)
tree7c23c3ba6a4afcc9c5e257a9bf0c77692234bd4c /dmaap/dmaapplugin/__init__.py
parentd9c3e3f3bcaf15bb4a0735b390661745063599f9 (diff)
parent0619cb3772a12e0a5a3aecc09b96eeb7df20a000 (diff)
Merge "Add seed code for DMaaP plugin"
Diffstat (limited to 'dmaap/dmaapplugin/__init__.py')
-rw-r--r--dmaap/dmaapplugin/__init__.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/dmaap/dmaapplugin/__init__.py b/dmaap/dmaapplugin/__init__.py
new file mode 100644
index 0000000..130c0bf
--- /dev/null
+++ b/dmaap/dmaapplugin/__init__.py
@@ -0,0 +1,46 @@
+# ============LICENSE_START====================================================
+# org.onap.ccsdk
+# =============================================================================
+# Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
+# =============================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END======================================================
+
+## Get parameters for accessing the DMaaP controller
+from consulif.consulif import ConsulHandle
+from cloudify.exceptions import NonRecoverableError
+
+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
+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)
+ DMAAP_USER = config['dmaap']['username']
+ DMAAP_PASS = config['dmaap']['password']
+ DMAAP_OWNER = config['dmaap']['owner']
+ 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
+ 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
+
+ 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 configuring dmaap plugin: {0}".format(e))