[virt-tools-list] [PATCH 5/9] Updated the stopnetwork.py command.

Darryl L. Pierce dpierce at redhat.com
Fri Jul 15 14:02:22 UTC 2011


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

Added logging for when an exception occurs while stopping a network

The command returns true or false based on the state of the network
after the stop call rather than assuming it's true.
---
 src/virtManagerTui/stopnetwork.py |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/virtManagerTui/stopnetwork.py b/src/virtManagerTui/stopnetwork.py
index fe5247c..e41edc5 100644
--- a/src/virtManagerTui/stopnetwork.py
+++ b/src/virtManagerTui/stopnetwork.py
@@ -18,8 +18,9 @@
 # MA  02110-1301, USA.  A copy of the GNU General Public License is
 # also available at http://www.gnu.org/copyleft/gpl.html.
 
-import snack
+from snack import Label
 from networklistconfigscreen import NetworkListConfigScreen
+import logging
 
 LIST_PAGE = 1
 STOP_PAGE = 2
@@ -47,14 +48,16 @@ class StopNetworkConfigScreen(NetworkListConfigScreen):
     def validate_input(self, page, errors):
         if page is LIST_PAGE:
             network = self.get_selected_network()
-            network.stop()
-            return True
-        return False
+            try:
+                network.stop()
+            except Exception as error:
+                logging.error(error)
+        return network.is_active() is not True
 
     def get_stop_network_page(self, screen):
         ignore = screen
         network = self.get_selected_network()
-        return [snack.Label("%s has been stopped." % network.get_name())]
+        return [Label("%s has been stopped." % network.get_name())]
 
 def StopNetwork():
     screen = StopNetworkConfigScreen()
-- 
1.7.6




More information about the virt-tools-list mailing list