Change in vdsm[ovirt-3.6]: virt: periodic: factor out periodic operations

fromani at redhat.com fromani at redhat.com
Wed Nov 11 09:32:22 UTC 2015


Hello Dan Kenigsberg,

I'd like you to do a code review.  Please visit

    https://gerrit.ovirt.org/48413

to review the following change.

Change subject: virt: periodic: factor out periodic operations
......................................................................

virt: periodic: 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 patches.

Backport-To: 3.6
Change-Id: I283331ecfa5b47c147f0a42cd4a6b51a49308fe7
Signed-off-by: Francesco Romani <fromani at redhat.com>
Reviewed-on: https://gerrit.ovirt.org/44548
Continuous-Integration: Jenkins CI
Reviewed-by: Dan Kenigsberg <danken at redhat.com>
---
M tests/periodicTests.py
M vdsm/virt/periodic.py
2 files changed, 15 insertions(+), 29 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/13/48413/1

diff --git a/tests/periodicTests.py b/tests/periodicTests.py
index ce4d592..62a602f 100644
--- a/tests/periodicTests.py
+++ b/tests/periodicTests.py
@@ -237,12 +237,9 @@
     return 'VM-%03i' % i
 
 
-class _Visitor(object):
+class _Visitor(periodic._RunnableOnVm):
 
     VMS = defaultdict(int)
-
-    def __init__(self, vm):
-        self._vm = vm
 
     @property
     def required(self):
@@ -260,9 +257,7 @@
         _Visitor.VMS[self._vm.id] += 1
 
 
-class _Nop(object):
-    def __init__(self, _):
-        pass
+class _Nop(periodic._RunnableOnVm):
 
     @property
     def required(self):
diff --git a/vdsm/virt/periodic.py b/vdsm/virt/periodic.py
index 14ab145..73f447e 100644
--- a/vdsm/virt/periodic.py
+++ b/vdsm/virt/periodic.py
@@ -262,18 +262,21 @@
         return 'VmDispatcher(%s)' % self._create
 
 
-class UpdateVolumes(object):
+class _RunnableOnVm(object):
     def __init__(self, vm):
         self._vm = vm
+
+    @property
+    def runnable(self):
+        return self._vm.isDomainReadyForCommands()
+
+
+class UpdateVolumes(_RunnableOnVm):
 
     @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):
         for drive in self._vm.getDiskDevices():
@@ -283,9 +286,7 @@
             self._vm.updateDriveVolume(drive)
 
 
-class NumaInfoMonitor(object):
-    def __init__(self, vm):
-        self._vm = vm
+class NumaInfoMonitor(_RunnableOnVm):
 
     @property
     def required(self):
@@ -293,15 +294,15 @@
 
     @property
     def runnable(self):
+        # NUMA operations don't require QEMU monitor access
+        # (inspected libvirt sources v1.2.17)
         return True
 
     def __call__(self):
         self._vm.updateNumaInfo()
 
 
-class BlockjobMonitor(object):
-    def __init__(self, vm):
-        self._vm = vm
+class BlockjobMonitor(_RunnableOnVm):
 
     @property
     def required(self):
@@ -312,26 +313,16 @@
         # monitor (most often true).
         return self._vm.hasVmJobs
 
-    @property
-    def runnable(self):
-        return self._vm.isDomainReadyForCommands()
-
     def __call__(self):
         self._vm.updateVmJobs()
 
 
-class DriveWatermarkMonitor(object):
-    def __init__(self, vm):
-        self._vm = vm
+class DriveWatermarkMonitor(_RunnableOnVm):
 
     @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._vm.extendDrivesIfNeeded()


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I283331ecfa5b47c147f0a42cd4a6b51a49308fe7
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.6
Gerrit-Owner: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>


More information about the vdsm-patches mailing list