[virt-tools-list] [PATCH 8/9] Added a confirmation page to the Remove Pool flow.

Darryl L. Pierce dpierce at redhat.com
Fri Jul 22 15:32:11 UTC 2011


From: "Darryl L. Pierce" <dpierce at redhat.com>

The new page displays the name of the pool that was removed.

It also catches exceptions when the pool is deleted from underneath the
command.
---
 src/virtManagerTui/removepool.py |   30 +++++++++++++++++++++++++-----
 1 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/src/virtManagerTui/removepool.py b/src/virtManagerTui/removepool.py
index 0561e75..bea61c0 100644
--- a/src/virtManagerTui/removepool.py
+++ b/src/virtManagerTui/removepool.py
@@ -25,6 +25,7 @@ from storagelistconfigscreen import StorageListConfigScreen
 
 LIST_POOLS_PAGE    = 1
 CONFIRM_PAGE       = 2
+FINISHED_REMOVING  = 3
 
 class RemoveStoragePoolConfigScreen(StorageListConfigScreen):
     def __init__(self):
@@ -36,16 +37,25 @@ class RemoveStoragePoolConfigScreen(StorageListConfigScreen):
             return self.get_storage_pool_list_page(screen)
         elif page is CONFIRM_PAGE:
             return self.get_confirm_page(screen)
+        elif page is FINISHED_REMOVING:
+            return self.get_finished_removing_page(screen)
 
     def page_has_next(self, page):
-        return page is LIST_POOLS_PAGE and self.has_selectable_pools()
+        if page is LIST_POOLS_PAGE and self.has_selectable_pools():
+            return True
+        elif page is CONFIRM_PAGE:
+            return True
+        return False
+
+    def page_has_finish(self, page):
+        return page is FINISHED_REMOVING
 
     def page_has_back(self, page):
         ignore = page
         return False
 
     def page_has_finish(self, page):
-        return page is CONFIRM_PAGE
+        return page is FINISHED_REMOVING
 
     def validate_input(self, page, errors):
         if page is LIST_POOLS_PAGE:
@@ -62,18 +72,28 @@ class RemoveStoragePoolConfigScreen(StorageListConfigScreen):
 
     def process_input(self, page):
         if page is CONFIRM_PAGE:
-            self.get_libvirt().destroy_storage_pool(self.get_selected_pool())
-            self.get_libvirt().undefine_storage_pool(self.get_selected_pool())
+            try:
+                self.get_libvirt().destroy_storage_pool(self.get_selected_pool())
+                self.get_libvirt().undefine_storage_pool(self.get_selected_pool())
+            except Exception, error:
+                pass
 
     def get_confirm_page(self, screen):
         ignore = screen
-        self.set_finished()
         self.__confirm = Checkbox("Check here to confirm deleting pool: %s" % self.get_selected_pool())
         fields = []
         fields.append((None, self.__confirm))
         return [Label("Remove Selected Storage Pool"),
                 self.create_grid_from_fields(fields)]
 
+    def get_finished_removing_page(self, page):
+        self.set_finished()
+        pool = self.get_selected_pool()
+        state = ""
+        if self.get_libvirt().storage_pool_exists(pool):
+            state = "was not "
+        return [Label("Storage pool '%s' %sdeleted." % (pool, state))]
+
 def RemoveStoragePool():
     screen = RemoveStoragePoolConfigScreen()
     screen.start()
-- 
1.7.6




More information about the virt-tools-list mailing list