[libvirt] [jenkins-ci PATCH v2] lcitool: check for virt-install / ansible-playbook in $PATH

Daniel P. Berrangé berrange at redhat.com
Fri May 3 10:02:09 UTC 2019


This improves error reporting:

  $ ./lcitool install libvirt-fedora-29
  ./lcitool: Failed to install 'libvirt-fedora-29': [Errno 2] No such file or directory

To

  $ ./lcitool install libvirt-fedora-29
  ./lcitool: Cannot find virt-install in $PATH

Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
---
 guests/lcitool | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/guests/lcitool b/guests/lcitool
index 0f60704..d3937be 100755
--- a/guests/lcitool
+++ b/guests/lcitool
@@ -17,6 +17,7 @@
 # with this program. If not, see <https://www.gnu.org/licenses/>.
 
 import argparse
+import distutils.spawn
 import fnmatch
 import json
 import os
@@ -461,8 +462,12 @@ class Application:
             "git_branch": git_branch,
         })
 
+        ap_path = distutils.spawn.find_executable("ansible-playbook")
+        if ap_path is None:
+            raise Exception("Cannot find ansible-playbook in $PATH")
+
         cmd = [
-            "ansible-playbook",
+            ap_path,
             "--limit", ansible_hosts,
             "--extra-vars", extra_vars,
         ]
@@ -534,8 +539,12 @@ class Application:
             # a kernel argument
             extra_arg = "console=ttyS0 ks=file:/{}".format(install_config)
 
+            vi_path = distutils.spawn.find_executable("virt-install")
+            if vi_path is None:
+                raise Exception("Cannot find virt-install in $PATH")
+
             cmd = [
-                "virt-install",
+                vi_path,
                 "--name", host,
                 "--location", facts["install_url"],
                 "--virt-type", facts["install_virt_type"],
-- 
2.21.0




More information about the libvir-list mailing list