From: peusterm Date: Fri, 19 Aug 2016 13:05:37 +0000 (+0200) Subject: Merge pull request #163 from stevenvanrossem/master X-Git-Tag: v3.1~69 X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2Fvim-emu.git;a=commitdiff_plain;h=c13e49dda2949b468c3f15bc4008361783fd0014;hp=79570f1a3e27b9d4f66c9a6b04a2af99a2164d52 Merge pull request #163 from stevenvanrossem/master start cadvisor and pushgateway from emulator --- diff --git a/Vagrantfile b/Vagrantfile index 3ed9a3f..2efc999 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -60,7 +60,7 @@ Vagrant.configure(2) do |config| # accessing "localhost:8080" will access port 80 on the guest machine. config.vm.network "forwarded_port", guest: 5000, host: 5000 # dummy gatekeeper config.vm.network "forwarded_port", guest: 5001, host: 5001 # REST API - config.vm.network "forwarded_port", guest: 8080, host: 8080 # cAdvisor + config.vm.network "forwarded_port", guest: 8081, host: 8081 # cAdvisor config.vm.network "forwarded_port", guest: 9091, host: 9091 # push gateway # Create a private network, which allows host-only access to the machine diff --git a/src/emuvim/api/sonata/dummygatekeeper.py b/src/emuvim/api/sonata/dummygatekeeper.py index 939070c..2aa712e 100755 --- a/src/emuvim/api/sonata/dummygatekeeper.py +++ b/src/emuvim/api/sonata/dummygatekeeper.py @@ -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"]}, diff --git a/src/emuvim/dcemulator/monitoring.py b/src/emuvim/dcemulator/monitoring.py index ba04771..875913f 100755 --- a/src/emuvim/dcemulator/monitoring.py +++ b/src/emuvim/dcemulator/monitoring.py @@ -44,23 +44,16 @@ logging.basicConfig(level=logging.INFO) class to read openflow stats from the Ryu controller of the DCNetwork """ +PUSHGATEWAY_PORT = 9091 +# we cannot use port 8080 because ryu-ofrest api is already using that one +CADVISOR_PORT = 8081 + class DCNetworkMonitor(): def __init__(self, net): self.net = net - # TODO: these global variables should be part of a config file? - ''' - # prometheus is started outside of son-emu - prometheus_ip = '127.0.0.1' - prometheus_port = '9090' - self.prometheus_REST_api = 'http://{0}:{1}'.format(prometheus_ip, prometheus_port) - ''' - # helper variables to calculate the metrics - # pushgateway is started outside of son-emu and son-emu is started with net=host - # so localhost:9091 works - self.pushgateway = 'localhost:9091' - # when sdk is started with docker-compose, we could use - # self.pushgateway = 'pushgateway:9091' + # pushgateway address + self.pushgateway = 'localhost:{0}'.format(PUSHGATEWAY_PORT) # supported Prometheus metrics self.registry = CollectorRegistry() @@ -103,7 +96,9 @@ class DCNetworkMonitor(): self.monitor_flow_thread.start() # helper tools - # cAdvisor, Prometheus pushgateway and DB are started as external container, outside of son-emu + # cAdvisor, Prometheus pushgateway are started as external container, to gather monitoring metric in son-emu + self.pushgateway_process = self.start_PushGateway() + self.cadvisor_process = self.start_cAdvisor() # first set some parameters, before measurement can start @@ -487,7 +482,7 @@ class DCNetworkMonitor(): logging.info('Start Prometheus container {0}'.format(cmd)) return Popen(cmd) - def start_PushGateway(self, port=9091): + def start_PushGateway(self, port=PUSHGATEWAY_PORT): cmd = ["docker", "run", "-d", @@ -499,7 +494,7 @@ class DCNetworkMonitor(): logging.info('Start Prometheus Push Gateway container {0}'.format(cmd)) return Popen(cmd) - def start_cadvisor(self, port=8090): + def start_cAdvisor(self, port=CADVISOR_PORT): cmd = ["docker", "run", "--rm", @@ -527,7 +522,7 @@ class DCNetworkMonitor(): self.prometheus_process.terminate() self.prometheus_process.kill() self._stop_container('prometheus') - + ''' if self.pushgateway_process is not None: logging.info('stopping pushgateway container') self.pushgateway_process.terminate() @@ -539,7 +534,6 @@ class DCNetworkMonitor(): self.cadvisor_process.terminate() self.cadvisor_process.kill() self._stop_container('cadvisor') - ''' def switch_tx_rx(self,metric=''): # when monitoring vnfs, the tx of the datacenter switch is actually the rx of the vnf