[PATCH virt-manager] virtinst/cli: don't use hard-coded path for binaries

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The binaries could be installed somewhere else and we should not
hard-code the binary paths.  This patch allows non-root user to build
their own virt-viewer/virsh, set the PATH env and run virt-manager
tests.

Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---

This is required to run ./setup.py test using Jenkins on nodes without root
privileges.  We are building upstream virt-viewer and libvirt by ourself and
installing them to specific path, which is then exported correctly using
environment variables.

 virtinst/cli.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/virtinst/cli.py b/virtinst/cli.py
index 642e4eb..59628b6 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -26,6 +26,7 @@ import os
 import shlex
 import sys
 import traceback
+import subprocess
 
 import libvirt
 
@@ -379,7 +380,7 @@ def _run_console(args):
 
 
 def _gfx_console(guest):
-    args = ["/usr/bin/virt-viewer",
+    args = ["virt-viewer",
             "--connect", guest.conn.uri,
             "--wait", guest.name]
 
@@ -389,7 +390,7 @@ def _gfx_console(guest):
 
 
 def _txt_console(guest):
-    args = ["/usr/bin/virsh",
+    args = ["virsh",
             "--connect", guest.conn.uri,
             "console", guest.name]
 
@@ -428,7 +429,10 @@ def get_console_cb(guest):
         logging.debug("No viewer to launch for graphics type '%s'", gtype)
         return
 
-    if not os.path.exists("/usr/bin/virt-viewer"):
+    try:
+        subprocess.check_output(["virt-viewer", "--version"],
+                                stdout=subprocess.STDOUT)
+    except OSError:
         logging.warn(_("Unable to connect to graphical console: "
                        "virt-viewer not installed. Please install "
                        "the 'virt-viewer' package."))
-- 
2.0.5

_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list




[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux