summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorNicolas PLANEL <nicolas.planel@enovance.com>2013-10-10 22:34:18 +0000
committerThomas Graf <tgraf@suug.ch>2013-10-22 14:20:41 +0200
commit07669b0b80902a166686ccb8135f971205a01281 (patch)
tree970194adcfc23697ebc3a7e0650078acaf616d24 /python
parentdefebe30c657aee9a40c4cf331659e7a285c2f65 (diff)
downloadlibnl-07669b0b80902a166686ccb8135f971205a01281.tar.gz
test: add python bridge testing sample
New test sample file, test-create-bridge.py Create an bridge (testbrige) and attach an already setup interface (testtap1) to it. Signed-off-by: Nicolas PLANEL <nicolas.planel@enovance.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
Diffstat (limited to 'python')
-rw-r--r--python/tests/test-create-bridge.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/python/tests/test-create-bridge.py b/python/tests/test-create-bridge.py
new file mode 100644
index 00000000..216b2491
--- /dev/null
+++ b/python/tests/test-create-bridge.py
@@ -0,0 +1,28 @@
+import netlink.core as netlink
+import netlink.route.capi as capi
+import netlink.route.link as link
+
+sock = netlink.lookup_socket(netlink.NETLINK_ROUTE)
+
+cache = link.LinkCache()
+cache.refill(sock)
+
+testtap1 = cache['testtap1']
+print testtap1
+
+lbr = link.Link()
+lbr.type = 'bridge'
+lbr.name = 'testbridge'
+print lbr
+lbr.add()
+
+cache.refill(sock)
+lbr = cache['testbridge']
+print lbr
+
+lbr.enslave(testtap1)
+cache.refill(sock)
+testtap1 = cache['testtap1']
+
+print capi.rtnl_link_is_bridge(lbr._rtnl_link)
+print capi.rtnl_link_get_master(testtap1._rtnl_link)