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):
20 """clean brs created before.
24 r"brctl show | grep -v '^\s' | awk '{print $1}'|sed '1,1d'",
27 for br in out.split():
36 def _del_br(self, name):
37 check_call('ip link set dev %s down' % name, shell=True)
38 check_call('brctl delbr %s' % name, shell=True)
40 def create_br(self, br_cfg):
41 """Create a bridge(virtual switch). Return True for success, return False for failure.
43 :param dict br_cfg: configuration for bridge creation like
57 name, uplinks = br_cfg['name'], br_cfg['uplinks']
58 check_call("brctl addbr %s" % name, shell=True)
59 for uplink in uplinks:
60 device = get_eth_by_bdf(uplink['bdf'])
61 check_call("ip link set dev %s up" % device, shell=True)
62 check_call("brctl addif %s %s" % (name, device), shell=True)
63 check_call("ip link set dev %s up" % name, shell=True)
66 def set_tap_vid(self, tap_cfg):
67 """linux bridge doesn't support vlan id setting.
71 def set_fastlink(self, br_cfg):
72 """linux bridge doesn't support openflow protocol.