This patch implements version check between Controller and Slaves. Check
is done after hello messages are exchanged. Controller extracts Slave
version slave_desc dict and compares with its own version.
These situations might happen:
1) Versions match - everything continues as normally
2) Versions mismatch:
a) Both Ctl and Slave are run from git repo - warning message is shown,
but execution continues
b) Ctl/Slave is run from git repo but the second one is run from RPM
installation - exception is raised and execution is stopped
changes in v2:
* logging warning message is now multiline - decorated with '='
* replaced method compare_versions with is_git_version
Signed-off-by: Jiri Prochazka <jprochaz(a)redhat.com>
---
lnst/Controller/Machine.py | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/lnst/Controller/Machine.py b/lnst/Controller/Machine.py
index c5d9191..3e730bd 100644
--- a/lnst/Controller/Machine.py
+++ b/lnst/Controller/Machine.py
@@ -247,6 +247,22 @@ class Machine(object):
"to machine %s, handshake failed!" % hostname
raise MachineError(msg)
+ slave_version = slave_desc["lnst_version"]
+ slave_is_git = self.is_git_version(slave_version)
+ ctl_version = lnst_config.version
+ ctl_is_git = self.is_git_version(ctl_version)
+ if slave_version != ctl_version:
+ if ctl_is_git and slave_is_git:
+ msg = "Controller and Slave '%s' git versions are
different"\
+ % hostname
+ logging.warning(len(msg)*"=")
+ logging.warning(msg)
+ logging.warning(len(msg)*"=")
+ else:
+ msg = "Controller and Slave '%s' versions are not
compatible!"\
+ % hostname
+ raise MachineError(msg)
+
self._slave_desc = slave_desc
devices = self._rpc_call("get_devices")
@@ -258,6 +274,13 @@ class Machine(object):
self._configured = True
+ def is_git_version(self, version):
+ try:
+ int(version)
+ return False
+ except ValueError:
+ return True
+
def is_configured(self):
""" Test if the machine was configured """
--
2.4.11