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>
This commit is contained in:
parent
defebe30c6
commit
07669b0b80
1 changed files with 28 additions and 0 deletions
28
python/tests/test-create-bridge.py
Normal file
28
python/tests/test-create-bridge.py
Normal file
|
@ -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)
|
Loading…
Add table
Reference in a new issue