diff --git a/image_creator/dialog_menu.py b/image_creator/dialog_menu.py index c4438b2c5442e88547a6fcf41ca0624c9eb10252..847fb0a424167874099e242fb25b0d06eb148136 100644 --- a/image_creator/dialog_menu.py +++ b/image_creator/dialog_menu.py @@ -27,13 +27,13 @@ import re import time from image_creator import __version__ as version -from image_creator.util import MD5, FatalError +from image_creator.util import MD5, FatalError, virtio_versions from image_creator.output.dialog import GaugeOutput, InfoBoxOutput from image_creator.kamaki_wrapper import Kamaki, ClientError from image_creator.help import get_help_file from image_creator.dialog_util import SMALL_WIDTH, WIDTH, \ update_background_title, confirm_reset, confirm_exit, Reset, \ - extract_image, add_cloud, edit_cloud, virtio_versions, update_sysprep_param + extract_image, add_cloud, edit_cloud, update_sysprep_param CONFIGURATION_TASKS = [ ("Partition table manipulation", ["FixPartitionTable"], @@ -768,8 +768,18 @@ def install_virtio_drivers(session): assert hasattr(image.os, 'install_virtio_drivers') - if d.yesno("Continue with the installation of the VirtIO drivers?", - width=SMALL_WIDTH, defaultno=1): + virtio = image.os.sysprep_params['virtio'].value + new_drivers = virtio_versions(image.os.compute_virtio_state(virtio)) + + msg = \ + "The following VirtIO drivers were discovered in the directory you "\ + "specified:\n\n" + for drv, drv_ver in new_drivers.items(): + msg += "%s: %s\n" % (drv, drv_ver) + msg += "\nPress <Install> to continue with the installation of the " \ + "aforementioned drivers or <Cancel> to return to the previous menu." + if d.yesno(msg, width=WIDTH, defaultno=1, height=11+len(new_drivers), + yes_label="Install", no_label="Cancel"): return False title = "VirtIO Drivers Installation" diff --git a/image_creator/dialog_util.py b/image_creator/dialog_util.py index 360f6307eab5a1d27b7dade7973b7a786f5f28ca..2b64b91be178fd7e8afbddb9f9bb654c29b75d0a 100644 --- a/image_creator/dialog_util.py +++ b/image_creator/dialog_util.py @@ -336,19 +336,6 @@ def edit_cloud(session, name): return True -def virtio_versions(virtio_state): - """Returns the versions of the drivers defined by the virtio state""" - - ret = {} - for name, infs in virtio_state.items(): - driver_ver = [drv['DriverVer'].split(',', 1) if 'DriverVer' in drv - else [] for drv in infs.values()] - vers = [v[1] if len(v) > 1 else " " for v in driver_ver] - ret[name] = "<not found>" if len(infs) == 0 else ", ".join(vers) - - return ret - - def update_sysprep_param(session, name, title=None): """Modify the value of a sysprep parameter""" d = session['dialog'] diff --git a/image_creator/dialog_wizard.py b/image_creator/dialog_wizard.py index 1adb75c42ffb9999c27ca5af551b6d1729ef9923..7ce24cb9a442f2884a6ba435154e41ce54fcaba9 100644 --- a/image_creator/dialog_wizard.py +++ b/image_creator/dialog_wizard.py @@ -25,10 +25,10 @@ import json import re from image_creator.kamaki_wrapper import Kamaki, ClientError -from image_creator.util import MD5, FatalError +from image_creator.util import MD5, FatalError, virtio_versions from image_creator.output.cli import OutputWthProgress from image_creator.dialog_util import extract_image, update_background_title, \ - add_cloud, edit_cloud, virtio_versions, update_sysprep_param + add_cloud, edit_cloud, update_sysprep_param PAGE_WIDTH = 70 PAGE_HEIGHT = 12 diff --git a/image_creator/util.py b/image_creator/util.py index c34d41d561f11b54616fe9ec83cddd8c3b1b5d27..d5370ffd06f9daa10e9a003719a680c1bdbeafda 100644 --- a/image_creator/util.py +++ b/image_creator/util.py @@ -118,4 +118,17 @@ class MD5: return checksum + +def virtio_versions(virtio_state): + """Returns the versions of the drivers defined by the virtio state""" + + ret = {} + for name, infs in virtio_state.items(): + driver_ver = [drv['DriverVer'].split(',', 1) if 'DriverVer' in drv + else [] for drv in infs.values()] + vers = [v[1] if len(v) > 1 else " " for v in driver_ver] + ret[name] = "<not found>" if len(infs) == 0 else ", ".join(vers) + + return ret + # vim: set sta sts=4 shiftwidth=4 sw=4 et ai :