1 ##############################################################################
2 # Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
10 from vstf.agent.env.vswitch_plugins import model
11 from vstf.common.utils import check_call, get_eth_by_bdf, check_output
14 class BridgePlugin(model.VswitchPlugin):
19 """clean brs created before.
22 out = check_output(r"brctl show | grep -v '^\s' | awk '{print $1}'|sed '1,1d'", shell=True)
24 for br in out.split():
33 def _del_br(self, name):
34 check_call('ip link set dev %s down' % name, shell=True)
35 check_call('brctl delbr %s' % name, shell=True)
37 def create_br(self, br_cfg):
38 """Create a bridge(virtual switch). Return True for success, return False for failure.
40 :param dict br_cfg: configuration for bridge creation like
54 name, uplinks = br_cfg['name'], br_cfg['uplinks']
55 check_call("brctl addbr %s" % name, shell=True)
56 for uplink in uplinks:
57 device = get_eth_by_bdf(uplink['bdf'])
58 check_call("ip link set dev %s up" % device, shell=True)
59 check_call("brctl addif %s %s" % (name, device), shell=True)
60 check_call("ip link set dev %s up" % name, shell=True)
63 def set_tap_vid(self, tap_cfg):
64 """linux bridge doesn't support vlan id setting.
68 def set_fastlink(self, br_cfg):
69 """linux bridge doesn't support openflow protocol.