+++ /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 add(self, args):\r
- r = self.c.network_action_start(\r
- #args.get("datacenter"),\r
- args.get("source"),\r
- args.get("destination"))\r
- pp.pprint(r)\r
-\r
- def remove(self, args):\r
- r = self.c.network_action_stop(\r
- #args.get("datacenter"),\r
- args.get("source"),\r
- args.get("destination"))\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: add|remove")\r
-parser.add_argument(\r
- "--datacenter", "-d", dest="datacenter",\r
- help="Data center to in which the network action should be initiated")\r
-parser.add_argument(\r
- "--source", "-src", dest="source",\r
- help="vnf name of the source of the chain")\r
-parser.add_argument(\r
- "--destination", "-dst", dest="destination",\r
- help="vnf name of the destination of the chain")\r
-\r
-def main(argv):\r
- print "This is the son-emu network CLI."\r
- print "Arguments: %s" % str(argv)\r
- args = vars(parser.parse_args(argv))\r
- c = ZeroRpcClient()\r
- c.execute_command(args)\r