virt-install: implement --osinfo require=no as fallback name=generic

This is essentially what it has always behaved as, but making it
explicit in the code will now trigger the extra warnings when
detect=on is also used.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson 2024-10-09 10:55:33 -04:00 committed by Pavel Hrdina
parent e02607766c
commit 8f75ac4e6e
3 changed files with 5 additions and 6 deletions

View File

@ -1024,6 +1024,7 @@ c.add_compare("--pxe --os-variant detect=yes,name=win7", "os-detect-fail-fallbac
c.add_compare("--connect %(URI-KVM-X86)s --install fedora26", "osinfo-url") # getting URL from osinfo
c.add_valid("--location https://foobar.com --os-variant detect=yes,name=win7", nogrep="Please file a bug against virt-install") # os detection succeeds, the fallback warning shouldn't be printed
c.add_valid("--pxe --os-variant detect=yes,name=win7", grep="Please file a bug against virt-install") # os detection fails, so fallback warning should be printed
c.add_valid("--cdrom http://example.com/path/to/some.iso --os-variant detect=yes,require=no", grep="Please file a bug against virt-install") # detection fails with require=no, we should print the error about using fallback name=
c.add_invalid("--pxe --os-variant detect=yes,require=yes", grep="--os-variant/--osinfo OS name is required") # No os-variant detected, but require=yes
c.add_invalid("--pxe --osinfo detect=yes", grep="--os-variant/--osinfo OS name is required") # --osinfo detect=on failed, but with implied require=yes
c.add_invalid("--pxe --virt-type foobar", grep="Host does not support domain type")

View File

@ -1886,7 +1886,6 @@ def parse_location(optstr):
class OSVariantData(object):
_REQUIRE_ON = 1
_REQUIRE_OFF = 2
_REQUIRE_AUTO = 3
def __init__(self):
@ -1920,7 +1919,10 @@ class OSVariantData(object):
self._name = osobj.name
if self._require_from_cli is False:
self._require = self._REQUIRE_OFF
if not self._name:
log.debug(
"Converting `require=off` to fallback `name=generic`")
self._name = "generic"
elif self._require_from_cli is True:
self._require = self._REQUIRE_ON
else:
@ -1930,8 +1932,6 @@ class OSVariantData(object):
return self._detect
def is_require_on(self):
return self._require == self._REQUIRE_ON
def is_require_off(self):
return self._require == self._REQUIRE_OFF
def get_name(self):
return self._name

View File

@ -576,8 +576,6 @@ def installer_detect_distro(guest, installer, osdata):
return
if osdata.is_require_on():
fail(msg)
if osdata.is_require_off():
return
if not _needs_accurate_osinfo(guest):
return