Merge "Ignore bridge already exists error when creating bridge" into stable/kilo
This commit is contained in:
commit
e68404ec8b
@ -1599,7 +1599,13 @@ class LinuxBridgeInterfaceDriver(LinuxNetInterfaceDriver):
|
||||
"""
|
||||
if not device_exists(bridge):
|
||||
LOG.debug('Starting Bridge %s', bridge)
|
||||
_execute('brctl', 'addbr', bridge, run_as_root=True)
|
||||
out, err = _execute('brctl', 'addbr', bridge,
|
||||
check_exit_code=False, run_as_root=True)
|
||||
if (err and err != "device %s already exists; can't create "
|
||||
"bridge with the same name\n" % (bridge)):
|
||||
msg = _('Failed to add bridge: %s') % err
|
||||
raise exception.NovaException(msg)
|
||||
|
||||
_execute('brctl', 'setfd', bridge, 0, run_as_root=True)
|
||||
# _execute('brctl setageing %s 10' % bridge, run_as_root=True)
|
||||
_execute('brctl', 'stp', bridge, 'off', run_as_root=True)
|
||||
|
@ -1164,6 +1164,22 @@ class LinuxNetworkTestCase(test.NoDBTestCase):
|
||||
driver.ensure_bridge, 'bridge', 'eth0')
|
||||
device_exists.assert_called_once_with('bridge')
|
||||
|
||||
def test_ensure_bridge_brclt_addbr_neutron_race(self):
|
||||
def fake_execute(*cmd, **kwargs):
|
||||
if ('brctl', 'addbr', 'brq1234567-89') == cmd:
|
||||
return ('', "device brq1234567-89 already exists; "
|
||||
"can't create bridge with the same name\n")
|
||||
else:
|
||||
return ('', '')
|
||||
|
||||
with contextlib.nested(
|
||||
mock.patch.object(linux_net, 'device_exists', return_value=False),
|
||||
mock.patch.object(linux_net, '_execute', fake_execute)
|
||||
) as (device_exists, _):
|
||||
driver = linux_net.LinuxBridgeInterfaceDriver()
|
||||
driver.ensure_bridge('brq1234567-89', '')
|
||||
device_exists.assert_called_once_with('brq1234567-89')
|
||||
|
||||
def test_set_device_mtu_configured(self):
|
||||
self.flags(network_device_mtu=10000)
|
||||
calls = [
|
||||
|
Loading…
Reference in New Issue
Block a user