def test_list_by_link_ref(self): dpid = 100 reid = "1.1.1.1" _ports = [ dict(name="10/eth1", port=1), dict(name="20/eth1", port=2), dict(name="20/eth2", port=3), dict(name="10/eth1.10", port=0, link="10/eth1"), dict(name="20/eth2.10", port=0, link="20/eth2"), dict(name="20/eth2.20", port=0, link="20/eth2"), ] ports = [fibcdbm.FIBCPortEntry.new(dp_id=dpid, re_id=reid, **p) for p in _ports] table = fibcdbm.FIBCDbPortMapTable() for port in ports: table.add(port) # 10/eth1 -> 10/eth1.10 link = portmap.FIBCLink(re_id=reid, name="10/eth1") ret = table.list_by_link_ref(link) self.assertEqual(ret, ports[3:4]) # 20/eth2 -> 20/eth2.10, 20/eth2.20 link = portmap.FIBCLink(re_id=reid, name="20/eth2") ret = table.list_by_link_ref(link) self.assertEqual(ret, ports[4:6]) # 20/eth1 -> [] link = portmap.FIBCLink(re_id=reid, name="20/eth1") ret = table.list_by_link_ref(link) self.assertEqual(ret, [])
def test_create_port_bond(self): dpid = 100 reid = "1.1.1.1" name = "ethX" slaves = ["ethA", "ethB"] # exec ret = fibcdbm.FIBCPortEntry.new(dp_id=dpid, re_id=reid, name=name, port=1, slaves=slaves) # check expect = dict( dp=portmap.FIBCPort(dpid, 1), vm=portmap.FIBCPort(reid, 0), vs=portmap.FIBCPort(0, 0), name=portmap.FIBCLink(reid, name), link=None, dpenter=False, slaves=[ portmap.FIBCLink(reid, slaves[0]), portmap.FIBCLink(reid, slaves[1]), ], ) self.assertEqual(ret, expect)
def test_create_port_vlan(self): dpid = 100 reid = "1.1.1.1" name = "ethX" link = "ethY" # exec ret = fibcdbm.FIBCPortEntry.new( dp_id=dpid, re_id=reid, name=name, port=1, link=link) # check expect = dict( dp=portmap.FIBCPort(dpid, 1), vm=portmap.FIBCPort(reid, 0), vs=portmap.FIBCPort(0, 0), name=portmap.FIBCLink(reid, name), link=portmap.FIBCLink(reid, link), dpenter=False, no_vs=False, vs_hw_addr="", ) self.assertEqual(ret, expect)