cli: Add `--os-variant list` option to print OS name values
The canonical tool for this is `osinfo-query os`, which we still reference in the man pages and in the list output. However, we are about to make missing --os-variant fatal for common usage, and I don't want to force users to install an extra tool just to figure out what an acceptable --os-variant value is. Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
a39bd561b0
commit
96a40b1143
|
@ -1021,8 +1021,8 @@ value otherwise, and printing a warning.
|
|||
If any manual ``--os-variant`` value is specified, the default is
|
||||
all settings off or unset.
|
||||
|
||||
Use the command "osinfo-query os" to get the list of the accepted OS
|
||||
variant names.
|
||||
Use the command ``virt-xml --os-variant list`` to get the list of the
|
||||
accepted OS variants. See ``osinfo-query os`` for even more output.
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -191,8 +191,8 @@ GUEST OS OPTIONS
|
|||
have been stored in the guest configuration during installation and virt-xml
|
||||
will retrieve it from there automatically.
|
||||
|
||||
Use the command "osinfo-query os" to get the list of the accepted OS
|
||||
variants.
|
||||
Use the command ``virt-xml --os-variant list`` to get the list of the
|
||||
accepted OS variants. See ``osinfo-query os`` for even more output.
|
||||
|
||||
See virt-install(1) documentation for more details about ``--os-variant``
|
||||
|
||||
|
|
|
@ -968,6 +968,7 @@ c.add_compare("--connect %(URI-KVM-X86)s --reinstall test-clone-simple --locatio
|
|||
c.add_compare("--reinstall test-cdrom --cdrom %(ISO-WIN7)s --unattended", "reinstall-cdrom") # compare --reinstall with --cdrom handling
|
||||
c.add_invalid("--reinstall test --cdrom %(ISO-WIN7)s", grep="already active") # trying to reinstall an active VM should fail
|
||||
c.add_invalid("--reinstall test", grep="install method must be specified") # missing install method
|
||||
c.add_valid("--osinfo list", grep="osinfo-query os") # --osinfo list
|
||||
|
||||
|
||||
####################
|
||||
|
@ -1220,6 +1221,7 @@ vixml = App("virt-xml")
|
|||
c = vixml.add_category("misc", "")
|
||||
c.add_valid("--help") # basic --help test
|
||||
c.add_valid("--sound=? --tpm=?") # basic introspection test
|
||||
c.add_valid("--os-variant list", grep="ubuntu10.10, ubuntumaverick") # --os-variant list
|
||||
c.add_valid("test-state-shutoff --edit --update --boot menu=on", grep="The VM is not running") # --update with inactive VM, should work but warn
|
||||
c.add_valid("test-state-shutoff --edit --boot menu=on", grep="XML did not change after domain define") # menu=on is discarded because <bootloader> is specified
|
||||
c.add_valid("test-for-virtxml --edit --graphics password=foo --update --confirm", input_text="no\nno\n") # prompt exiting
|
||||
|
|
|
@ -928,7 +928,7 @@ def add_os_variant_option(parser, virtinstall):
|
|||
msg += "\n"
|
||||
msg += _("This is used for deciding optimal defaults like VirtIO.\n"
|
||||
"Example values: fedora29, rhel7.0, win10, ...\n"
|
||||
"See 'osinfo-query os' for a full list.")
|
||||
"Use '--os-variant list' to see a full list.")
|
||||
|
||||
osg.add_argument("--os-variant", "--osinfo", help=msg)
|
||||
return osg
|
||||
|
@ -4786,3 +4786,15 @@ def check_option_introspection(options):
|
|||
ret = True
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
def check_osinfo_list(options):
|
||||
if options.os_variant != "list":
|
||||
return False
|
||||
|
||||
for osobj in OSDB.list_os():
|
||||
print(", ".join(osobj.all_names))
|
||||
|
||||
print()
|
||||
print(_("You can see additional information with:\n\n osinfo-query os\n"))
|
||||
return True
|
||||
|
|
|
@ -179,7 +179,7 @@ class _OSDB(object):
|
|||
if len(oslist) == 0:
|
||||
if raise_error:
|
||||
raise ValueError(_("Unknown OS name '%s'. "
|
||||
"See `osinfo-query os` for valid values.") % key)
|
||||
"See `--os-variant list` for valid values.") % key)
|
||||
return None
|
||||
return _OsVariant(oslist[0])
|
||||
|
||||
|
@ -312,6 +312,7 @@ class _OsVariant(object):
|
|||
if hasattr(self._os, "get_short_id_list"):
|
||||
self._short_ids = self._os.get_short_id_list()
|
||||
self.name = self._short_ids[0]
|
||||
self.all_names = list(sorted(set(self._short_ids)))
|
||||
|
||||
self._family = self._os.get_family()
|
||||
self.full_id = self._os.get_id()
|
||||
|
|
|
@ -1113,6 +1113,8 @@ def main(conn=None):
|
|||
|
||||
if cli.check_option_introspection(options):
|
||||
return 0
|
||||
if cli.check_osinfo_list(options):
|
||||
return 0
|
||||
|
||||
check_cdrom_option_error(options)
|
||||
cli.convert_old_force(options)
|
||||
|
|
|
@ -451,6 +451,8 @@ def main(conn=None):
|
|||
|
||||
if cli.check_option_introspection(options):
|
||||
return 0
|
||||
if cli.check_osinfo_list(options):
|
||||
return 0
|
||||
|
||||
options.stdinxml = None
|
||||
if not options.domain and not options.build_xml:
|
||||
|
|
Loading…
Reference in New Issue