aboutsummaryrefslogtreecommitdiffstats
path: root/os_net_config/tests/test_impl_eni.py
diff options
context:
space:
mode:
authorSteven Hardy <shardy@redhat.com>2015-01-26 18:44:21 +0000
committerSteven Hardy <shardy@redhat.com>2015-03-05 13:11:09 +0000
commit3304fa066d1dae93df0f597c1709c955e3857a5d (patch)
treeb5347080f433cdc99b0b8e1f386b7bb5437ae09f /os_net_config/tests/test_impl_eni.py
parent4cf8c1a0fd3c029ea81092a8901d786bfce77735 (diff)
Add a --no-activate option to disable device up/down actions
Allows you to only install the config, but not take interfaces down/up. Useful if you wish to defer activation of a new config until a later time (e.g reboot). Change-Id: I42f3195e1d3d5d3b9d1c9dbb1f7cf1364503cbd3
Diffstat (limited to 'os_net_config/tests/test_impl_eni.py')
-rw-r--r--os_net_config/tests/test_impl_eni.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/os_net_config/tests/test_impl_eni.py b/os_net_config/tests/test_impl_eni.py
index 9322017..e5a712e 100644
--- a/os_net_config/tests/test_impl_eni.py
+++ b/os_net_config/tests/test_impl_eni.py
@@ -207,13 +207,17 @@ class TestENINetConfigApply(base.TestCase):
def setUp(self):
super(TestENINetConfigApply, self).setUp()
self.temp_config_file = tempfile.NamedTemporaryFile()
+ self.ifup_interface_names = []
def test_config_path():
return self.temp_config_file.name
self.stubs.Set(impl_eni, '_network_config_path', test_config_path)
def test_execute(*args, **kwargs):
+ if args[0] == '/sbin/ifup':
+ self.ifup_interface_names.append(args[1])
pass
+
self.stubs.Set(processutils, 'execute', test_execute)
self.provider = impl_eni.ENINetConfig()
@@ -232,6 +236,19 @@ class TestENINetConfigApply(base.TestCase):
self.provider.apply()
iface_data = utils.get_file_data(self.temp_config_file.name)
self.assertEqual((_V4_IFACE_STATIC_IP + _RTS), iface_data)
+ self.assertIn('eth0', self.ifup_interface_names)
+
+ def test_apply_noactivate(self):
+ route = objects.Route('192.168.1.1', '172.19.0.0/24')
+ v4_addr = objects.Address('192.168.1.2/24')
+ interface = objects.Interface('eth0', addresses=[v4_addr],
+ routes=[route])
+ self.provider.add_interface(interface)
+
+ self.provider.apply(activate=False)
+ iface_data = utils.get_file_data(self.temp_config_file.name)
+ self.assertEqual((_V4_IFACE_STATIC_IP + _RTS), iface_data)
+ self.assertEqual([], self.ifup_interface_names)
def test_dhcp_ovs_bridge_network_apply(self):
interface = objects.Interface('eth0')
@@ -242,3 +259,5 @@ class TestENINetConfigApply(base.TestCase):
self.provider.apply()
iface_data = utils.get_file_data(self.temp_config_file.name)
self.assertEqual((_OVS_BRIDGE_DHCP + _OVS_PORT_IFACE), iface_data)
+ self.assertIn('eth0', self.ifup_interface_names)
+ self.assertIn('br0', self.ifup_interface_names)