Yeela Kaplan has uploaded a new change for review.

Change subject: Final separation of IOProcess and RFH
......................................................................

Final separation of IOProcess and RFH

From now on vdsm will either fully use
remoteFileHandler implementation or
IOProcess implementation for out of process(oop).

Change-Id: Ief85d2dca2d22058c4ed2504e49dc3dd62547532
Signed-off-by: Yeela Kaplan <[email protected]>
---
M vdsm/storage/outOfProcess.py
1 file changed, 43 insertions(+), 36 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/88/28088/1

diff --git a/vdsm/storage/outOfProcess.py b/vdsm/storage/outOfProcess.py
index 68be884..b360e78 100644
--- a/vdsm/storage/outOfProcess.py
+++ b/vdsm/storage/outOfProcess.py
@@ -42,7 +42,6 @@
 
 _procLock = threading.Lock()
 _proc = {}
-_ioproc = {GLOBAL: None}
 
 log = logging.getLogger('oop')
 
@@ -57,11 +56,13 @@
         return _proc[clientName]
     except KeyError:
         with _procLock:
-            if _oopImpl == IOPROC and _ioproc[GLOBAL] is None:
-                _ioproc[GLOBAL] = IOProcess(DEFAULT_TIMEOUT)
-
-            _proc[clientName] = OopWrapper(
-                RemoteFileHandlerPool(HELPERS_PER_DOMAIN), _ioproc[GLOBAL])
+            if _oopImpl == IOPROC:
+                if _proc[GLOBAL] is None:
+                    _proc[GLOBAL] = OopWrapper(IOProcess(DEFAULT_TIMEOUT))
+                _proc[clientName] = _proc[GLOBAL]
+            else:
+                _proc[clientName] = OopWrapper(
+                    RemoteFileHandlerPool(HELPERS_PER_DOMAIN))
 
             return _proc[clientName]
 
@@ -240,8 +241,33 @@
     ioprocess.truncate(path, size, mode, creatExcl)
 
 
+class _IOProcWrapper(types.ModuleType):
+    def __init__(self, modname, ioproc):
+        self._modName = modname
+        self._ioproc = ioproc
+        self.glob = _IOProcessGlob(ioproc)
+        self.fileUtils.cleanupdir = \
+            _IOProcessFileUtils(ioproc).cleanupdir
+        self.fileUtils.createdir = \
+            _IOProcessFileUtils(ioproc).createdir
+        self.fileUtils.validateAccess = \
+            _IOProcessFileUtils(ioproc).validateAccess
+        self.fileUtils.pathExists = \
+            _IOProcessFileUtils(ioproc).pathExists
+        self.os.chmod = _IOProcessOs(ioproc).chmod
+        self.os.statvfs = _IOProcessOs(ioproc).statvfs
+        self.os.rename = _IOProcessOs(ioproc).rename
+        self.os.unlink = _IOProcessOs(ioproc).unlink
+        self.os.path = _IOProcessOs(ioproc).path
+        self.directReadLines = partial(directReadLines, ioproc)
+        self.writeLines = partial(writeLines, ioproc)
+        self.simpleWalk = partial(simpleWalk, ioproc)
+        self.directTouch = partial(directTouch, ioproc)
+        self.truncateFile = partial(truncateFile, ioproc)
+
+
 class _ModuleWrapper(types.ModuleType):
-    def __init__(self, modName, procPool, ioproc, timeout, subModNames=()):
+    def __init__(self, modName, procPool, timeout, subModNames=()):
         self._modName = modName
         self._procPool = procPool
         self._timeout = timeout
@@ -256,31 +282,9 @@
             setattr(self, subModName,
                     _ModuleWrapper(fullModName,
                                    self._procPool,
-                                   ioproc,
                                    DEFAULT_TIMEOUT,
                                    subSubModNames)
                     )
-
-        if ioproc:
-            self.glob = _IOProcessGlob(ioproc)
-            self.fileUtils.cleanupdir = \
-                _IOProcessFileUtils(ioproc).cleanupdir
-            self.fileUtils.createdir = \
-                _IOProcessFileUtils(ioproc).createdir
-            self.fileUtils.validateAccess = \
-                _IOProcessFileUtils(ioproc).validateAccess
-            self.fileUtils.pathExists = \
-                _IOProcessFileUtils(ioproc).pathExists
-            self.os.chmod = _IOProcessOs(ioproc).chmod
-            self.os.statvfs = _IOProcessOs(ioproc).statvfs
-            self.os.rename = _IOProcessOs(ioproc).rename
-            self.os.unlink = _IOProcessOs(ioproc).unlink
-            self.os.path = _IOProcessOs(ioproc).path
-            self.directReadLines = partial(directReadLines, ioproc)
-            self.writeLines = partial(writeLines, ioproc)
-            self.simpleWalk = partial(simpleWalk, ioproc)
-            self.directTouch = partial(directTouch, ioproc)
-            self.truncateFile = partial(truncateFile, ioproc)
 
     def __getattr__(self, name):
         # Root modules is fake, we need to remove it
@@ -290,10 +294,13 @@
                        fullName)
 
 
-def OopWrapper(procPool, ioproc=None):
-    return _ModuleWrapper("oop", procPool, ioproc, DEFAULT_TIMEOUT,
-                          (("os",
-                            ("path",)),
-                           "glob",
-                           "fileUtils",
-                           "utils"))
+def OopWrapper(procPool):
+    if _oopImpl == IOPROC:
+        return _IOProcWrapper("oop", procPool)
+    else:
+        return _ModuleWrapper("oop", procPool, DEFAULT_TIMEOUT,
+                              (("os",
+                                ("path",)),
+                               "glob",
+                               "fileUtils",
+                               "utils"))


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

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

Reply via email to