def __init__(self, net):
self.net = net
- def network_action_start(self, vnf_src_name, vnf_dst_name, vnf_src_interface=None, vnf_dst_interface=None, weight=None):
+ def network_action_start(self, vnf_src_name, vnf_dst_name, kwargs):
# call DCNetwork method, not really datacenter specific API for now...
# provided dc name needs to be part of API endpoint
# no check if vnfs are really connected to this datacenter...
try:
c = self.net.setChain(
vnf_src_name, vnf_dst_name,
- vnf_src_interface=vnf_src_interface,
- vnf_dst_interface=vnf_dst_interface,
- weight=weight)
+ vnf_src_interface=kwargs.get('vnf_src_interface'),
+ vnf_dst_interface=kwargs.get('vnf_dst_interface'),
+ weight=kwargs.get('weight'),
+ match=kwargs.get('match'))
return str(c)
except Exception as ex:
logging.exception("RPC error.")
\r
def add(self, args):\r
vnf_src_name = self._parse_vnf_name(args.get("source"))\r
- vnf_src_interface = self._parse_vnf_interface(args.get("source"))\r
vnf_dst_name = self._parse_vnf_name(args.get("destination"))\r
- vnf_dst_interface = self._parse_vnf_interface(args.get("destination"))\r
- weight = args.get("weight")\r
+\r
+ params = self._create_dict(\r
+ vnf_src_interface=self._parse_vnf_interface(args.get("source")),\r
+ vnf_dst_interface=self._parse_vnf_interface(args.get("destination")),\r
+ weight=args.get("weight"),\r
+ match=args.get("match"))\r
+\r
# note zerorpc does not support named arguments\r
r = self.c.network_action_start(\r
#args.get("datacenter"),\r
vnf_src_name,\r
vnf_dst_name,\r
- vnf_src_interface,\r
- vnf_dst_interface,\r
- weight)\r
+ params)\r
pp.pprint(r)\r
\r
def remove(self, args):\r
vnf_dst_name = self._parse_vnf_name(args.get("destination"))\r
vnf_dst_interface = self._parse_vnf_interface(args.get("destination"))\r
weight = args.get("weight")\r
+ match = args.get("match")\r
r = self.c.network_action_stop(\r
#args.get("datacenter"),\r
vnf_src_name,\r
vnf_dst_name,\r
vnf_src_interface,\r
vnf_dst_interface,\r
- weight)\r
+ weight,\r
+ match)\r
pp.pprint(r)\r
\r
def _parse_vnf_name(self, vnf_name_str):\r
\r
return vnf_interface\r
\r
+ def _create_dict(self, **kwargs):\r
+ return kwargs\r
\r
parser = argparse.ArgumentParser(description='son-emu network')\r
parser.add_argument(\r
parser.add_argument(\r
"--weight", "-w", dest="weight",\r
help="weight metric to calculate the path")\r
+parser.add_argument(\r
+ "--match", "-m", dest="match",\r
+ help="string holding extra matches for the flow entries")\r
\r
def main(argv):\r
args = vars(parser.parse_args(argv))\r
CLI(self)
# to remove chain do setChain( src, dst, cmd='del-flows')
- def setChain(self, vnf_src_name, vnf_dst_name, vnf_src_interface=None, vnf_dst_interface=None, cmd='add-flow', weight=None):
+ def setChain(self, vnf_src_name, vnf_dst_name, vnf_src_interface=None, vnf_dst_interface=None, cmd='add-flow',
+ weight=None, **kwargs):
logging.info('vnf_src_if: {0}'.format(vnf_src_interface))
#check if port is specified (vnf:port)
# TODO need multiple matches to do this (VLAN tags)
if isinstance( current_node, OVSSwitch ):
match = 'in_port=%s' % switch_inport_nr
+ #add additional match entries from the argument
+ match_input = kwargs.get('match')
+ logging.info('match input:{0}'.format(match_input))
+ if match_input:
+ s = ','
+ match = s.join([match,match_input])
if cmd=='add-flow':
action = 'action=%s' % switch_outport_nr