@@ 750-781 (lines=32) @@ | ||
747 | ||
748 | return flow_mod |
|
749 | ||
750 | def _prepare_push_flow(self, *args, queue_id=None): |
|
751 | """Prepare push flow. |
|
752 | ||
753 | Arguments: |
|
754 | in_interface(str): Interface input. |
|
755 | out_interface(str): Interface output. |
|
756 | in_vlan(str): Vlan input. |
|
757 | out_vlan(str): Vlan output. |
|
758 | ||
759 | Return: |
|
760 | dict: An python dictionary representing a FlowMod |
|
761 | ||
762 | """ |
|
763 | # assign all arguments |
|
764 | in_interface, out_interface, in_vlan, out_vlan = args |
|
765 | ||
766 | flow_mod = self._prepare_flow_mod( |
|
767 | in_interface, out_interface, queue_id |
|
768 | ) |
|
769 | ||
770 | # the service tag must be always pushed |
|
771 | new_action = {"action_type": "set_vlan", "vlan_id": out_vlan} |
|
772 | flow_mod["actions"].insert(0, new_action) |
|
773 | ||
774 | new_action = {"action_type": "push_vlan", "tag_type": "s"} |
|
775 | flow_mod["actions"].insert(0, new_action) |
|
776 | ||
777 | if in_vlan: |
|
778 | # if in_vlan is set, it must be included in the match |
|
779 | flow_mod["match"]["dl_vlan"] = in_vlan |
|
780 | new_action = {"action_type": "pop_vlan"} |
|
781 | flow_mod["actions"].insert(0, new_action) |
|
782 | return flow_mod |
|
783 | ||
784 | def _prepare_pop_flow( |
|
@@ 784-798 (lines=15) @@ | ||
781 | flow_mod["actions"].insert(0, new_action) |
|
782 | return flow_mod |
|
783 | ||
784 | def _prepare_pop_flow( |
|
785 | self, in_interface, out_interface, in_vlan, out_vlan, queue_id=None |
|
786 | ): |
|
787 | # pylint: disable=too-many-arguments |
|
788 | """Prepare pop flow.""" |
|
789 | flow_mod = self._prepare_flow_mod( |
|
790 | in_interface, out_interface, queue_id |
|
791 | ) |
|
792 | flow_mod["match"]["dl_vlan"] = out_vlan |
|
793 | if in_vlan: |
|
794 | new_action = {"action_type": "set_vlan", "vlan_id": in_vlan} |
|
795 | flow_mod["actions"].insert(0, new_action) |
|
796 | new_action = {"action_type": "push_vlan", "tag_type": "c"} |
|
797 | flow_mod["actions"].insert(0, new_action) |
|
798 | new_action = {"action_type": "pop_vlan"} |
|
799 | flow_mod["actions"].insert(0, new_action) |
|
800 | return flow_mod |
|
801 |