Tests . Vpp . Func . Interfaces . Eth2P-Eth-L2Bdbasemaclrn-Eth-2Tap-Func
L2Utils.py
def linux_add_bridge(node, br_name, if_1, if_2, set_up=True):
"""Bridge two interfaces on linux node.
:param node: Node to add bridge on.
:param br_name: Bridge name.
:param if_1: First interface to be added to the bridge.
:param if_2: Second interface to be added to the bridge.
:param set_up: Change bridge interface state to up after create bridge.
Optional. Default: True.
:type node: dict
:type br_name: str
:type if_1: str
:type if_2: str
:type set_up: bool
"""
cmd = 'brctl addbr {0}'.format(br_name)
exec_cmd_no_error(node, cmd, sudo=True)
cmd = 'brctl addif {0} {1}'.format(br_name, if_1)
exec_cmd_no_error(node, cmd, sudo=True)
cmd = 'brctl addif {0} {1}'.format(br_name, if_2)
exec_cmd_no_error(node, cmd, sudo=True)
if set_up:
cmd = 'ip link set dev {0} up'.format(br_name)
exec_cmd_no_error(node, cmd, sudo=True)
Logs :
exec_command on ('192.168.122.66', 22): sudo -S brctl addbr tapBr |
|
14:33:57.400 |
TRACE |
exec_command on ('192.168.122.66', 22) took 0.166389942169 seconds |
|
14:33:57.400 |
TRACE |
chan_recv/_stderr took 0.000277996063232 seconds |
|
14:33:57.400 |
TRACE |
return RC 1 |
|
14:33:57.400 |
TRACE |
return STDOUT |
|
14:33:57.401 |
TRACE |
return STDERR sudo: brctl: command not found |
|
14:33:57.402 |
FAIL |
Command execution failed: "brctl addbr tapBr" sudo: brctl: command not found : 1 != 0 |
|
14:33:57.402 |
DEBUG |
Traceback (most recent call last): File "/home/ubuntu/csit/resources/libraries/python/L2Util.py", line 237, in linux_add_bridge exec_cmd_no_error(node, cmd, sudo=True) |