projects
/
osm
/
vim-emu.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4937815
)
prepare son-emu-cli for son-cli integration
author
stevenvanrossem
<steven.vanrossem@intec.ugent.be>
Thu, 19 May 2016 10:19:36 +0000
(12:19 +0200)
committer
stevenvanrossem
<steven.vanrossem@intec.ugent.be>
Thu, 19 May 2016 10:19:36 +0000
(12:19 +0200)
setup.py
patch
|
blob
|
history
setup_cli_only.py
patch
|
blob
|
history
src/emuvim/cli/monitor.py
patch
|
blob
|
history
src/emuvim/cli/network.py
patch
|
blob
|
history
src/emuvim/cli/prometheus.py
patch
|
blob
|
history
utils/ci/test_sdk_monitor.sh
patch
|
blob
|
history
diff --git
a/setup.py
b/setup.py
index
3657816
..
b8af834
100755
(executable)
--- a/
setup.py
+++ b/
setup.py
@@
-25,7
+25,8
@@
setup(name='emuvim',
'requests',
'prometheus_client',
'paramiko',
'requests',
'prometheus_client',
'paramiko',
- 'urllib3'
+ 'urllib3',
+ 'requests'
],
zip_safe=False,
entry_points={
],
zip_safe=False,
entry_points={
diff --git
a/setup_cli_only.py
b/setup_cli_only.py
index
320ddc3
..
6ab0777
100755
(executable)
--- a/
setup_cli_only.py
+++ b/
setup_cli_only.py
@@
-14,6
+14,7
@@
setup(name='emuvim',
'zerorpc',
'tabulate',
'argparse',
'zerorpc',
'tabulate',
'argparse',
+ 'requests'
],
zip_safe=False,
entry_points={
],
zip_safe=False,
entry_points={
diff --git
a/src/emuvim/cli/monitor.py
b/src/emuvim/cli/monitor.py
index
7be7374
..
20bfc25
100755
(executable)
--- a/
src/emuvim/cli/monitor.py
+++ b/
src/emuvim/cli/monitor.py
@@
-1,12
+1,13
@@
"""
\r
son-emu monitor CLI
\r
(c) 2016 by Manuel Peuster <manuel.peuster@upb.de>
\r
"""
\r
son-emu monitor CLI
\r
(c) 2016 by Manuel Peuster <manuel.peuster@upb.de>
\r
+Steven Van Rossem <steven.vanrossem@intec.ugent.be>
\r
"""
\r
\r
import argparse
\r
import pprint
\r
import zerorpc
\r
"""
\r
\r
import argparse
\r
import pprint
\r
import zerorpc
\r
-import prometheus
\r
+
from emuvim.cli
import prometheus
\r
\r
pp = pprint.PrettyPrinter(indent=4)
\r
\r
\r
pp = pprint.PrettyPrinter(indent=4)
\r
\r
diff --git
a/src/emuvim/cli/network.py
b/src/emuvim/cli/network.py
index
bfd1127
..
48ff33a
100755
(executable)
--- a/
src/emuvim/cli/network.py
+++ b/
src/emuvim/cli/network.py
@@
-1,6
+1,7
@@
"""
\r
son-emu network CLI
\r
(c) 2016 by Manuel Peuster <manuel.peuster@upb.de>
\r
"""
\r
son-emu network CLI
\r
(c) 2016 by Manuel Peuster <manuel.peuster@upb.de>
\r
+Steven Van Rossem <steven.vanrossem@intec.ugent.be>
\r
"""
\r
\r
import argparse
\r
"""
\r
\r
import argparse
\r
diff --git
a/src/emuvim/cli/prometheus.py
b/src/emuvim/cli/prometheus.py
index
26f18bf
..
9432408
100755
(executable)
--- a/
src/emuvim/cli/prometheus.py
+++ b/
src/emuvim/cli/prometheus.py
@@
-3,8
+3,9
@@
Prometheus API helper functions
(c) 2016 by Steven Van Rossem <steven.vanrossem@intec.ugent.be>
"""
(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
# 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
@@
prometheus_REST_api = 'http://{0}:{1}'.format(prometheus_ip, prometheus_port)
def query_Prometheus(query):
url = prometheus_REST_api + '/' + 'api/v1/query?query=' + query
# logging.info('query:{0}'.format(url))
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:
if ret['status'] == 'success':
# logging.info('return:{0}'.format(ret))
try:
diff --git
a/utils/ci/test_sdk_monitor.sh
b/utils/ci/test_sdk_monitor.sh
index
afd4b8c
..
51e5e7a
100755
(executable)
--- a/
utils/ci/test_sdk_monitor.sh
+++ b/
utils/ci/test_sdk_monitor.sh
@@
-29,6
+29,9
@@
son-emu-cli compute stop -d datacenter1 -n vnf1
# test if prometheus query worked
echo $cpu_load
# test if prometheus query worked
echo $cpu_load
+
+regex='\[[0-9.]*, .*\]'
+
if [[ $cpu_load =~ $regex ]] ; then
echo " cpu monitor test OK"
exit 0
if [[ $cpu_load =~ $regex ]] ; then
echo " cpu monitor test OK"
exit 0
@@
-36,3
+39,5
@@
else
echo "cpu monitor test not OK"
exit 1
fi
echo "cpu monitor test not OK"
exit 1
fi
+
+