Francesco Romani has uploaded a new change for review.

Change subject: migration: make downtime steps instance attributes
......................................................................

migration: make downtime steps instance attributes

Move the DowntimeThread steps from class constant
to instance attribute, to make the coder more testable.

Change-Id: I326439ad42a108c7f194cf9e8ede1c0e8e4ffec8
Signed-off-by: Francesco Romani <[email protected]>
---
M vdsm/virt/migration.py
1 file changed, 8 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/78/42578/1

diff --git a/vdsm/virt/migration.py b/vdsm/virt/migration.py
index 1e9710e..dd6b7d1 100644
--- a/vdsm/virt/migration.py
+++ b/vdsm/virt/migration.py
@@ -342,7 +342,10 @@
             self._vm.log.info('starting migration to %s '
                               'with miguri %s', duri, muri)
 
-            downtimeThread = DowntimeThread(self._vm, int(self._downtime))
+            downtimeThread = DowntimeThread(self._vm,
+                                            int(self._downtime),
+                                            config.getint('vars',
+                                                'migration_downtime_steps'))
             self._monitorThread = MonitorThread(self._vm, startTime)
             with utils.running(downtimeThread):
                 with utils.running(self._monitorThread):
@@ -410,13 +413,12 @@
 
 
 class DowntimeThread(threading.Thread):
-    DOWNTIME_STEPS = config.getint('vars', 'migration_downtime_steps')
-
-    def __init__(self, vm, downtime):
+    def __init__(self, vm, downtime, steps):
         super(DowntimeThread, self).__init__()
 
         self._vm = vm
         self._downtime = downtime
+        self._steps = steps
         self._stop = threading.Event()
 
         delay_per_gib = config.getint('vars', 'migration_downtime_delay')
@@ -428,9 +430,8 @@
     def run(self):
         self._vm.log.debug('migration downtime thread started')
 
-        for downtime in exponential_downtime(self._downtime,
-                                             self.DOWNTIME_STEPS):
-            self._stop.wait(self._wait / self.DOWNTIME_STEPS)
+        for downtime in exponential_downtime(self._downtime, self._steps):
+            self._stop.wait(self._wait / self._steps)
 
             if self._stop.isSet():
                 break


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

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

Reply via email to