flow_entry = FlowEntry() table_id = 0 flow_id = 29 flow_entry.set_flow_table_id(table_id) flow_entry.set_flow_id(flow_id) flow_entry.set_flow_name(flow_name="Change MPLS Label") flow_entry.set_flow_hard_timeout(hard_timeout=0) flow_entry.set_flow_idle_timeout(idle_timeout=0) flow_entry.set_flow_priority(flow_priority=1022) flow_entry.set_flow_cookie(cookie=401) flow_entry.set_flow_cookie_mask(cookie_mask=255) # --- Instruction: 'Apply-actions' # Actions: 'Set Field' # 'Output' instruction = Instruction(instruction_order=0) action = SetFieldAction(order=0) action.set_mpls_label(new_mpls_label) instruction.add_apply_action(action) action = OutputAction(order=1, port=2) instruction.add_apply_action(action) flow_entry.add_instruction(instruction) # --- Match Fields: Ethernet Type # Input Port # MPLS Label match = Match() match.set_eth_type(eth_type) match.set_in_port(in_port) match.set_mpls_label(mpls_label) flow_entry.add_match(match)
print (" Action: Output (CONTROLLER)") time.sleep(rundelay) flow_entry = FlowEntry() table_id = 0 flow_entry.set_flow_table_id(table_id) flow_id = 15 flow_entry.set_flow_id(flow_id) flow_entry.set_flow_priority(flow_priority=1006) flow_entry.set_flow_cookie(cookie=100) flow_entry.set_flow_cookie_mask(cookie_mask=255) # --- Instruction: 'Apply-actions' # Action: 'Output' to CONTROLLER instruction = Instruction(instruction_order=0) action = OutputAction(order=0, port="CONTROLLER", max_len=60) instruction.add_apply_action(action) flow_entry.add_instruction(instruction) # --- Match Fields: Ethernet Type # Ethernet Source Address # Ethernet Destination Address # IPv4 Source Address # IPv4 Destination Address # IP Protocol Number # IP DSCP # Input Port match = Match() match.set_eth_type(eth_type) match.set_eth_src(eth_src)