[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[et-mgmt-tools] [PATCH] virt-clone --original-xml option
- From: Cole Robinson <crobinso redhat com>
- To: Fedora/Linux Management Tools <et-mgmt-tools redhat com>
- Subject: [et-mgmt-tools] [PATCH] virt-clone --original-xml option
- Date: Wed, 18 Feb 2009 21:40:08 -0500
Hi all,
The attached patch adds a new command line option to virt-clone:
--original-xml. This allows the user to specify the guest to clone as an
xml file, rather than require the use of a guest defined on the current
connection. The backend code in CloneManager is already present (I
recently added it to help build up a test suite).
Any input (option name, docs, etc) appreciated.
Thanks,
Cole
# HG changeset patch
# User Cole Robinson <crobinso redhat com>
# Date 1234977563 18000
# Node ID 90143398f8426e7b3de106e8ee5e50d18e0ff2c8
# Parent 2fdf8457b2929f655f4525aee9acfdc2b26a7c03
Add --original-xml option to virt-clone
Allows passing a libvirt xml file to use as the original guest, rather than require an existing defined guest on the connection.
diff -r 2fdf8457b292 -r 90143398f842 man/en/virt-clone.pod
--- a/man/en/virt-clone.pod Wed Feb 18 12:11:14 2009 -0500
+++ b/man/en/virt-clone.pod Wed Feb 18 12:19:23 2009 -0500
@@ -35,8 +35,14 @@
=item -o ORIGINAL_GUEST, --original=ORIGINAL_GUEST
-Name of the original guest to be cloned. This guest must be shut off since
-it is not possible to safely clone active guests at this time.
+Name of the original guest to be cloned. This guest must be shut off or paused
+since it is not possible to safely clone active guests at this time.
+
+=item --original-xml=ORIGINAL_XML
+
+Libvirt guest xml file to use as the original guest. The guest does not need to
+be defined on the libvirt connection. This takes the place of the
+C<--original> parameter.
=item -n NAME, --name=NAME
diff -r 2fdf8457b292 -r 90143398f842 virt-clone
--- a/virt-clone Wed Feb 18 12:11:14 2009 -0500
+++ b/virt-clone Wed Feb 18 12:19:23 2009 -0500
@@ -48,15 +48,27 @@
print _("ERROR: "), e
new_name = None
-def get_original_guest(guest, design):
+def get_original_guest(guest, origfile, design):
+
+ origxml = None
+ if origfile:
+ f = open(origfile, "r")
+ origxml = f.read()
+ f.close()
+
while 1:
- guest = cli.prompt_for_input(_("What is the name of the original virtual machine?"), guest)
+ if not origxml:
+ guest = cli.prompt_for_input(_("What is the name of the original virtual machine?"), guest)
try:
- design.original_guest = guest
+ if origxml:
+ design.original_xml = origxml
+ else:
+ design.original_guest = guest
break
except (ValueError, RuntimeError), e:
print _("ERROR: "), e
guest = None
+ origxml = None
def get_clone_macaddr(new_mac, design):
if new_mac is None:
@@ -140,7 +152,11 @@
geng.add_option("-o", "--original", type="string", dest="original_guest",
action="callback", callback=cli.check_before_store,
help=_("Name of the original guest; "
- "The status must be shut off"))
+ "The status must be shut off or paused."))
+ geng.add_option("", "--original-xml", type="string",
+ dest="original_xml", action="callback",
+ callback=cli.check_before_store,
+ help=_("XML file to use as the original guest."))
geng.add_option("-n", "--name", type="string", dest="new_name",
action="callback", callback=cli.check_before_store,
help=_("Name for the new guest"))
@@ -209,7 +225,8 @@
get_clone_diskfile(options.new_diskfile, design, conn,
not options.preserve)
get_clone_macaddr(options.new_mac, design)
- get_original_guest(options.original_guest, design)
+ get_original_guest(options.original_guest, options.original_xml,
+ design)
get_clone_name(options.new_name, design)
get_clone_uuid(options.new_uuid, design)
get_clone_sparse(options.sparse, design)
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]