[et-mgmt-tools] [PATCH 11 of 11] Add --host option
John Levon
levon at movementarian.org
Tue Jul 8 00:36:54 UTC 2008
On Mon, Jul 07, 2008 at 03:51:41PM -0700, john.levon at sun.com wrote:
> Add --host option
I didn't quite mean to send this patch yet, but here's a version that actually
works below
thanks
john
Add --host option
Some formats need unpleasant knowledge of what hypervisor they're going to run
on. We default to the current machine, but add a --host option to allow people
to choose (and so we can write tests).
Signed-off-by: John Levon <john.levon at sun.com>
diff --git a/man/en/virt-convert.1 b/man/en/virt-convert.1
--- a/man/en/virt-convert.1
+++ b/man/en/virt-convert.1
@@ -129,7 +129,7 @@
.\" ========================================================================
.\"
.IX Title "VIRT-CONVERT 1"
-.TH VIRT-CONVERT 1 "2008-07-04" "perl v5.8.8" "Virtual Machine Install Tools"
+.TH VIRT-CONVERT 1 "2008-07-07" "perl v5.8.8" "Virtual Machine Install Tools"
.SH "NAME"
virt\-convert \- convert virtual machines between formats
.SH "SYNOPSIS"
@@ -159,6 +159,11 @@
.IP "\-h, \-\-help" 4
.IX Item "-h, --help"
Show the help message and exit
+.IP "\-H \s-1HOST\s0, \-\-host=HOST" 4
+.IX Item "-H HOST, --host=HOST"
+Hypervisor target host. This is needed for some output formats such as
+\&\f(CW\*(C`virt\-instance\*(C'\fR, and it will default to the current host. Current
+accepted values are 'xvm' (for Solaris xVM), or 'xen' (for Xen).
.IP "\-a \s-1ARCH\s0, \-\-arch=ARCH" 4
.IX Item "-a ARCH, --arch=ARCH"
Architecture of the virtual machine (i686, x86_64, ppc). Defaults to
diff --git a/man/en/virt-convert.pod b/man/en/virt-convert.pod
--- a/man/en/virt-convert.pod
+++ b/man/en/virt-convert.pod
@@ -36,6 +36,12 @@
=item -h, --help
Show the help message and exit
+
+=item -H HOST, --host=HOST
+
+Hypervisor target host. This is needed for some output formats such as
+C<virt-instance>, and it will default to the current host. Current
+accepted values are 'xvm' (for Solaris xVM), or 'xen' (for Xen).
=item -a ARCH, --arch=ARCH
diff --git a/virt-convert b/virt-convert
--- a/virt-convert
+++ b/virt-convert
@@ -83,6 +83,8 @@
help=("Disables APIC for fully virtualized guest (overrides value in os-type/os-variant db)"), default=False)
opts.add_option("", "--noacpi", action="store_true", dest="noacpi",
help=("Disables ACPI for fully virtualized guest (overrides value in os-type/os-variant db)"), default=False)
+ opts.add_option("-H", "--host", type="string", dest="host", action="store",
+ default=vmconfig.default_host(), help=("Host hypervisor type, e.g. 'xen'"))
(options, args) = opts.parse_args()
if len(args) < 1:
@@ -196,6 +198,7 @@
else:
vmdef.type = vmconfig.VM_TYPE_HVM
+ vmdef.host = options.host
vmdef.arch = options.arch
vmdef.os_type = options.os_type
vmdef.os_variant = options.os_variant
diff --git a/virtconv/vmconfig.py b/virtconv/vmconfig.py
--- a/virtconv/vmconfig.py
+++ b/virtconv/vmconfig.py
@@ -18,7 +18,10 @@
# MA 02110-1301 USA.
#
+import platform
import os
+
+from virtinst import util
_parsers = [ ]
@@ -286,3 +289,13 @@
return (os.path.join(path, cfgfile), p.name)
raise StandardError("unknown format")
+
+def default_host():
+ """
+ Return the default host hypervisor, or 'None' if none seems present.
+ """
+ if platform.system() == "SunOS":
+ return "xvm"
+
+ # FIXME: should we massage this value?
+ return util.default_connection()
More information about the et-mgmt-tools
mailing list