Ondřej Svoboda has uploaded a new change for review.

Change subject: firewall: move the context manager from networkTests to the 
module
......................................................................

firewall: move the context manager from networkTests to the module

Change-Id: I125fed1a54492137675020d6dcbb4c70aa629ec3
Signed-off-by: Ondřej Svoboda <[email protected]>
---
M tests/functional/firewall.py
M tests/functional/networkTests.py
2 files changed, 15 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/43/37743/1

diff --git a/tests/functional/firewall.py b/tests/functional/firewall.py
index 259f296..071e349 100644
--- a/tests/functional/firewall.py
+++ b/tests/functional/firewall.py
@@ -16,8 +16,9 @@
 #
 # Refer to the README and COPYING files for full details of the license
 #
-
+from contextlib import contextmanager
 import logging
+
 from nose.plugins.skip import SkipTest
 
 from vdsm.utils import CommandPath
@@ -32,7 +33,17 @@
     pass
 
 
-def allowDhcp(veth):
+@contextmanager
+def allow_dhcp(interface):
+    """Temporarily allow DHCP traffic in firewall."""
+    _allow_dhcp(interface)
+    try:
+        yield
+    finally:
+        _forbid_dhcp(interface)
+
+
+def _allow_dhcp(veth):
     """Allows DHCP traffic on a testing veth interface.
 
     When using the iptables service, no other traffic is allowed.
@@ -56,7 +67,7 @@
         raise SkipTest('Failed to allow DHCP traffic in firewall: %s' % e)
 
 
-def stopAllowingDhcp(veth):
+def _forbid_dhcp(veth):
     """Removes the rules allowing DHCP on the testing veth interface.
 
     As the interface is expected to be removed from the system,
diff --git a/tests/functional/networkTests.py b/tests/functional/networkTests.py
index 14cb10f..c721062 100644
--- a/tests/functional/networkTests.py
+++ b/tests/functional/networkTests.py
@@ -119,7 +119,7 @@
     except dhcp.DhcpError as e:
         raise SkipTest(e)
 
-    with firewallDhcp(interface):
+    with firewall.allow_dhcp(interface):
         try:
             yield
         finally:
@@ -140,16 +140,6 @@
     finally:
         if has_nm:
             dhcp.removeNMplaceholderConnection(connectionName)
-
-
-@contextmanager
-def firewallDhcp(interface):
-    """ Adds and removes firewall rules for DHCP"""
-    firewall.allowDhcp(interface)
-    try:
-        yield
-    finally:
-        firewall.stopAllowingDhcp(interface)
 
 
 @contextmanager


-- 
To view, visit http://gerrit.ovirt.org/37743
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I125fed1a54492137675020d6dcbb4c70aa629ec3
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ondřej Svoboda <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to