From ce264720a59eea3c1c55bca94f2cb0803b5282eb Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Wed, 9 Jul 2014 13:44:36 -0400 Subject: Don't write 'None' to ifcfg route files. Corrects an issue where 'None' got written into the ifcfg format route files instead of ''. --- os_net_config/impl_ifcfg.py | 4 ++-- os_net_config/tests/test_impl_ifcfg.py | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/os_net_config/impl_ifcfg.py b/os_net_config/impl_ifcfg.py index 271c9f5..2ba7502 100644 --- a/os_net_config/impl_ifcfg.py +++ b/os_net_config/impl_ifcfg.py @@ -169,7 +169,7 @@ class IfcfgNetConfig(os_net_config.NetConfig): update_files = {} for interface_name, iface_data in self.interfaces.iteritems(): - route_data = self.routes.get(interface_name) + route_data = self.routes.get(interface_name, '') if (utils.diff(ifcfg_config_path(interface_name), iface_data) or utils.diff(route_config_path(interface_name), route_data)): restart_interfaces.append(interface_name) @@ -180,7 +180,7 @@ class IfcfgNetConfig(os_net_config.NetConfig): interface_name) for bridge_name, bridge_data in self.bridges.iteritems(): - route_data = self.routes.get(bridge_name) + route_data = self.routes.get(bridge_name, '') if (utils.diff(ifcfg_config_path(bridge_name), bridge_data) or utils.diff(route_config_path(bridge_name), route_data)): restart_bridges.append(bridge_name) diff --git a/os_net_config/tests/test_impl_ifcfg.py b/os_net_config/tests/test_impl_ifcfg.py index d74e405..629f1cf 100644 --- a/os_net_config/tests/test_impl_ifcfg.py +++ b/os_net_config/tests/test_impl_ifcfg.py @@ -110,8 +110,8 @@ class TestIfcfgNetConfig(base.TestCase): def get_interface_config(self, name='em1'): return self.provider.interfaces[name] - def get_route_config(self): - return self.provider.routes['em1'] + def get_route_config(self, name='em1'): + return self.provider.routes.get(name, '') def test_add_base_interface(self): interface = objects.Interface('em1') @@ -129,11 +129,13 @@ class TestIfcfgNetConfig(base.TestCase): interface = objects.Interface('em1', addresses=[v4_addr]) self.provider.addInterface(interface) self.assertEqual(_V4_IFCFG, self.get_interface_config()) + self.assertEqual('', self.get_route_config()) def test_add_interface_with_v6(self): v6_addr = objects.Address('2001:abc:a::/64') interface = objects.Interface('em1', addresses=[v6_addr]) self.provider.addInterface(interface) + self.assertEqual(_V6_IFCFG, self.get_interface_config()) def test_network_with_routes(self): route1 = objects.Route('192.168.1.1', default=True) @@ -253,6 +255,8 @@ class TestIfcfgNetConfigApply(base.TestCase): self.assertEqual(_OVS_INTERFACE, ifcfg_data) bridge_data = utils.get_file_data(self.temp_bridge_file.name) self.assertEqual(_OVS_BRIDGE_DHCP, bridge_data) + route_data = utils.get_file_data(self.temp_route_file.name) + self.assertEqual("", route_data) def test_vlan_apply(self): vlan = objects.Vlan('em1', 5) -- cgit 1.2.3-korg