'requests',
'prometheus_client',
'paramiko',
- 'urllib3'
+ 'urllib3',
+ 'requests'
],
zip_safe=False,
entry_points={
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...)
# 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()
"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(
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)
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")
# 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()
"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(
"""\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
-import prometheus\r
+from emuvim.cli import prometheus\r
\r
pp = pprint.PrettyPrinter(indent=4)\r
\r
# call the local method with the same name as the command arg\r
getattr(self, args["command"])(args)\r
else:\r
- print "Command not implemented."\r
+ print("Command not implemented.")\r
\r
def setup_metric(self, args):\r
vnf_name = self._parse_vnf_name(args.get("vnf_name"))\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
# call the local method with the same name as the command arg\r
getattr(self, args["command"])(args)\r
else:\r
- print "Command not implemented."\r
+ print("Command not implemented.")\r
\r
def add(self, args):\r
vnf_src_name = self._parse_vnf_name(args.get("source"))\r
(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
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:
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:])
# test if prometheus query worked
echo $cpu_load
+
+regex='\[[0-9.]*, .*\]'
+
if [[ $cpu_load =~ $regex ]] ; then
echo " cpu monitor test OK"
exit 0
echo "cpu monitor test not OK"
exit 1
fi
+
+