guest: Tweak error with invalid --os-variant

Try to point people in the right direction if they specify an
unknown distro name on the cli, like was reported here:

https://bugzilla.redhat.com/show_bug.cgi?id=1576473
This commit is contained in:
Cole Robinson 2018-10-03 19:32:09 -04:00
parent 046a242bd4
commit b51104ad22
2 changed files with 6 additions and 5 deletions

View File

@ -304,20 +304,21 @@ def convert_old_features(options):
##################################
def set_distro_variant(options, guest, installer):
distro = None
try:
installer.check_location(guest)
distro = None
if options.distro_variant == "auto":
distro = installer.detect_distro(guest)
elif options.distro_variant != "none":
distro = options.distro_variant
if distro:
guest.set_os_name(distro)
except ValueError as e:
fail(_("Error validating install location: %s") % str(e))
if distro:
guest.set_os_name(distro)
def do_test_media_detection(conn, options):
url = options.test_media_detection

View File

@ -259,8 +259,8 @@ class Guest(XMLBuilder):
def set_os_name(self, name):
obj = OSDB.lookup_os(name)
if obj is None:
raise ValueError(
_("Distro '%s' does not exist in our dictionary") % name)
raise ValueError(_("Unknown OS name '%s'. "
"See `osinfo-query os` for valid values.") % name)
logging.debug("Setting Guest osinfo %s", obj)
self.__osinfo = obj