[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[et-mgmt-tools] [PATCH] Add --list-os-options to virt-install and virt-convert



Add an option '--list-os-options' to virt-install and virt-convert to
dump the valid os-type/variant values from our internal OS dictionary
(then exit). Prior to this, the only way a user knew what to pass was
via the quite outdated man pages, or via virt-manager (which reads the
OS dictionary from virtinst).

On one side I'm hesitant about this: we are going to expand this OS
metadata in the future with a potentially more granular approach (ex.
RHEL5.1/2/3 instead of just RHEL5), and giving the illusion that this is
stable (and machine parseable) may make it harder to deviate later.

That said, this solution is clearly much more useful and sustainable
than the current situation, so until we work out something better I
think this patch is the way to go.

Example output:

$ ./virt-install --list-os-options
TYPE : VARIANT
--------------
linux : debianetch
linux : debianlenny
linux : fedora5
linux : fedora6
linux : fedora7
linux : fedora8
linux : fedora9
linux : fedora10
linux : fedora11
linux : generic24
linux : generic26
linux : virtio26
linux : rhel2.1
linux : rhel3
linux : rhel4
linux : rhel5
linux : sles10
linux : ubuntuhardy
other : generic
other : msdos
other : netware4
other : netware5
other : netware6
solaris : opensolaris
solaris : solaris10
solaris : solaris9
unix : freebsd6
unix : freebsd7
unix : openbsd4
windows : vista
windows : win2k
windows : win2k3
windows : win2k8
windows : winxp
windows : winxp64

Thanks,
Cole
# HG changeset patch
# User Cole Robinson <crobinso redhat com>
# Node ID 55fa05f7f258fb5bf5aae7d03fa100cda8cdd93b
# Parent  9f02b1bb16e2d47088ab928ccc1ba2a59d26d1c8
Add --list-os-options command.

Shows valid --os-type/variant values, rather than continually updating the
man pages.

diff -r 9f02b1bb16e2 -r 55fa05f7f258 man/en/virt-convert.pod
--- a/man/en/virt-convert.pod	Sun Mar 01 21:19:29 2009 -0500
+++ b/man/en/virt-convert.pod	Mon Mar 02 00:35:18 2009 -0500
@@ -73,163 +73,17 @@
 
 =item  --os-type=OS_TYPE
 
-Optimize the guest configuration for a type of operating system. This will
-attempt to pick the most suitable ACPI & APIC settings, optimally supported
-mouse drivers and generally accommodate other operating system quirks. The
-valid operating system types are
-
-=over 4
-
-=item linux
-
-Linux 2.x series
-
-=item windows
-
-Microsoft Windows 9x or later
-
-=item unix
-
-Traditional UNIX BSD or SysV derivatives
-
-=item other
-
-Operating systems not in one of the 3 prior groups
-
-=back
+Optimize the guest configuration for a type of operating system (ex. 'linux',
+'windows'). This will attempt to pick the most suitable ACPI & APIC settings,
+optimally supported mouse drivers, virtio, and generally accommodate other
+operating system quirks. See C<--list-os-options> for valid values.
 
 =item --os-variant=OS_VARIANT
 
 Further optimize the guest configuration for a specific operating system
-variant. This parameter is optional. The valid variants are
-
-=over 4
-
-=item linux
-
-=over 4
-
-=item rhel2.1
-
-Red Hat Enterprise Linux 2.1
-
-=item rhel3
-
-Red Hat Enterprise Linux 3
-
-=item rhel4
-
-Red Hat Enterprise Linux 4
-
-=item rhel5
-
-Red Hat Enterprise Linux 5
-
-=item centos5
-
-Cent OS 5
-
-=item fedora5
-
-Fedora Core 5
-
-=item fedora6
-
-Fedora Core 6
-
-=item fedora7
-
-Fedora 7
-
-=item sles10
-
-Suse Linux Enterprise Server 10.x
-
-=item debianEtch
-
-Debian 4.0 (Etch)
-
-=item debianLenny
-
-Debian Lenny
-
-=item generic26
-
-Generic Linux 2.6.x kernel
-
-=item generic24
-
-Generic Linux 2.4.x kernel
-
-=back
-
-=item windows
-
-=over 4
-
-=item winxp
-
-Microsoft Windows XP
-
-=item win2k
-
-Microsoft Windows 2000
-
-=item win2k3
-
-Microsoft Windows 2003
-
-=item vista
-
-Microsoft Windows Vista
-
-=back
-
-=item unix
-
-=over 4
-
-=item solaris9
-
-Sun Solaris 9
-
-=item solaris10
-
-Sun Solaris 10
-
-=item freebsd6
-
-Free BSD 6.x
-
-=item openbsd4
-
-Open BSD 4.x
-
-=back
-
-=item other
-
-=over 4
-
-=item msdos
-
-Microsoft DOS
-
-=item netware4
-
-Novell Netware 4
-
-=item netware5
-
-Novell Netware 5
-
-=item netware6
-
-Novell Netware 6
-
-=back
-
-=back
+variant (ex. 'fedora8', 'winxp'). This does not require an C<--os-type>
+to be specified. This parameter is optional. See C<--list-os-options> for
+valid values.
 
 =item  --noapic
 
@@ -241,6 +95,10 @@
 Override the OS type / variant to disables the ACPI setting for fully 
 virtualized guest. 
 
+=item --list-os-options
+
+Show a list of valid values for C<--os-type> and C<--os-variant>, then exit.
+
 =back
 
 =head1 EXAMPLES
diff -r 9f02b1bb16e2 -r 55fa05f7f258 man/en/virt-install.pod
--- a/man/en/virt-install.pod	Sun Mar 01 21:19:29 2009 -0500
+++ b/man/en/virt-install.pod	Mon Mar 02 00:35:18 2009 -0500
@@ -340,163 +340,17 @@
 
 =item  --os-type=OS_TYPE
 
-Optimize the guest configuration for a type of operating system. This will
-attempt to pick the most suitable ACPI & APIC settings, optimally supported
-mouse drivers and generally accommodate other operating system quirks. The
-valid operating system types are
-
-=over 4
-
-=item linux
-
-Linux 2.x series
-
-=item windows
-
-Microsoft Windows 9x or later
-
-=item unix
-
-Traditional UNIX BSD or SysV derivatives
-
-=item other
-
-Operating systems not in one of the 3 prior groups
-
-=back
+Optimize the guest configuration for a type of operating system (ex. 'linux',
+'windows'). This will attempt to pick the most suitable ACPI & APIC settings,
+optimally supported mouse drivers, virtio, and generally accommodate other
+operating systemquirks. See C<--list-os-options> for valid values.
 
 =item --os-variant=OS_VARIANT
 
 Further optimize the guest configuration for a specific operating system
-variant. This parameter is optional. The valid variants are
-
-=over 4
-
-=item linux
-
-=over 4
-
-=item rhel2.1
-
-Red Hat Enterprise Linux 2.1
-
-=item rhel3
-
-Red Hat Enterprise Linux 3
-
-=item rhel4
-
-Red Hat Enterprise Linux 4
-
-=item rhel5
-
-Red Hat Enterprise Linux 5
-
-=item centos5
-
-Cent OS 5
-
-=item fedora5
-
-Fedora Core 5
-
-=item fedora6
-
-Fedora Core 6
-
-=item fedora7
-
-Fedora 7
-
-=item sles10
-
-Suse Linux Enterprise Server 10.x
-
-=item debianEtch
-
-Debian 4.0 (Etch)
-
-=item debianLenny
-
-Debian Lenny
-
-=item generic26
-
-Generic Linux 2.6.x kernel
-
-=item generic24
-
-Generic Linux 2.4.x kernel
-
-=back
-
-=item windows
-
-=over 4
-
-=item winxp
-
-Microsoft Windows XP
-
-=item win2k
-
-Microsoft Windows 2000
-
-=item win2k3
-
-Microsoft Windows 2003
-
-=item vista
-
-Microsoft Windows Vista
-
-=back
-
-=item unix
-
-=over 4
-
-=item solaris9
-
-Sun Solaris 9
-
-=item solaris10
-
-Sun Solaris 10
-
-=item freebsd6
-
-Free BSD 6.x
-
-=item openbsd4
-
-Open BSD 4.x
-
-=back
-
-=item other
-
-=over 4
-
-=item msdos
-
-Microsoft DOS
-
-=item netware4
-
-Novell Netware 4
-
-=item netware5
-
-Novell Netware 5
-
-=item netware6
-
-Novell Netware 6
-
-=back
-
-=back
+variant (ex. 'fedora8', 'winxp'). This does not require an C<--os-type>
+to be specified. This parameter is optional. See C<--list-os-options> for
+valid values.
 
 =item  --noapic
 
@@ -576,6 +430,10 @@
 Additional kernel command line arguments to pass to the installer when
 performing a guest install from a kernel+initrd.
 
+=item --list-os-options
+
+Show a list of valid values for C<--os-type> and C<--os-variant>, then exit.
+
 =item  -d, --debug
 
 Print debugging information to the terminal when running the install process.
diff -r 9f02b1bb16e2 -r 55fa05f7f258 virt-convert
--- a/virt-convert	Sun Mar 01 21:19:29 2009 -0500
+++ b/virt-convert	Mon Mar 02 00:35:18 2009 -0500
@@ -68,12 +68,12 @@
                     help=_("Machine Architecture Type (i686/x86_64/ppc)"))
     cfgg.add_option("", "--os-type", type="string", dest="os_type",
                     action="callback", callback=cli.check_before_store,
-                    help=_("The OS type for fully virtualized guests, e.g. "
+                    help=_("The OS type being installed, e.g. "
                            "'linux', 'unix', 'windows'"))
     cfgg.add_option("", "--os-variant", type="string", dest="os_variant",
-                    action="callback", callback=cli.check_before_store,
-                    help=_("The OS variant for fully virtualized guests, e.g. "
-                           "'fedora6', 'rhel5', 'solaris10', 'win2k', 'vista'"))
+                      action="callback", callback=cli.check_before_store,
+                      help=_("The OS variant being installed, "
+                             "e.g. 'fedora6', 'rhel5', 'solaris10', 'win2k'"))
     cfgg.add_option("", "--noapic", action="store_true", dest="noapic",
                     help=_("Disables APIC for fully virtualized guest "
                            "(overrides value in os-type/os-variant db)"),
@@ -85,6 +85,9 @@
     opts.add_option_group(cfgg)
 
     misc = OptionGroup(opts, "Miscellaneous Options")
+    misc.add_option("", "--list-os-options", action="store_true",
+                    dest="list_os", default=False,
+                    help=_("List OS type and OS variant options."))
     misc.add_option("-q", "--quiet", action="store_true", dest="quiet",
                     help=_("Don't be verbose"))
     misc.add_option("-d", "--debug", action="store_true", dest="debug",
@@ -93,6 +96,8 @@
 
 
     (options, args) = opts.parse_args()
+    cli.do_list_os(options.list_os)
+
     if len(args) < 1:
         opts.error(_("You need to provide an input VM definition"))
     if len(args) > 2:
diff -r 9f02b1bb16e2 -r 55fa05f7f258 virt-install
--- a/virt-install	Sun Mar 01 21:19:29 2009 -0500
+++ b/virt-install	Mon Mar 02 00:35:18 2009 -0500
@@ -350,19 +350,22 @@
     geng.add_option("", "--cpuset", type="string", dest="cpuset",
                     action="callback", callback=cli.check_before_store,
                     help=_("Set which physical CPUs Domain can use."))
+    geng.add_option("", "--os-type", type="string", dest="distro_type",
+                    action="callback", callback=cli.check_before_store,
+                    help=_("The OS type being installed, e.g. "
+                           "'linux', 'unix', 'windows'"))
+    geng.add_option("", "--os-variant", type="string", dest="distro_variant",
+                      action="callback", callback=cli.check_before_store,
+                      help=_("The OS variant being installed, "
+                             "e.g. 'fedora6', 'rhel5', 'solaris10', 'win2k'"))
+    geng.add_option("", "--list-os-options", action="store_true",
+                    dest="list_os", default=False,
+                    help=_("List OS type and OS variant options."))
     parser.add_option_group(geng)
 
     fulg = OptionGroup(parser, _("Full Virtualization specific options."))
     fulg.add_option("", "--sound", action="store_true", dest="sound",
                     default=False, help=_("Use sound device emulation"))
-    fulg.add_option("", "--os-type", type="string", dest="distro_type",
-                    action="callback", callback=cli.check_before_store,
-                    help=_("The OS type for fully virtualized guests, e.g. "
-                           "'linux', 'unix', 'windows'"))
-    fulg.add_option("", "--os-variant", type="string", dest="distro_variant",
-                      action="callback", callback=cli.check_before_store,
-                      help=_("The OS variant for fully virtualized guests, "
-                             "e.g. 'fedora6', 'rhel5', 'solaris10', 'win2k'"))
     fulg.add_option("", "--noapic", action="store_true", dest="noapic",
                     default=False,
                     help=_("Disables APIC for fully virtualized guest "
@@ -519,6 +522,8 @@
     cli.setupLogging("virt-install", options.debug)
     cli.set_force(options.force)
     cli.set_prompt(options.prompt)
+    cli.do_list_os(options.list_os)
+
     conn = cli.getConnection(options.connect)
     capabilities = virtinst.CapabilitiesParser.parse(conn.getCapabilities())
 
diff -r 9f02b1bb16e2 -r 55fa05f7f258 virtinst/cli.py
--- a/virtinst/cli.py	Sun Mar 01 21:19:29 2009 -0500
+++ b/virtinst/cli.py	Mon Mar 02 00:35:18 2009 -0500
@@ -28,7 +28,7 @@
 import libvirt
 import _util
 from virtinst import CapabilitiesParser, VirtualNetworkInterface, \
-                     VirtualGraphics, VirtualAudio, User
+                     VirtualGraphics, VirtualAudio, User, Guest
 from virtinst import _virtinst as _
 
 MIN_RAM = 64
@@ -179,6 +179,17 @@
             continue
     return res
 
+def do_list_os(do_list):
+    # Print all available os type/variant choices and exit the app
+    if not do_list:
+        return
+
+    print "TYPE : VARIANT"
+    print "--------------"
+    for t in Guest.list_os_types():
+        for v in Guest.list_os_variants(t):
+            print "%s : %s" % (t, v)
+    sys.exit(0)
 #
 # Ask for attributes
 #

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]