Martin Peřina has uploaded a new change for review.

Change subject: kdump: Fix kexec-tools detection in node
......................................................................

kdump: Fix kexec-tools detection in node

Use rpm to detect version of kexec-tools when running on oVirt Node.

Change-Id: I136469c35e7fc11d3eb89ab5b4fc71395010f42b
Bug-Url: https://bugzilla.redhat.com/1079821
Signed-off-by: Martin Perina <[email protected]>
---
M src/plugins/ovirt-host-deploy/kdump/packages.py
1 file changed, 44 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-host-deploy 
refs/changes/83/29283/1

diff --git a/src/plugins/ovirt-host-deploy/kdump/packages.py 
b/src/plugins/ovirt-host-deploy/kdump/packages.py
index 5027417..b410585 100644
--- a/src/plugins/ovirt-host-deploy/kdump/packages.py
+++ b/src/plugins/ovirt-host-deploy/kdump/packages.py
@@ -21,6 +21,7 @@
 """kdump packages plugin."""
 
 
+import ast
 import gettext
 import platform
 import re
@@ -107,6 +108,41 @@
                     break
         return crashkernel
 
+    def _get_available_kexec_tools_version(self):
+        if self.environment[odeploycons.VdsmEnv.OVIRT_NODE]:
+            # in node rpm -q has to be called to get kexec-tools version
+            # instead of standard packager
+            available = []
+            rpmCmd = self.command.get('rpm', optional=True)
+            if rpmCmd is not None:
+                (rc, stdout, stderr) = self.execute(
+                    (
+                        self.command.get('rpm'),
+                        '-q',
+                        '--qf',
+                        "\{'version':'%{VERSION}', 'release':'%{RELEASE}'\}",
+                        self._KEXEC_TOOLS_PKG
+                    ),
+                    raiseOnError=False
+                )
+                if rc == 0:
+                    try:
+                        available.append(
+                            ast.literal_eval(stdout[0])
+                        )
+                    except ValueError:
+                        self.logger.debug(
+                            'Invalid output of RPM query: %s',
+                            stdout[0],
+                            exc_info=True,
+                        )
+
+        else:
+            available = self.packager.queryPackages(
+                patterns=(self._KEXEC_TOOLS_PKG,),
+            )
+        return available
+
     def _update_kdump_conf(
             self,
             content,
@@ -155,6 +191,13 @@
         self.environment.setdefault(odeploycons.KdumpEnv.SUPPORTED, False)
 
     @plugin.event(
+        stage=plugin.Stages.STAGE_SETUP,
+        condition=lambda self: 
self.environment[odeploycons.VdsmEnv.OVIRT_NODE],
+    )
+    def _setup(self):
+        self.command.detect('rpm')
+
+    @plugin.event(
         stage=plugin.Stages.STAGE_CUSTOMIZATION,
         priority=plugin.Stages.PRIORITY_HIGH,
     )
@@ -164,9 +207,7 @@
             min_version = self._get_min_kexec_tools_version()
             if min_version is not None:
                 from distutils.version import LooseVersion
-                result = self.packager.queryPackages(
-                    patterns=(self._KEXEC_TOOLS_PKG,),
-                )
+                result = self._get_available_kexec_tools_version()
                 self.logger.debug("minver: %s, result=%s", min_version, result)
                 for package in result:
                     cur_version = '%s-%s' % (


-- 
To view, visit http://gerrit.ovirt.org/29283
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I136469c35e7fc11d3eb89ab5b4fc71395010f42b
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-host-deploy
Gerrit-Branch: master
Gerrit-Owner: Martin Peřina <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to