Change in vdsm[master]: lib: migration: add response.is_failure helper
fromani at redhat.com
fromani at redhat.com
Wed Jun 24 11:08:36 UTC 2015
Francesco Romani has uploaded a new change for review.
Change subject: lib: migration: add response.is_failure helper
......................................................................
lib: migration: add response.is_failure helper
Add little helper to make the code more explicit
and self-documenting.
Change-Id: I6ccefec4f1bebcb2ca64f0bc9f6b9e9954dbf04c
Signed-off-by: Francesco Romani <fromani at redhat.com>
---
M lib/vdsm/response.py
M vdsm/virt/migration.py
2 files changed, 6 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/95/42795/1
diff --git a/lib/vdsm/response.py b/lib/vdsm/response.py
index 758fde8..eea62ef 100644
--- a/lib/vdsm/response.py
+++ b/lib/vdsm/response.py
@@ -40,3 +40,7 @@
"message": message or status["message"]
}
}
+
+
+def is_failure(res):
+ return res["status"]["code"] != doneCode["code"]
diff --git a/vdsm/virt/migration.py b/vdsm/virt/migration.py
index a51d977..99af017 100644
--- a/vdsm/virt/migration.py
+++ b/vdsm/virt/migration.py
@@ -197,7 +197,7 @@
self._vm.lastStatus = vmstatus.MIGRATION_SOURCE
def _recover(self, message):
- if not self._last_status['status']['code']:
+ if not response.is_failure(self._last_status):
self._last_status = response.error('migrateErr')
self.log.error(message)
if not self.hibernating:
@@ -325,7 +325,7 @@
self.log.info('Creation of destination VM took: %d seconds',
destCreationTime)
- if result['status']['code']:
+ if response.is_failure(result):
self._last_status = result
raise RuntimeError('migration destination error: ' +
result['status']['message'])
--
To view, visit https://gerrit.ovirt.org/42795
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6ccefec4f1bebcb2ca64f0bc9f6b9e9954dbf04c
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