Code Duplication    Length = 15-32 lines in 2 locations

models/evc.py 2 locations

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