Change in vdsm[master]: configNet: introduce ConfigWriter.restorePersistentBackup()

danken at redhat.com danken at redhat.com
Sun Aug 26 08:43:52 UTC 2012


Dan Kenigsberg has uploaded a new change for review.

Change subject: configNet: introduce ConfigWriter.restorePersistentBackup()
......................................................................

configNet: introduce ConfigWriter.restorePersistentBackup()

restorePersistentBackup is to be called before vdsm starts, via
vdsm-restore-net-config, to load persistent backup into memory, make
them effective again, and remove the backup.

This patch makes a single function out of this in order to fix the
currently-broken testPersistentBackup test case.

Change-Id: I31e1f6a2cce082fcc82da37663518edec6c9d095
Signed-off-by: Dan Kenigsberg <danken at redhat.com>
---
M tests/configNetworkTests.py
M vdsm/configNetwork.py
M vdsm/vdsm-restore-net-config
3 files changed, 12 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/63/7463/1

diff --git a/tests/configNetworkTests.py b/tests/configNetworkTests.py
index b888667..f6dc402 100644
--- a/tests/configNetworkTests.py
+++ b/tests/configNetworkTests.py
@@ -357,14 +357,13 @@
         cw.restoreAtomicBackup()
         self._assertFilesRestored()
 
-    @brokentest('Fixing this test requires more monkeypatching '
-                'than I can handle')
     @MonkeyPatch(os, 'chown', lambda *x: 0)
     def testPersistentBackup(self):
 
         with MonkeyPatchScope([
             (netinfo, 'NET_CONF_BACK_DIR',
-            os.path.join(self._tempdir, 'netback'))
+             os.path.join(self._tempdir, 'netback')),
+            (netinfo, 'NET_CONF_DIR', self._tempdir),
         ]):
             #after vdsm package is installed, the 'vdsm' account will be
             #created if no 'vdsm' account, we should skip this test
@@ -380,9 +379,7 @@
 
             self._makeFilesDirty()
 
-            subprocess.call(['../vdsm/vdsm-restore-net-config',
-                             '--skip-net-restart'],
-                    env={'NET_CONF_BACK_DIR': netinfo.NET_CONF_BACK_DIR,
-                         'NET_CONF_DIR': self._tempdir})
+            cw = configNetwork.ConfigWriter()
+            cw.restorePersistentBackup()
 
             self._assertFilesRestored()
diff --git a/vdsm/configNetwork.py b/vdsm/configNetwork.py
index 0dc5f34..62a3ccc 100755
--- a/vdsm/configNetwork.py
+++ b/vdsm/configNetwork.py
@@ -312,6 +312,13 @@
 
         cls.writeBackupFile(netinfo.NET_CONF_BACK_DIR, basename, content)
 
+    def restorePersistentBackup(self):
+        """Restore network config to last known 'safe' state"""
+
+        self.loadBackups()
+        self.restoreBackups()
+        self.clearBackups()
+
     def _loadBackupFiles(self, loadDir, restoreDir=None):
         for fpath in glob.iglob(loadDir + '/*'):
             if not os.path.isfile(fpath):
diff --git a/vdsm/vdsm-restore-net-config b/vdsm/vdsm-restore-net-config
index a805f93..a879969 100755
--- a/vdsm/vdsm-restore-net-config
+++ b/vdsm/vdsm-restore-net-config
@@ -36,9 +36,7 @@
         pass
 
     configWriter = configNetwork.ConfigWriter()
-    configWriter.loadBackups()
-    configWriter.restoreBackups()
-    configWriter.clearBackups()
+    configWriter.restorePersistentBackup()
 
 
 if __name__ == '__main__':


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I31e1f6a2cce082fcc82da37663518edec6c9d095
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken at redhat.com>


More information about the vdsm-patches mailing list