+++ /dev/null
-"""\r
-son-emu network CLI\r
-(c) 2016 by Manuel Peuster <manuel.peuster@upb.de>\r
-"""\r
-\r
-import argparse\r
-import pprint\r
-from tabulate import tabulate\r
-import zerorpc\r
-\r
-\r
-pp = pprint.PrettyPrinter(indent=4)\r
-\r
-class ZeroRpcClient(object):\r
-\r
- def __init__(self):\r
- self.c = zerorpc.Client()\r
- # TODO connect to DCNetwork API\r
- #self.c.connect("tcp://127.0.0.1:4242") # TODO hard coded for now. we'll change this later\r
- self.c.connect("tcp://127.0.0.1:5151")\r
- self.cmds = {}\r
-\r
- def execute_command(self, args):\r
- if getattr(self, args["command"]) is not None:\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
-\r
- def get_rate(self, args):\r
- r = self.c.monitor_get_rate(\r
- args.get("vnf_name"),\r
- args.get("direction"))\r
- pp.pprint(r)\r
-\r
-\r
-parser = argparse.ArgumentParser(description='son-emu network')\r
-parser.add_argument(\r
- "command",\r
- help="Action to be executed: get_rate")\r
-parser.add_argument(\r
- "--vnf_name", "-vnf", dest="vnf_name",\r
- help="vnf name to be monitored")\r
-parser.add_argument(\r
- "--direction", "-d", dest="direction",\r
- help="in (ingress rate) or out (egress rate)")\r
-\r
-def main(argv):\r
- print "This is the son-emu monitor CLI."\r
- print "Arguments: %s" % str(argv)\r
- args = vars(parser.parse_args(argv))\r
- c = ZeroRpcClient()\r
- c.execute_command(args)\r