summaryrefslogtreecommitdiffstats
path: root/os_net_config/tests
diff options
context:
space:
mode:
authorDan Prince <dprince@redhat.com>2014-08-14 14:05:05 -0400
committerDan Prince <dprince@redhat.com>2014-08-14 14:05:05 -0400
commit462436fa4d339c80a888def1707f792c33cca715 (patch)
treec1e483e02de39f56062fa8531223b97de98c302f /os_net_config/tests
parent9e515950c7eb4a73e02a4f4883c223dd24ba93ff (diff)
Add --cleanup, and impl for ifcfg
Adds a new cleanup option which can be used to ifdown and remove interfaces that exists but aren't specified in the object model (or JSON).
Diffstat (limited to 'os_net_config/tests')
-rw-r--r--os_net_config/tests/test_impl_ifcfg.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/os_net_config/tests/test_impl_ifcfg.py b/os_net_config/tests/test_impl_ifcfg.py
index aee34d3..a5c621c 100644
--- a/os_net_config/tests/test_impl_ifcfg.py
+++ b/os_net_config/tests/test_impl_ifcfg.py
@@ -14,6 +14,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+import os.path
import tempfile
from os_net_config import impl_ifcfg
@@ -220,6 +221,7 @@ class TestIfcfgNetConfigApply(base.TestCase):
self.temp_ifcfg_file = tempfile.NamedTemporaryFile()
self.temp_route_file = tempfile.NamedTemporaryFile()
self.temp_bridge_file = tempfile.NamedTemporaryFile()
+ self.temp_cleanup_file = tempfile.NamedTemporaryFile()
def test_ifcfg_path(name):
return self.temp_ifcfg_file.name
@@ -233,6 +235,10 @@ class TestIfcfgNetConfigApply(base.TestCase):
return self.temp_bridge_file.name
self.stubs.Set(impl_ifcfg, 'bridge_config_path', test_bridge_path)
+ def test_cleanup_pattern():
+ return self.temp_cleanup_file.name
+ self.stubs.Set(impl_ifcfg, 'cleanup_pattern', test_cleanup_pattern)
+
def test_execute(*args, **kwargs):
pass
self.stubs.Set(processutils, 'execute', test_execute)
@@ -243,6 +249,8 @@ class TestIfcfgNetConfigApply(base.TestCase):
self.temp_ifcfg_file.close()
self.temp_route_file.close()
self.temp_bridge_file.close()
+ if os.path.exists(self.temp_cleanup_file.name):
+ self.temp_cleanup_file.close()
super(TestIfcfgNetConfigApply, self).tearDown()
def test_network_apply(self):
@@ -282,3 +290,7 @@ class TestIfcfgNetConfigApply(base.TestCase):
ifcfg_data = utils.get_file_data(self.temp_ifcfg_file.name)
self.assertEqual(_VLAN_NO_IP, ifcfg_data)
+
+ def test_cleanup(self):
+ self.provider.apply(cleanup=True)
+ self.assertTrue(not os.path.exists(self.temp_cleanup_file.name))