File: test-create-bridge.py

package info (click to toggle)
libnl3 3.7.0-0.2
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 6,624 kB
  • sloc: ansic: 65,616; sh: 4,669; python: 3,702; makefile: 1,005; cpp: 813; yacc: 480; lex: 210
file content (29 lines) | stat: -rw-r--r-- 596 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from __future__ import print_function
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))