|
@@ 772-803 (lines=32) @@
|
| 769 |
|
|
| 770 |
|
return flow_mod |
| 771 |
|
|
| 772 |
|
def _prepare_push_flow(self, *args, queue_id=None): |
| 773 |
|
"""Prepare push flow. |
| 774 |
|
|
| 775 |
|
Arguments: |
| 776 |
|
in_interface(str): Interface input. |
| 777 |
|
out_interface(str): Interface output. |
| 778 |
|
in_vlan(str): Vlan input. |
| 779 |
|
out_vlan(str): Vlan output. |
| 780 |
|
|
| 781 |
|
Return: |
| 782 |
|
dict: An python dictionary representing a FlowMod |
| 783 |
|
|
| 784 |
|
""" |
| 785 |
|
# assign all arguments |
| 786 |
|
in_interface, out_interface, in_vlan, out_vlan = args |
| 787 |
|
|
| 788 |
|
flow_mod = self._prepare_flow_mod(in_interface, out_interface, |
| 789 |
|
queue_id) |
| 790 |
|
|
| 791 |
|
# the service tag must be always pushed |
| 792 |
|
new_action = {"action_type": "set_vlan", "vlan_id": out_vlan} |
| 793 |
|
flow_mod["actions"].insert(0, new_action) |
| 794 |
|
|
| 795 |
|
new_action = {"action_type": "push_vlan", "tag_type": "s"} |
| 796 |
|
flow_mod["actions"].insert(0, new_action) |
| 797 |
|
|
| 798 |
|
if in_vlan: |
| 799 |
|
# if in_vlan is set, it must be included in the match |
| 800 |
|
flow_mod['match']['dl_vlan'] = in_vlan |
| 801 |
|
new_action = {"action_type": "pop_vlan"} |
| 802 |
|
flow_mod["actions"].insert(0, new_action) |
| 803 |
|
return flow_mod |
| 804 |
|
|
| 805 |
|
def _prepare_pop_flow(self, in_interface, out_interface, in_vlan, |
| 806 |
|
out_vlan, queue_id=None): |
|
@@ 805-819 (lines=15) @@
|
| 802 |
|
flow_mod["actions"].insert(0, new_action) |
| 803 |
|
return flow_mod |
| 804 |
|
|
| 805 |
|
def _prepare_pop_flow(self, in_interface, out_interface, in_vlan, |
| 806 |
|
out_vlan, queue_id=None): |
| 807 |
|
# pylint: disable=too-many-arguments |
| 808 |
|
"""Prepare pop flow.""" |
| 809 |
|
flow_mod = self._prepare_flow_mod(in_interface, out_interface, |
| 810 |
|
queue_id) |
| 811 |
|
flow_mod['match']['dl_vlan'] = out_vlan |
| 812 |
|
if in_vlan: |
| 813 |
|
new_action = {'action_type': 'set_vlan', 'vlan_id': in_vlan} |
| 814 |
|
flow_mod['actions'].insert(0, new_action) |
| 815 |
|
new_action = {'action_type': 'push_vlan', 'tag_type': 'c'} |
| 816 |
|
flow_mod['actions'].insert(0, new_action) |
| 817 |
|
new_action = {"action_type": "pop_vlan"} |
| 818 |
|
flow_mod["actions"].insert(0, new_action) |
| 819 |
|
return flow_mod |
| 820 |
|
|
| 821 |
|
|
| 822 |
|
class LinkProtection(EVCDeploy): |