X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2Fvim-emu.git;a=blobdiff_plain;f=src%2Femuvim%2Fdcemulator%2Fmonitoring.py;fp=src%2Femuvim%2Fdcemulator%2Fmonitoring.py;h=0d40531a626c061582657eb871961b1d70494a4a;hp=6418e37f2f60b230353247be37c3605cc28e4d66;hb=c63c549c44b90b0e9e447ae47466d701efbca5db;hpb=ed293f8a67f260ea937ae8b2b72823e1e39353f2 diff --git a/src/emuvim/dcemulator/monitoring.py b/src/emuvim/dcemulator/monitoring.py index 6418e37..0d40531 100755 --- a/src/emuvim/dcemulator/monitoring.py +++ b/src/emuvim/dcemulator/monitoring.py @@ -34,7 +34,7 @@ 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 @@ -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 + + + + + +