コード例 #1
0
    def test_mpls_iface(self):
        group = pb.MPLSInterfaceGroup(
            ne_id=1010,
            port_id=1,
            vlan_vid=_VID,
            eth_dst=_ETH_DST_MAC,
            eth_src=_ETH_SRC_MAC,
        )
        mod = pb.GroupMod(re_id=_RE_ID,
                          g_type="MPLS_INTERFACE",
                          mpls_iface=group)

        p2 = fibcdbm.FIBCPortEntry.new(name=_IFNAME,
                                       port=2,
                                       dp_id=_DP_ID,
                                       re_id=_RE_ID)
        p3 = fibcdbm.FIBCPortEntry.new(name=_IFNAME,
                                       port=3,
                                       dp_id=_DP_ID,
                                       re_id=_RE_ID)
        portmap = Mock(spec=fibcdbm.FIBCDbPortMapTable)
        portmap.find_by_vm.return_value = p2
        portmap.lower_port.return_value = p3

        # exec
        fibccnv.conv_group(mod, portmap)
        # check
        self.assertEqual(mod.mpls_iface.port_id, 3)
        portmap.find_by_vm.assert_called_once_with(re_id=_RE_ID, port_id=1)
        portmap.lower_port.assert_called_once_with(p2)
コード例 #2
0
    def on_group_mod(self, evt):
        """
        Process GroupMod event
        """
        mod = evt.msg
        if fibclog.dump_msg():
            _LOG.debug(mod)

        try:
            dpath, mode = _find_dp_by_re_id(mod.re_id)
            if dpath is not None:
                fibccnv.conv_group(mod, fibcdbm.portmap())
                func = ofc.group(mode, mod.g_type)
                func(dpath, mod, ofctl)
                sleep(_SEND_MOD_WAIT_SEC)

        except Exception as expt:
            _LOG.exception(expt)
コード例 #3
0
    def test_conv_l2_interface(self):
        group = pb.L2InterfaceGroup(port_id=1,
                                    vlan_vid=_VID,
                                    vlan_translation=True)
        mod = pb.GroupMod(re_id=_RE_ID, g_type="L2_INTERFACE", l2_iface=group)

        p = fibcdbm.FIBCPortEntry.new(name=_IFNAME,
                                      port=2,
                                      dp_id=_DP_ID,
                                      re_id=_RE_ID)
        portmap = Mock(spec=fibcdbm.FIBCDbPortMapTable)
        portmap.find_by_vm.return_value = p
        portmap.lower_port.return_value = p

        # exec
        fibccnv.conv_group(mod, portmap)
        # check
        self.assertEqual(mod.l2_iface.port_id, 2)
        portmap.find_by_vm.assert_called_once_with(re_id=_RE_ID, port_id=1)
        portmap.lower_port.assert_called_once_with(p)
コード例 #4
0
    def test_l3_unicast(self):
        group = pb.L3UnicastGroup(
            ne_id=1010,
            port_id=1,
            vlan_vid=_VID,
            eth_dst=_ETH_DST_MAC,
            eth_src=_ETH_SRC_MAC,
        )
        mod = pb.GroupMod(re_id=_RE_ID, g_type="L3_UNICAST", l3_unicast=group)

        p = fibcdbm.FIBCPortEntry.new(name=_IFNAME,
                                      port=2,
                                      dp_id=_DP_ID,
                                      re_id=_RE_ID)
        portmap = Mock(spec=fibcdbm.FIBCDbPortMapTable)
        portmap.find_by_vm.return_value = p
        portmap.lower_port.return_value = p

        # exec
        fibccnv.conv_group(mod, portmap)
        # check
        self.assertEqual(mod.l3_unicast.port_id, 2)
        portmap.find_by_vm.assert_called_once_with(re_id=_RE_ID, port_id=1)
        portmap.lower_port.assert_called_once_with(p)