[et-mgmt-tools] [patch 4/8] Re-factor virt-installs post-install checking code

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

 



This patch attempts to clean up the two similar "start guest,
check to see if it succeeded" code paths into a single code
path.

Signed-off-by: Mark McLoughlin <markmc@xxxxxxxxxx>

Index: virtinst--devel/virt-install
===================================================================
--- virtinst--devel.orig/virt-install
+++ virtinst--devel/virt-install
@@ -565,51 +565,47 @@ def main():
     # we've got everything -- try to start the install
     try:
         print "\n\nStarting install..."
-        dom = guest.start_install(conscb,progresscb)
-        if dom is None:
-            print "Guest installation failed"
-            sys.exit(0)
-        elif dom.info()[0] != libvirt.VIR_DOMAIN_SHUTOFF:
-            # domain seems to be running
-            print "Domain installation still in progress.  You can reconnect "
-            print "to the console to complete the installation process."
-            sys.exit(0)
-    except RuntimeError, e:
-        print >> sys.stderr, "ERROR: ", e
-        sys.exit(1)
 
-    # the domain is no longer running
-    # FIXME: this is just a hacky heuristic, but I'll take what I can get
-    try:
-        if guest.post_install_check():
-            # things installed enough that we should be able to restart
-            # the domain
-            if continue_inst:
-                # continue to installation.
+        started = False
+        while True:
+            if not started:
+                dom = guest.start_install(conscb,progresscb)
+            elif continue_inst:
                 dom = guest.continue_install(conscb,progresscb)
-                if dom is None:
-                    print "Guest installation failed"
-                    sys.exit(0)
-                elif dom.info()[0] != libvirt.VIR_DOMAIN_SHUTOFF:
-                    # domain seems to be running
-                    print "Domain installation still in progress.  You can reconnect "
-                    print "to the console to complete the installation process."
+                continue_inst = False
+            else:
+                break
+
+            if dom is None:
+                print "Guest installation failed"
+                sys.exit(0)
+            elif dom.info()[0] != libvirt.VIR_DOMAIN_SHUTOFF:
+                # domain seems to be running
+                print "Domain installation still in progress.  You can reconnect "
+                print "to the console to complete the installation process."
+                sys.exit(0)
+
+            if not started:
+                started = True
+                if not guest.post_install_check():
+                    print ("Domain installation does not appear to have been\n"
+                           "successful.  If it was, you can restart your domain\n"
+                           "by running 'virsh start %s'; otherwise, please\n"
+                           "restart your installation.") %(guest.name,)
                     sys.exit(0)
-            print "Guest installation complete... restarting guest."
-            dom.create()
-            guest.connect_console(conscb)
-        else:
-            print ("Domain installation does not appear to have been\n"
-                   "successful.  If it was, you can restart your domain\n"
-                   "by running 'virsh start %s'; otherwise, please\n"
-                   "restart your installation.") %(guest.name,)
+
+        print "Guest installation complete... restarting guest."
+        dom.create()
+        guest.connect_console(conscb)
+    except RuntimeError, e:
+        print >> sys.stderr, "ERROR: ", e
+        sys.exit(1)
     except Exception, e:
-        print "exception was:", e
         print ("Domain installation may not have been\n"
                "successful.  If it was, you can restart your domain\n"
                "by running 'virsh start %s'; otherwise, please\n"
                "restart your installation.") %(guest.name,)
-
+        raise
 
 if __name__ == "__main__":
     main()

-- 


[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux