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"]},
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
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
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
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
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