Skip to content

Commit 4e9bffc

Browse files
committed
iproute2: add bridge
1 parent 5fd58c4 commit 4e9bffc

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

test/test_modules.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,3 +738,29 @@ def test_iproute2_netns(host):
738738
namespaces = host.iproute2.netns()
739739
assert len(namespaces) == 1
740740
assert namespaces[0].get("name") == "test"
741+
742+
def test_iproute2_bridge_vlan(host):
743+
assert host.iproute2.bridge_exists
744+
745+
vlans = host.iproute2.bridge_vlan()
746+
assert len(vlans) == 0
747+
748+
def test_iproute2_bridge_fdb(host):
749+
assert host.iproute2.bridge_exists
750+
751+
fdb = host.iproute2.bridge_fdb()
752+
assert len(fdb) > 0
753+
754+
def test_iproute2_bridge_mdb(host):
755+
assert host.iproute2.bridge_exists
756+
757+
mdb = host.iproute2.bridge_mdb()
758+
assert len(mdb) == 1
759+
assert len(mdb[0].get("mdb")) == 0
760+
assert len(mdb[0].get("router")) == 0
761+
762+
def test_iproute2_bridge_link(host):
763+
assert host.iproute2.bridge_exists
764+
765+
links = host.iproute2.bridge_link()
766+
assert len(links) == 0

testinfra/modules/iproute2.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,27 @@ def netns(self):
221221
if not out: # ip netns returns null instead of [] in json mode
222222
return json.loads("[]\n")
223223
return json.loads(out)
224+
225+
def bridge_vlan(self):
226+
"""Returns all configured vlans"""
227+
cmd = f"{self._bridge} -json vlan show"
228+
out = self.check_output(cmd)
229+
return json.loads(out)
230+
231+
def bridge_fdb(self):
232+
"""Returns all configured fdb entries"""
233+
cmd = f"{self._bridge} -json fdb show"
234+
out = self.check_output(cmd)
235+
return json.loads(out)
236+
237+
def bridge_mdb(self):
238+
"""Returns all configured mdb entries"""
239+
cmd = f"{self._bridge} -json mdb show"
240+
out = self.check_output(cmd)
241+
return json.loads(out)
242+
243+
def bridge_link(self):
244+
"""Returns all configured links"""
245+
cmd = f"{self._bridge} -json link show"
246+
out = self.check_output(cmd)
247+
return json.loads(out)

0 commit comments

Comments
 (0)