3 (c) 2016 by Manuel Peuster <manuel.peuster@upb.de>
8 from tabulate
import tabulate
12 pp
= pprint
.PrettyPrinter(indent
=4)
14 class ZeroRpcClient(object):
17 self
.c
= zerorpc
.Client()
18 # TODO connect to DCNetwork API
19 #self.c.connect("tcp://127.0.0.1:4242") # TODO hard coded for now. we'll change this later
20 self
.c
.connect("tcp://127.0.0.1:5151")
23 def execute_command(self
, args
):
24 if getattr(self
, args
["command"]) is not None:
25 # call the local method with the same name as the command arg
26 getattr(self
, args
["command"])(args
)
28 print "Command not implemented."
31 r
= self
.c
.network_action_start(
32 #args.get("datacenter"),
34 args
.get("destination"))
37 def remove(self
, args
):
38 r
= self
.c
.network_action_stop(
39 #args.get("datacenter"),
41 args
.get("destination"))
45 parser
= argparse
.ArgumentParser(description
='son-emu network')
48 help="Action to be executed: add|remove")
50 "--datacenter", "-d", dest
="datacenter",
51 help="Data center to in which the network action should be initiated")
53 "--source", "-src", dest
="source",
54 help="vnf name of the source of the chain")
56 "--destination", "-dst", dest
="destination",
57 help="vnf name of the destination of the chain")
60 args
= vars(parser
.parse_args(argv
))
62 c
.execute_command(args
)