Francesco Romani has uploaded a new change for review.

Change subject: WIP: RFC: factor out periodic operations
......................................................................

WIP: RFC: factor out periodic operations

Factor the periodic operation implementations
using a common subclass.
This patch has little benefit on its own, but
helps to reduce the size of the followup patch.

WARNING: this patch is not yet ready for review,
let alone merging. It is a proof of concept and
live demo.

Change-Id: I283331ecfa5b47c147f0a42cd4a6b51a49308fe7
Signed-off-by: Francesco Romani <[email protected]>
---
M vdsm/virt/periodic.py
1 file changed, 18 insertions(+), 30 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/48/44548/4

diff --git a/vdsm/virt/periodic.py b/vdsm/virt/periodic.py
index 632674f..e3801d6 100644
--- a/vdsm/virt/periodic.py
+++ b/vdsm/virt/periodic.py
@@ -256,20 +256,26 @@
         return 'VmDispatcher(%s)' % self._create
 
 
-class UpdateVolumes(object):
+class _RunnableVmOperation(object):
     def __init__(self, vm):
         self._vm = vm
-
-    @property
-    def required(self):
-        # Avoid queries from storage during recovery process
-        return self._vm.isDisksStatsCollectionEnabled()
 
     @property
     def runnable(self):
         return self._vm.isDomainReadyForCommands()
 
     def __call__(self):
+        self._execute()
+
+
+class UpdateVolumes(_RunnableVmOperation):
+
+    @property
+    def required(self):
+        # Avoid queries from storage during recovery process
+        return self._vm.isDisksStatsCollectionEnabled()
+
+    def _execute(self):
         for drive in self._vm.getDiskDevices():
             # TODO: If this block (it is actually possible?)
             # we must make sure we don't overwrite good data
@@ -277,25 +283,17 @@
             self._vm.updateDriveVolume(drive)
 
 
-class NumaInfoMonitor(object):
-    def __init__(self, vm):
-        self._vm = vm
+class NumaInfoMonitor(_RunnableVmOperation):
 
     @property
     def required(self):
         return self._vm.hasGuestNumaNode
 
-    @property
-    def runnable(self):
-        return self._vm.isDomainReadyForCommands()
-
-    def __call__(self):
+    def _execute(self):
         self._vm.updateNumaInfo()
 
 
-class BlockjobMonitor(object):
-    def __init__(self, vm):
-        self._vm = vm
+class BlockjobMonitor(_RunnableVmOperation):
 
     @property
     def required(self):
@@ -306,26 +304,16 @@
         # monitor (most often true).
         return self._vm.hasVmJobs
 
-    @property
-    def runnable(self):
-        return self._vm.isDomainReadyForCommands()
-
-    def __call__(self):
+    def _execute(self):
         self._vm.updateVmJobs()
 
 
-class DriveWatermarkMonitor(object):
-    def __init__(self, vm):
-        self._vm = vm
+class DriveWatermarkMonitor(_RunnableVmOperation):
 
     @property
     def required(self):
         # Avoid queries from storage during recovery process
         return self._vm.isDisksStatsCollectionEnabled()
 
-    @property
-    def runnable(self):
-        return self._vm.isDomainReadyForCommands()
-
-    def __call__(self):
+    def _execute(self):
         self._vm.extendDrivesIfNeeded()


-- 
To view, visit https://gerrit.ovirt.org/44548
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I283331ecfa5b47c147f0a42cd4a6b51a49308fe7
Gerrit-PatchSet: 4
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <[email protected]>
Gerrit-Reviewer: [email protected]
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to