Merge remote-tracking branch 'upstream/master'
authorstevenvanrossem <steven.vanrossem@intec.ugent.be>
Thu, 18 Aug 2016 15:32:44 +0000 (17:32 +0200)
committerstevenvanrossem <steven.vanrossem@intec.ugent.be>
Thu, 18 Aug 2016 15:32:44 +0000 (17:32 +0200)
src/emuvim/api/sonata/dummygatekeeper.py
src/emuvim/dcemulator/monitoring.py

index 939070c..2aa712e 100755 (executable)
@@ -157,7 +157,7 @@ class Service(object):
                 vnfi = self._start_vnfd(vnfd)
             self.instances[instance_uuid]["vnf_instances"].append(vnfi)
 
-        # 3. Configure the chaining of the network functions (currently only E-Line links supported)
+        # 3. Configure the chaining of the network functions (currently only E-Line and E-LAN links supported)
         vnf_id2vnf_name = defaultdict(lambda: "NotExistingNode",
                                 reduce(lambda x, y: dict(x, **y),
                                        map(lambda d: {d["vnf_id"]: d["vnf_name"]},
index ba04771..2e1e041 100755 (executable)
@@ -44,23 +44,15 @@ logging.basicConfig(level=logging.INFO)
 class to read openflow stats from the Ryu controller of the DCNetwork\r
 """\r
 \r
+PUSHGATEWAY_PORT = 9091\r
+CADVISOR_PORT = 8080\r
+\r
 class DCNetworkMonitor():\r
     def __init__(self, net):\r
         self.net = net\r
 \r
-        # TODO: these global variables should be part of a config file?\r
-        '''\r
-        # prometheus is started outside of son-emu\r
-        prometheus_ip = '127.0.0.1'\r
-        prometheus_port = '9090'\r
-        self.prometheus_REST_api = 'http://{0}:{1}'.format(prometheus_ip, prometheus_port)\r
-        '''\r
-        # helper variables to calculate the metrics\r
-        # pushgateway is started outside of son-emu and son-emu is started with net=host\r
-        # so localhost:9091 works\r
-        self.pushgateway = 'localhost:9091'\r
-        # when sdk is started with docker-compose, we could use\r
-        # self.pushgateway = 'pushgateway:9091'\r
+        # pushgateway address\r
+        self.pushgateway = 'localhost:{0}'.format(PUSHGATEWAY_PORT)\r
 \r
         # supported Prometheus metrics\r
         self.registry = CollectorRegistry()\r
@@ -103,7 +95,9 @@ class DCNetworkMonitor():
         self.monitor_flow_thread.start()\r
 \r
         # helper tools\r
-        # cAdvisor, Prometheus pushgateway and DB are started as external container, outside of son-emu\r
+        # cAdvisor, Prometheus pushgateway are started as external container, to gather monitoring metric in son-emu\r
+        self.start_PushGateway()\r
+        self.start_cAdvisor()\r
 \r
 \r
     # first set some parameters, before measurement can start\r
@@ -473,7 +467,7 @@ class DCNetworkMonitor():
             logging.warning("Pushgateway not reachable: {0} {1}".format(Exception, e))\r
 \r
 \r
-    def start_Prometheus(self, port=9090):\r
+    def start_Prometheus(self, port=CADVISOR_PORT):\r
         # prometheus.yml configuration file is located in the same directory as this file\r
         cmd = ["docker",\r
                "run",\r
@@ -487,7 +481,7 @@ class DCNetworkMonitor():
         logging.info('Start Prometheus container {0}'.format(cmd))\r
         return Popen(cmd)\r
 \r
-    def start_PushGateway(self, port=9091):\r
+    def start_PushGateway(self, port=PUSHGATEWAY_PORT):\r
         cmd = ["docker",\r
                "run",\r
                "-d",\r
@@ -499,7 +493,7 @@ class DCNetworkMonitor():
         logging.info('Start Prometheus Push Gateway container {0}'.format(cmd))\r
         return Popen(cmd)\r
 \r
-    def start_cadvisor(self, port=8090):\r
+    def start_cAdvisor(self, port=8080):\r
         cmd = ["docker",\r
                "run",\r
                "--rm",\r