[lorax 1/3] livemedia-creator: make libvirt module optional

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

 



From: "Brian C. Lane" <bcl@xxxxxxxxxx>

When running with no-virt mode libvirt and virt-install are not needed
so make the import optional and update the usage info reflect that the
virt options are disabled.
---
 src/sbin/livemedia-creator |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/sbin/livemedia-creator b/src/sbin/livemedia-creator
index 9730d99..3f3e4c2 100755
--- a/src/sbin/livemedia-creator
+++ b/src/sbin/livemedia-creator
@@ -32,7 +32,6 @@ import subprocess
 import socket
 import threading
 import SocketServer
-import libvirt
 from time import sleep
 import shutil
 import traceback
@@ -49,6 +48,11 @@ from pylorax.sysutils import joinpaths, remove, linktree
 from pylorax.imgutils import PartitionMount, mksparse, mkext4img
 from pylorax.executils import execWithRedirect, execWithCapture
 
+# no-virt mode doesn't need libvirt, so make it optional
+try:
+    import libvirt
+except Exception:
+    libvirt = None
 
 # Default parameters for rebuilding initramfs, override with --dracut-args
 DRACUT_DEFAULT = ["--xz", "--add", "livenet", "--add", "dmsquash-live",
@@ -558,7 +562,10 @@ if __name__ == '__main__':
                               "Defaults to the temporary working directory")
 
     # Group of arguments to pass to virt-install
-    virt_group = parser.add_argument_group("virt-install arguments")
+    if not libvirt:
+        virt_group = parser.add_argument_group("virt-install arguments (DISABLED -- no libvirt)")
+    else:
+        virt_group = parser.add_argument_group("virt-install arguments")
     virt_group.add_argument("--ram", metavar="MEMORY", default=1024,
                             help="Memory to allocate for installer in megabytes." )
     virt_group.add_argument("--vcpus", default=1,
@@ -648,6 +655,10 @@ if __name__ == '__main__':
         logger.fatal("the volume id cannot be longer than 32 characters")
         sys.exit(1)
 
+    if not opts.no_virt and not libvirt:
+        log.error("virt-install requires libvirt to be installed.")
+        sys.exit(1)
+
     # Make the disk image
     if not opts.disk_image:
         # Parse the kickstart to get the partition sizes
-- 
1.7.7.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux