File: test-create-bridge.py

package info (click to toggle)
libnl3 3.2.24-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 4,876 kB
  • ctags: 9,179
  • sloc: ansic: 41,143; sh: 11,605; python: 3,697; yacc: 476; makefile: 474; cpp: 454; lex: 202
file content (28 lines) | stat: -rw-r--r-- 553 bytes parent folder | download | duplicates (4)
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
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)