summaryrefslogtreecommitdiffstats
path: root/dmaap/dmaapplugin/__init__.py
diff options
context:
space:
mode:
authorJack Lucas <jflucas@research.att.com>2017-09-01 13:48:08 +0000
committerJack Lucas <jflucas@research.att.com>2017-09-01 13:50:18 +0000
commit0619cb3772a12e0a5a3aecc09b96eeb7df20a000 (patch)
treeb8a921e0e41578163f7c2db41450301c374361df /dmaap/dmaapplugin/__init__.py
parentac3f029edc6bc8b25ab44666b5408c8929e6ba92 (diff)
Add seed code for DMaaP plugin
Change-Id: I8c7a9c432badd3052a571ed87b9b580760b376e6 Issue-Id: CCSDK-65 Signed-off-by: Jack Lucas <jflucas@research.att.com>
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))