cleanup for open sourcing
diff --git a/src/emuvim/cli/compute.py b/src/emuvim/cli/compute.py
index 25ac247..b5f775f 100755
--- a/src/emuvim/cli/compute.py
+++ b/src/emuvim/cli/compute.py
@@ -101,27 +101,6 @@
args.get("datacenter"), args.get("name"))
pp.pprint(r)
- def profile(self, args):
- nw_list = list()
- if args.get("network") is not None:
- nw_list = self._parse_network(args.get("network"))
-
- params = self._create_dict(
- network=nw_list,
- command=args.get("docker_command"),
- image=args.get("image"),
- input=args.get("input"),
- output=args.get("output"))
-
- for output in self.c.compute_profile(
- args.get("datacenter"),
- args.get("name"),
- params):
- print(output + '\n')
-
- #pp.pprint(r)
- #print(r)
-
def _create_dict(self, **kwargs):
return kwargs
@@ -144,7 +123,7 @@
parser = argparse.ArgumentParser(description='son-emu compute')
parser.add_argument(
"command",
- choices=['start', 'stop', 'list', 'status', 'profile'],
+ choices=['start', 'stop', 'list', 'status'],
help="Action to be executed.")
parser.add_argument(
"--datacenter", "-d", dest="datacenter",
@@ -162,13 +141,6 @@
"--net", dest="network",
help="Network properties of a compute instance e.g. \
'(id=input,ip=10.0.10.3/24),(id=output,ip=10.0.10.4/24)' for multiple interfaces.")
-parser.add_argument(
- "--input", "-in", dest="input",
- help="input interface of the vnf to profile")
-parser.add_argument(
- "--output", "-out", dest="output",
- help="output interface of the vnf to profile")
-
def main(argv):
args = vars(parser.parse_args(argv))
diff --git a/src/emuvim/cli/monitor.py b/src/emuvim/cli/monitor.py
index 9620a98..3e872d6 100755
--- a/src/emuvim/cli/monitor.py
+++ b/src/emuvim/cli/monitor.py
@@ -93,17 +93,9 @@
args.get("cookie"))
pp.pprint(r)
- def prometheus_zrpc(self, args):
- vnf_name = self._parse_vnf_name(args.get("vnf_name"))
- vnf_interface = self._parse_vnf_interface(args.get("vnf_name"))
- r = self.c.prometheus(
- args.get("datacenter"),
- vnf_name,
- vnf_interface,
- args.get("query"))
- pp.pprint(r)
-
def prometheus(self, args):
+ # This functions makes it more user-friendly to create the correct prometheus query
+ # <uuid> is replaced by the correct uuid of the deployed vnf container
vnf_name = self._parse_vnf_name(args.get("vnf_name"))
vnf_interface = self._parse_vnf_interface(args.get("vnf_name"))
dc_label = args.get("datacenter")
diff --git a/src/emuvim/cli/prometheus.py b/src/emuvim/cli/prometheus.py
index 4572449..58969d1 100755
--- a/src/emuvim/cli/prometheus.py
+++ b/src/emuvim/cli/prometheus.py
@@ -26,14 +26,16 @@
partner consortium (www.sonata-nfv.eu).
"""
-#import urllib2
+
import requests
-#import ast
+
# set this to localhost for now
# this is correct for son-emu started outside of a container or as a container with net=host
-#TODO prometheus sdk DB is started outside of emulator, place these globals in an external SDK config file?
-prometheus_ip = '127.0.0.1'
+#TODO if prometheus sdk DB is started outside of emulator, place these globals in an external SDK config file?
+prometheus_ip = 'localhost'
+# when sdk is started with docker-compose, we could use
+# prometheus_ip = 'prometheus'
prometheus_port = '9090'
prometheus_REST_api = 'http://{0}:{1}'.format(prometheus_ip, prometheus_port)
@@ -41,10 +43,7 @@
def query_Prometheus(query):
url = prometheus_REST_api + '/' + 'api/v1/query?query=' + query
# logging.info('query:{0}'.format(url))
- #req = urllib2.Request(url)
req = requests.get(url)
- #ret = urllib2.urlopen(req).read()
- #ret = ast.literal_eval(ret)
ret = req.json()
if ret['status'] == 'success':
# logging.info('return:{0}'.format(ret))
diff --git a/src/emuvim/cli/rest/monitor.py b/src/emuvim/cli/rest/monitor.py
index 88db8b2..7e9b839 100755
--- a/src/emuvim/cli/rest/monitor.py
+++ b/src/emuvim/cli/rest/monitor.py
@@ -94,6 +94,23 @@
pp.pprint(response.json())
+ def prometheus(self, args):
+ # This functions makes it more user-friendly to create the correct prometheus query
+ # <uuid> is replaced by the correct uuid of the deployed vnf container
+ vnf_name = self._parse_vnf_name(args.get("vnf_name"))
+ vnf_interface = self._parse_vnf_interface(args.get("vnf_name"))
+ dc_label = args.get("datacenter")
+ query = args.get("query")
+ vnf_status = get("%s/restapi/compute/%s/%s" %
+ (args.get("endpoint"),
+ args.get("datacenter"),
+ vnf_name)).json()
+ uuid = vnf_status['id']
+ query = query.replace('<uuid>', uuid)
+
+ response = prometheus.query_Prometheus(query)
+ pp.pprint(response)
+
def _parse_vnf_name(self, vnf_name_str):
vnf_name = vnf_name_str.split(':')[0]
return vnf_name