Change in vdsm[master]: migration: make SourceThread.status private

fromani at redhat.com fromani at redhat.com
Tue May 5 08:34:27 UTC 2015


Francesco Romani has uploaded a new change for review.

Change subject: migration: make SourceThread.status private
......................................................................

migration: make SourceThread.status private

The status field should never be accessed directly anymore,
the getStat() method already provides up-to-date information.

Change-Id: I7b720c03c1ee363c20522ac531fa25fc1d9bf4e8
Signed-off-by: Francesco Romani <fromani at redhat.com>
---
M vdsm/virt/migration.py
1 file changed, 16 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/23/40523/1

diff --git a/vdsm/virt/migration.py b/vdsm/virt/migration.py
index 61d5a7b..de6d21c 100644
--- a/vdsm/virt/migration.py
+++ b/vdsm/virt/migration.py
@@ -77,7 +77,7 @@
             config.get('vars', 'migration_downtime')
         self._autoConverge = autoConverge
         self._compressed = compressed
-        self.status = {
+        self._status = {
             'status': {
                 'code': 0,
                 'message': 'Migration in progress'},
@@ -97,13 +97,13 @@
         """
         if self._monitorThread is not None:
             # fetch migration status from the monitor thread
-            self.status['progress'] = self._monitorThread.progress
+            self._status['progress'] = self._monitorThread.progress
 
         stat = self._vm._dom.jobStats(libvirt.VIR_DOMAIN_JOB_STATS_COMPLETED)
         if 'downtime' in stat:
-            self.status['downtime'] = stat['downtime']
+            self._status['downtime'] = stat['downtime']
 
-        return self.status
+        return self._status
 
     def _setupVdsConnection(self):
         if self.hibernating:
@@ -129,10 +129,10 @@
             status = self._destServer.getVmStats(self._vm.id)
             if not status['status']['code']:
                 self.log.error("Machine already exists on the destination")
-                self.status = response.error('exist')
+                self._status = response.error('exist')
         except Exception:
             self.log.exception("Error initiating connection")
-            self.status = response.error('noConPeer')
+            self._status = response.error('noConPeer')
 
     def _setupRemoteMachineParams(self):
         self._machineParams.update(self._vm.status())
@@ -179,8 +179,8 @@
             self._vm.lastStatus = vmstatus.MIGRATION_SOURCE
 
     def _recover(self, message):
-        if not self.status['status']['code']:
-            self.status = response.error('migrateErr')
+        if not self._status['status']['code']:
+            self._status = response.error('migrateErr')
         self.log.error(message)
         if not self.hibernating:
             try:
@@ -194,10 +194,10 @@
         self._vm.lastStatus = vmstatus.UP
 
     def _finishSuccessfully(self):
-        self.status['progress'] = 100
+        self._status['progress'] = 100
         if not self.hibernating:
             self._vm.setDownStatus(NORMAL, vmexitreason.MIGRATION_SUCCEEDED)
-            self.status['status']['message'] = 'Migration done'
+            self._status['status']['message'] = 'Migration done'
         else:
             # don't pickle transient params
             for ignoreParam in ('displayIp', 'display', 'pid'):
@@ -212,7 +212,7 @@
                 self._vm.cif.teardownVolumePath(self._dstparams)
 
             self._vm.setDownStatus(NORMAL, vmexitreason.SAVE_STATE_SUCCEEDED)
-            self.status['status']['message'] = 'SaveState done'
+            self._status['status']['message'] = 'SaveState done'
 
     def _patchConfigForLegacy(self):
         """
@@ -270,8 +270,8 @@
                 self._finishSuccessfully()
             except libvirt.libvirtError as e:
                 if e.get_error_code() == libvirt.VIR_ERR_OPERATION_ABORTED:
-                    self.status = response.error('migCancelErr',
-                                                 message='Migration canceled')
+                    self._status = response.error('migCancelErr',
+                                                  message='Migration canceled')
                 raise
             finally:
                 if '_migrationParams' in self._vm.conf:
@@ -307,7 +307,7 @@
                           destCreationTime)
 
             if result['status']['code']:
-                self.status = result
+                self._status = result
                 raise RuntimeError('migration destination error: ' +
                                    result['status']['message'])
             if config.getboolean('vars', 'ssl'):
@@ -372,9 +372,9 @@
             if not self._preparingMigrationEvt:
                 raise
         else:
-            self.status['status']['message'] = \
+            self._status['status']['message'] = \
                 'Migration process cancelled'
-            return self.status
+            return self._status
 
 
 def exponential_downtime(downtime, steps):


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7b720c03c1ee363c20522ac531fa25fc1d9bf4e8
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani at redhat.com>


More information about the vdsm-patches mailing list