On Thu, Oct 02, 2014 at 10:11:36AM +0200, 'Klaus Aehlig' via ganeti-devel wrote:
The relevance of a warning about migrating between hypervisors
of different versions depends on whether the migration is likely
to succeed or not. While it is hard to predict this in general,
this function follows best practices for Xen's current numbering
scheme.

Signed-off-by: Klaus Aehlig <[email protected]>
---
lib/utils/version.py | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)

diff --git a/lib/utils/version.py b/lib/utils/version.py
index fb4c303..75f9ad0 100644
--- a/lib/utils/version.py
+++ b/lib/utils/version.py
@@ -181,3 +181,21 @@ def IsBefore(version, major, minor, revision):
    return True

  return version < (major, minor, revision)
+
+
+def HVVersionsLikelySafeForMigration(src, target):
+  """Decide if migration is likely to suceed for hypervisor versions.
+
+  Given two versions of a hypervisor, give a guess whether live migration
+  from the one version to the other version is likely to succeed. The current
+  heuristics is, that an increase by one on the second digit is OK. This is
+  in line with the current numbering of Xen.
+
+  """

Just a minor point, I'd suggest to add documentation tags - at least the @type tags to document that the versions are tuples/lists and that the result is bool.

+  if src == target:
+    return True
+
+  if len(src) < 2 or len(target) < 2:
+    return False
+
+  return src[0] == target[0] and target[1] in [src[1], src[1] + 1]
--
2.1.0.rc2.206.gedb03e5


Rest LGTM, no need to resend.

Reply via email to