VOL-282: Integrate demo components (e.g. dashd, shovel) with the clustered consul service

This submission migrates the dashd service to Docker swarm mode. The dashd implementation
did not use the '@' character to distinguish between a Consul service and a Docker service.

This submission adds support for both service types and a v3 compose file for a 'stats'
service stack. The shovel service will be added to this stackfile in a future submission.

Change-Id: Iad4695641d489666ed27a78b0a79539357a8e2be
diff --git a/dashd/dashd_impl.py b/dashd/dashd_impl.py
index 1df892b..e933cd4 100755
--- a/dashd/dashd_impl.py
+++ b/dashd/dashd_impl.py
@@ -86,7 +86,7 @@
 
 
 class DashDaemon(object):
-    def __init__(self, consul_endpoint, grafana_url, topic="voltha.heartbeat"):
+    def __init__(self, consul_endpoint, kafka_endpoint, grafana_url, topic="voltha.heartbeat"):
         #logging.basicConfig(
         # format='%(asctime)s:%(name)s:' +
         #        '%(levelname)s:%(process)d:%(message)s',
@@ -98,22 +98,25 @@
         self.topic = topic
         self.dash_template = DashTemplate(grafana_url)
         self.grafana_url = grafana_url
-        self.kafka_endpoint = None
+        self.kafka_endpoint = kafka_endpoint
         self.consul_endpoint = consul_endpoint
-        retrys = 10
-        while True:
-            try:
-                self.kafka_endpoint = get_endpoint_from_consul(self.consul_endpoint,
-                'kafka')
-                break
-            except:
-                log.error("unable-to-communicate-with-consul")
-                self.stop()
-            retrys -= 1
-            if retrys == 0:
-                log.error("unable-to-communicate-with-consul")
-                self.stop()
-            time.sleep(10)
+
+        if kafka_endpoint.startswith('@'):
+            retrys = 10
+            while True:
+                try:
+                    self.kafka_endpoint = get_endpoint_from_consul(
+                        self.consul_endpoint, kafka_endpoint[1:])
+                    break
+                except:
+                    log.error("unable-to-communicate-with-consul")
+                    self.stop()
+                retrys -= 1
+                if retrys == 0:
+                    log.error("unable-to-communicate-with-consul")
+                    self.stop()
+                time.sleep(10)
+
         self.on_start_callback = None
 
         self._client = KafkaClient(self.kafka_endpoint)
@@ -455,7 +458,7 @@
 
     args = parse_options()
 
-    dashd = DashDaemon(args.consul, args.grafana_url, args.topic)
+    dashd = DashDaemon(args.consul, args.kafka, args.grafana_url, args.topic)
     reactor.callWhenRunning(dashd.start)
     reactor.run()
     log.info("completed!")
diff --git a/dashd/main.py b/dashd/main.py
index 578958f..ba9c242 100755
--- a/dashd/main.py
+++ b/dashd/main.py
@@ -212,6 +212,7 @@
                                                  topic=args.topic)
             self.dashd_server = yield \
                     DashDaemon(args.consul, #'10.0.2.15:8500',
+                               args.kafka,
                                args.grafana_url, #'http://admin:admin@localhost:8882/api',
                                topic=args.topic )  #"voltha.kpis")