Code Duplication    Length = 15-32 lines in 2 locations

models/evc.py 2 locations

@@ 687-718 (lines=32) @@
684
685
        return flow_mod
686
687
    def _prepare_push_flow(self, *args, queue_id=None):
688
        """Prepare push flow.
689
690
        Arguments:
691
            in_interface(str): Interface input.
692
            out_interface(str): Interface output.
693
            in_vlan(str): Vlan input.
694
            out_vlan(str): Vlan output.
695
696
        Return:
697
            dict: An python dictionary representing a FlowMod
698
699
        """
700
        # assign all arguments
701
        in_interface, out_interface, in_vlan, out_vlan = args
702
703
        flow_mod = self._prepare_flow_mod(in_interface, out_interface,
704
                                          queue_id)
705
706
        # the service tag must be always pushed
707
        new_action = {"action_type": "set_vlan", "vlan_id": out_vlan}
708
        flow_mod["actions"].insert(0, new_action)
709
710
        new_action = {"action_type": "push_vlan", "tag_type": "s"}
711
        flow_mod["actions"].insert(0, new_action)
712
713
        if in_vlan:
714
            # if in_vlan is set, it must be included in the match
715
            flow_mod['match']['dl_vlan'] = in_vlan
716
            new_action = {"action_type": "pop_vlan"}
717
            flow_mod["actions"].insert(0, new_action)
718
        return flow_mod
719
720
    def _prepare_pop_flow(self, in_interface, out_interface, in_vlan,
721
                          out_vlan, queue_id=None):
@@ 720-734 (lines=15) @@
717
            flow_mod["actions"].insert(0, new_action)
718
        return flow_mod
719
720
    def _prepare_pop_flow(self, in_interface, out_interface, in_vlan,
721
                          out_vlan, queue_id=None):
722
        # pylint: disable=too-many-arguments
723
        """Prepare pop flow."""
724
        flow_mod = self._prepare_flow_mod(in_interface, out_interface,
725
                                          queue_id)
726
        flow_mod['match']['dl_vlan'] = out_vlan
727
        if in_vlan:
728
            new_action = {'action_type': 'set_vlan', 'vlan_id': in_vlan}
729
            flow_mod['actions'].insert(0, new_action)
730
            new_action = {'action_type': 'push_vlan', 'tag_type': 'c'}
731
            flow_mod['actions'].insert(0, new_action)
732
        new_action = {"action_type": "pop_vlan"}
733
        flow_mod["actions"].insert(0, new_action)
734
        return flow_mod
735
736
    @staticmethod
737
    def run_sdntrace(uni):