X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=src%2Femuvim%2Fdcemulator%2Fmonitoring.py;h=21985cba695edd456d9847c16626ae49517bb220;hb=3e16acbebd2c6669c1bbe5a7e3bb313aa1494e20;hp=6418e37f2f60b230353247be37c3605cc28e4d66;hpb=5d61e264565b4ae5f3114122d4007720216751e4;p=osm%2Fvim-emu.git diff --git a/src/emuvim/dcemulator/monitoring.py b/src/emuvim/dcemulator/monitoring.py index 6418e37..21985cb 100755 --- a/src/emuvim/dcemulator/monitoring.py +++ b/src/emuvim/dcemulator/monitoring.py @@ -34,13 +34,13 @@ import time from prometheus_client import start_http_server, Summary, Histogram, Gauge, Counter, REGISTRY, CollectorRegistry, \ pushadd_to_gateway, push_to_gateway, delete_from_gateway import threading -from subprocess import Popen, check_call +from subprocess import Popen import os import docker import json from copy import deepcopy -logging.basicConfig(level=logging.INFO) +logging.basicConfig() """ class to read openflow stats from the Ryu controller of the DCNetwork @@ -626,6 +626,46 @@ class DCNetworkMonitor(): wait_time += 1 return ret + def term(self, vnf_list=[]): + """ + Start a terminal window for the specified VNFs + (start a terminal for all VNFs if vnf_list is empty) + :param vnf_list: + :return: + """ + + + if vnf_list is None: + vnf_list = [] + if not isinstance(vnf_list, list): + vnf_list = str(vnf_list).split(',') + vnf_list = map(str.strip, vnf_list) + logging.info('vnf_list: {}'.format(vnf_list)) + + return self.start_xterm(vnf_list) + + + # start an xterm for the specfified vnfs + def start_xterm(self, vnf_names): + # start xterm for all vnfs + for vnf_name in vnf_names: + terminal_cmd = "docker exec -it mn.{0} /bin/bash".format(vnf_name) + + cmd = ['xterm', '-xrm', 'XTerm*selectToClipboard: true', '-xrm', 'XTerm.vt100.allowTitleOps: false', + '-T', vnf_name, + '-e', terminal_cmd] + Popen(cmd) + + ret = 'xterms started for {0}'.format(vnf_names) + if len(vnf_names) == 0: + ret = 'vnf list is empty, no xterms started' + return ret + + + + + +