Merge remote-tracking branch 'upstream/master'
diff --git a/setup.py b/setup.py
index 3657816..b8af834 100755
--- a/setup.py
+++ b/setup.py
@@ -25,7 +25,8 @@
'requests',
'prometheus_client',
'paramiko',
- 'urllib3'
+ 'urllib3',
+ 'requests'
],
zip_safe=False,
entry_points={
diff --git a/src/emuvim/api/zerorpc/compute.py b/src/emuvim/api/zerorpc/compute.py
index 63786fa..a08c118 100755
--- a/src/emuvim/api/zerorpc/compute.py
+++ b/src/emuvim/api/zerorpc/compute.py
@@ -119,12 +119,13 @@
return ex.message
@zerorpc.stream
- def compute_profile(self, dc_label, compute_name, image, kwargs):
+ def compute_profile(self, dc_label, compute_name, kwargs):
# note: zerorpc does not support keyword arguments
## VIM/dummy gatekeeper's tasks:
# start vnf
- vnf_status = self.compute_action_start( dc_label, compute_name, image,
+ vnf_status = self.compute_action_start( dc_label, compute_name,
+ kwargs.get('image'),
kwargs.get('network'),
kwargs.get('command'))
# start traffic source (with fixed ip addres, no use for now...)
diff --git a/src/emuvim/cli/compute.py b/src/emuvim/cli/compute.py
index 433826e..4869a17 100755
--- a/src/emuvim/cli/compute.py
+++ b/src/emuvim/cli/compute.py
@@ -24,7 +24,7 @@
# call the local method with the same name as the command arg
getattr(self, args["command"])(args)
else:
- print "Command not implemented."
+ print("Command not implemented.")
def start(self, args):
nw_list = list()
@@ -71,7 +71,7 @@
"eth0 IP",
"eth0 status",
"Status"]
- print tabulate(table, headers=headers, tablefmt="grid")
+ print(tabulate(table, headers=headers, tablefmt="grid"))
def status(self, args):
r = self.c.compute_status(
@@ -86,15 +86,14 @@
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"),
- args.get("image"),
- params
- ):
+ params):
print(output + '\n')
#pp.pprint(r)
@@ -138,8 +137,8 @@
help="Startup command of the container e.g. './start.sh'")
parser.add_argument(
"--net", dest="network",
- help="Network properties of compute instance e.g. \
- '10.0.0.123/8' or '10.0.0.123/8,11.0.0.123/24' for multiple interfaces.")
+ 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")
diff --git a/src/emuvim/cli/datacenter.py b/src/emuvim/cli/datacenter.py
index c3850fc..cbe4d0b 100755
--- a/src/emuvim/cli/datacenter.py
+++ b/src/emuvim/cli/datacenter.py
@@ -24,7 +24,7 @@
# call the local method with the same name as the command arg
getattr(self, args["command"])(args)
else:
- print "Command not implemented."
+ print("Command not implemented.")
def list(self, args):
r = self.c.datacenter_list()
@@ -42,7 +42,7 @@
"Switch",
"# Containers",
"# Metadata Items"]
- print tabulate(table, headers=headers, tablefmt="grid")
+ print(tabulate(table, headers=headers, tablefmt="grid"))
def status(self, args):
r = self.c.datacenter_status(
diff --git a/src/emuvim/cli/monitor.py b/src/emuvim/cli/monitor.py
index 79ff25b..20bfc25 100755
--- a/src/emuvim/cli/monitor.py
+++ b/src/emuvim/cli/monitor.py
@@ -1,12 +1,13 @@
"""
son-emu monitor CLI
(c) 2016 by Manuel Peuster <manuel.peuster@upb.de>
+Steven Van Rossem <steven.vanrossem@intec.ugent.be>
"""
import argparse
import pprint
import zerorpc
-import prometheus
+from emuvim.cli import prometheus
pp = pprint.PrettyPrinter(indent=4)
@@ -30,7 +31,7 @@
# call the local method with the same name as the command arg
getattr(self, args["command"])(args)
else:
- print "Command not implemented."
+ print("Command not implemented.")
def setup_metric(self, args):
vnf_name = self._parse_vnf_name(args.get("vnf_name"))
diff --git a/src/emuvim/cli/network.py b/src/emuvim/cli/network.py
index 516a752..48ff33a 100755
--- a/src/emuvim/cli/network.py
+++ b/src/emuvim/cli/network.py
@@ -1,6 +1,7 @@
"""
son-emu network CLI
(c) 2016 by Manuel Peuster <manuel.peuster@upb.de>
+Steven Van Rossem <steven.vanrossem@intec.ugent.be>
"""
import argparse
@@ -25,7 +26,7 @@
# call the local method with the same name as the command arg
getattr(self, args["command"])(args)
else:
- print "Command not implemented."
+ print("Command not implemented.")
def add(self, args):
vnf_src_name = self._parse_vnf_name(args.get("source"))
diff --git a/src/emuvim/cli/prometheus.py b/src/emuvim/cli/prometheus.py
index 26f18bf..9432408 100755
--- a/src/emuvim/cli/prometheus.py
+++ b/src/emuvim/cli/prometheus.py
@@ -3,8 +3,9 @@
(c) 2016 by Steven Van Rossem <steven.vanrossem@intec.ugent.be>
"""
-import urllib2
-import ast
+#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
@@ -16,9 +17,11 @@
def query_Prometheus(query):
url = prometheus_REST_api + '/' + 'api/v1/query?query=' + query
# logging.info('query:{0}'.format(url))
- req = urllib2.Request(url)
- ret = urllib2.urlopen(req).read()
- ret = ast.literal_eval(ret)
+ #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))
try:
diff --git a/src/emuvim/cli/son_emu_cli.py b/src/emuvim/cli/son_emu_cli.py
index 195fe06..842d0a1 100755
--- a/src/emuvim/cli/son_emu_cli.py
+++ b/src/emuvim/cli/son_emu_cli.py
@@ -20,7 +20,7 @@
def main():
if len(sys.argv) < 2:
- print "Usage: son-emu-cli <toolname> <arguments>"
+ print("Usage: son-emu-cli <toolname> <arguments>")
exit(0)
if sys.argv[1] == "compute":
compute.main(sys.argv[2:])
diff --git a/utils/ci/test_sdk_monitor.sh b/utils/ci/test_sdk_monitor.sh
index afd4b8c..51e5e7a 100755
--- a/utils/ci/test_sdk_monitor.sh
+++ b/utils/ci/test_sdk_monitor.sh
@@ -29,6 +29,9 @@
# test if prometheus query worked
echo $cpu_load
+
+regex='\[[0-9.]*, .*\]'
+
if [[ $cpu_load =~ $regex ]] ; then
echo " cpu monitor test OK"
exit 0
@@ -36,3 +39,5 @@
echo "cpu monitor test not OK"
exit 1
fi
+
+