Merge "Fix os-net-config interface restarts when applying routes" into stable/queens

This commit is contained in:
Zuul 2019-03-19 17:21:51 +00:00 committed by Gerrit Code Review
commit a0cb5c247a
2 changed files with 8 additions and 3 deletions

View File

@ -1385,11 +1385,14 @@ class IfcfgNetConfig(os_net_config.NetConfig):
for interface in apply_routes:
logger.debug('Applying routes for interface %s' % interface[0])
commands = self.iproute2_route_commands(interface[0],
interface[1])
filename = self.root_dir + route_config_path(interface[0])
commands = self.iproute2_route_commands(filename, interface[1])
for command in commands:
args = command.split()
try:
self.execute('Running ip %s' % command, ipcmd, command)
if len(args) > 0:
self.execute('Running ip %s' % command, ipcmd,
*args)
except Exception as e:
logger.warning("Error in 'ip %s', restarting %s:\n%s" %
(command, interface[0], str(e)))

View File

@ -1786,6 +1786,8 @@ class TestIfcfgNetConfigApply(base.TestCase):
expected_commands = ['addr add 192.168.1.2/24 dev em1',
'addr del 192.168.0.2/23 dev em1',
'link set dev em1 mtu 1500',
'route del default via 192.168.1.1 dev em1',
'route del 172.19.0.0/24 via 192.168.1.1 dev em1',
'route add default via 192.168.0.1 dev em1',
'route add 172.19.0.0/24 via 192.168.0.1 dev em1']