File output-libvirtxml-file.patch of Package open-ovf

Index: open-ovf-0.1/py/ovf/OvfSet.py
===================================================================
--- open-ovf-0.1.orig/py/ovf/OvfSet.py
+++ open-ovf-0.1/py/ovf/OvfSet.py
@@ -398,7 +398,7 @@ class OvfSet(object):
             raise
 
 # Libvirt Interface
-    def boot(self, virtPlatform = None, configId=None, installLoc=None, envDirectory=None):
+    def boot(self, virtPlatform = None, ofile=None, configId=None, installLoc=None, envDirectory=None):
         """
         Boots OvfSet as libvirt domain(s).
 
@@ -422,8 +422,15 @@ class OvfSet(object):
                                            virtPlatform, configId,
                                            envDirectory)
 
-        # queue domains with action: domains[id].create()
-        schedule = OvfLibvirt.getSchedule(startup, domains)
+        if ofile:
+            fd = os.open(ofile, os.O_RDWR | os.O_CREAT | os.O_TRUNC, 0644)
+            for domain in domains.values():
+                os.write(fd, domain)
+                os.write(fd, "\n\n")
+            os.close(fd)
+        else:
+            # queue domains with action: domains[id].create()
+            schedule = OvfLibvirt.getSchedule(startup, domains)
 
-        schedule.run()
+            schedule.run()
 
Index: open-ovf-0.1/py/scripts/ova
===================================================================
--- open-ovf-0.1.orig/py/scripts/ova
+++ open-ovf-0.1/py/scripts/ova
@@ -578,7 +578,8 @@ def run(options, args):
             ovf.writeAsDir(installLoc)
 
         # Boot Virtual Machines
-        ovf.boot(options.virtPlatform, None, installLoc, options.envDir)
+        ovf.boot(options.virtPlatform, options.ofile, None, installLoc,
+                 options.envDir)
         sys.exit(0)
 
     else:
@@ -698,6 +699,11 @@ COMMANDS = {
                       'help' : "Virtualization Platform"}
         },
         {
+            'flags' : ['-o', '--ofile'],
+            'parms': {'dest' : 'ofile',
+                      'help' : "Output file for libvirt XML"}
+        },
+        {
             "flags" : ["-e", "--environment"],
             "parms" : {"dest"    : "envDir", 'default' : None,
                        "help"    : "Path to environment files"}
openSUSE Build Service is sponsored by