Exemple #1
0
    def test_term_mac(self):
        flow = pb.TerminationMacFlow(match=pb.TerminationMacFlow.Match(
            in_port=1, eth_type=0x0800, eth_dst=_ETH_DST, vlan_vid=_VID),
                                     actions=[],
                                     goto_table=pb.FlowMod.UNICAST_ROUTING)
        mod = pb.FlowMod(cmd="ADD",
                         table=pb.FlowMod.TERM_MAC,
                         re_id=_RE_ID,
                         term_mac=flow)

        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_flow(mod, portmap)

        #check
        self.assertEqual(mod.cmd, pb.FlowMod.ADD)
        self.assertEqual(mod.table, pb.FlowMod.TERM_MAC)
        self.assertEqual(mod.re_id, _RE_ID)
        self.assertEqual(mod.term_mac.match.in_port, 2)
        self.assertEqual(mod.term_mac.match.eth_type, 0x0800)
        self.assertEqual(mod.term_mac.match.eth_dst, _ETH_DST)
        self.assertEqual(mod.term_mac.match.vlan_vid, _VID)
        self.assertEqual(len(mod.term_mac.actions), 0)
        self.assertEqual(mod.term_mac.goto_table, pb.FlowMod.UNICAST_ROUTING)
Exemple #2
0
    def test_new(self):
        match = pb.TerminationMacFlow.Match(eth_type=0x0800, eth_dst="11:22:33:44:55:66")
        actions = []
        flow = pb.TerminationMacFlow(match=match, actions=actions, goto_table=30)
        mod = pb.FlowMod(cmd="ADD", table="TERM_MAC", term_mac=flow)

        b = mod.SerializeToString()
        m = api.parse_flow_mod(b)

        self.assertEqual(str(mod), str(m))
Exemple #3
0
    def _mod_flow_termmac(self, msg):
        re_id = msg["re_id"]
        cmd = msg["cmd"]
        for arg in msg["args"]:
            match = pb.TerminationMacFlow.Match(eth_type=arg["eth_type"], eth_dst=arg["eth_dst"])
            flow = pb.TerminationMacFlow(match=match, actions=[], goto_table=arg["goto"])
            mod = pb.FlowMod(cmd=cmd, re_id=re_id, table="TERM_MAC", term_mac=flow)
            evt = fibcevt.EventFIBCFlowMod(mod)

            self.app.send_event_to_observers(evt)