diff --git a/os_net_config/impl_ifcfg.py b/os_net_config/impl_ifcfg.py index 23354b9b..29144889 100644 --- a/os_net_config/impl_ifcfg.py +++ b/os_net_config/impl_ifcfg.py @@ -1386,11 +1386,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))) diff --git a/os_net_config/tests/test_impl_ifcfg.py b/os_net_config/tests/test_impl_ifcfg.py index c6c97801..9e7f11b8 100644 --- a/os_net_config/tests/test_impl_ifcfg.py +++ b/os_net_config/tests/test_impl_ifcfg.py @@ -1821,6 +1821,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']