X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=src%2Femuvim%2Fdcemulator%2Fnet.py;h=3ded28ec70009b1a2e9648ccb7b23bc90322b4f7;hb=23c480906da46931b6f4350f3fb434a89f49227a;hp=ac44d57009c2244c4aad952cf7ccfaf19c8aaf70;hpb=307aa1f4774345d9e9a70c02eeee312ecb1b13cf;p=osm%2Fvim-emu.git diff --git a/src/emuvim/dcemulator/net.py b/src/emuvim/dcemulator/net.py index ac44d57..3ded28e 100755 --- a/src/emuvim/dcemulator/net.py +++ b/src/emuvim/dcemulator/net.py @@ -221,7 +221,8 @@ class DCNetwork(Dockernet): 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) @@ -305,7 +306,18 @@ class DCNetwork(Dockernet): # TODO this only sets port in to out, no match, so this will give trouble when multiple services are deployed... # TODO need multiple matches to do this (VLAN tags) if isinstance( current_node, OVSSwitch ): + match_input = kwargs.get('match') + self._set_flow_entry_dpctl(current_node, switch_inport_nr, switch_outport_nr, match_input, cmd) + if kwargs.get('bidirectional'): + self._set_flow_entry_dpctl(current_node, switch_outport_nr, switch_inport_nr, match_input, cmd) + ''' 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 @@ -319,6 +331,7 @@ class DCNetwork(Dockernet): current_node.dpctl(cmd, ofcmd) logging.info("add flow in switch: {0} in_port: {1} out_port: {2}".format(current_node.name, switch_inport_nr, switch_outport_nr)) + ''' # take first link between switches by default if isinstance( next_node, OVSSwitch ): switch_inport_nr = self.DCNetwork_graph[current_hop][next_hop][0]['dst_port_nr'] @@ -327,6 +340,28 @@ class DCNetwork(Dockernet): return "path added between {0} and {1}".format(vnf_src_name, vnf_dst_name) #return "destination node: {0} not reached".format(vnf_dst_name) + def _set_flow_entry_dpctl(self, node, switch_inport_nr, switch_outport_nr, match_input, cmd): + 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 + s = ',' + ofcmd = s.join([match, action]) + elif cmd == 'del-flows': + ofcmd = match + else: + ofcmd = '' + + node.dpctl(cmd, ofcmd) + logging.info("add flow in switch: {0} in_port: {1} out_port: {2}".format(node.name, switch_inport_nr, + switch_outport_nr)) + # start Ryu Openflow controller as Remote Controller for the DCNetwork def startRyu(self): # start Ryu controller with rest-API