Commit 8fb10dd2 authored by Nikos Skalkotos's avatar Nikos Skalkotos

Display the discovered VirtIO drvs in expert mode

When the user picks a directory that contains VirtIO drivers, show him
the version of the discovered drivers in the confirmation box.
parent 27435a93
......@@ -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"
......
......@@ -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']
......
......@@ -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
......
......@@ -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 :
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment