+
+ def _set_flow_entry_dpctl(self, node, switch_inport_nr, switch_outport_nr, **kwargs):
+ match = 'in_port=%s' % switch_inport_nr
+
+ cookie = kwargs.get('cookie')
+ match_input = kwargs.get('match')
+ cmd = kwargs.get('cmd')
+ path = kwargs.get('path')
+ current_hop = kwargs.get('current_hop')
+ vlan = kwargs.get('vlan')
+
+ s = ','
+ if cookie:
+ cookie = 'cookie=%s' % cookie
+ match = s.join([cookie, match])
+ if match_input:
+ match = s.join([match, match_input])
+ if cmd == 'add-flow':
+ action = 'action=%s' % switch_outport_nr
+ if vlan != None:
+ if path.index(current_hop) == 0: # first node
+ action = ('action=mod_vlan_vid:%s' % vlan) + (',output=%s' % switch_outport_nr)
+ match = '-O OpenFlow13 ' + match
+ elif path.index(current_hop) == len(path) - 1: # last node
+ match += ',dl_vlan=%s' % vlan
+ action = 'action=strip_vlan,output=%s' % switch_outport_nr
+ else: # middle nodes
+ match += ',dl_vlan=%s' % vlan
+ ofcmd = s.join([match, action])
+ elif cmd == 'del-flows':
+ ofcmd = match
+ else:
+ ofcmd = ''
+
+ node.dpctl(cmd, ofcmd)
+ logging.info("{3} in switch: {0} in_port: {1} out_port: {2}".format(node.name, switch_inport_nr,
+ switch_outport_nr, cmd))