[virt-tools-list] [PATCH 07/10] Renamed destroynetwork.py to stopnetwork.py.

Darryl L. Pierce dpierce at redhat.com
Thu May 26 18:37:22 UTC 2011


The old name was not consistent with the add/delete/start/stop/list
verbs used for commands.

Updated the network menu to use the new name and module.
---
 src/virtManagerTui/destroynetwork.py |   56 ----------------------------------
 src/virtManagerTui/netmenu.py        |    8 ++--
 src/virtManagerTui/stopnetwork.py    |   56 ++++++++++++++++++++++++++++++++++
 3 files changed, 60 insertions(+), 60 deletions(-)
 delete mode 100644 src/virtManagerTui/destroynetwork.py
 create mode 100644 src/virtManagerTui/stopnetwork.py

diff --git a/src/virtManagerTui/destroynetwork.py b/src/virtManagerTui/destroynetwork.py
deleted file mode 100644
index 5fb3e82..0000000
--- a/src/virtManagerTui/destroynetwork.py
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/usr/bin/env python
-#
-# destroynetwork.py - Copyright (C) 2009 Red Hat, Inc.
-# Written by Darryl L. Pierce <dpierce at redhat.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-# MA  02110-1301, USA.  A copy of the GNU General Public License is
-# also available at http://www.gnu.org/copyleft/gpl.html.
-
-from snack import *
-from configscreen import *
-
-LIST_PAGE    = 1
-DESTROY_PAGE = 2
-
-class DestroyNetworkConfigScreen(NetworkListConfigScreen):
-    def __init__(self):
-        NetworkListConfigScreen.__init__(self, "Destroy A Network")
-
-    def get_elements_for_page(self, screen, page):
-        if   page is LIST_PAGE:    return self.get_network_list_page(screen, defined = False)
-        elif page is DESTROY_PAGE: return self.get_destroy_network_page(screen)
-
-    def page_has_next(self, page):
-        if page is LIST_PAGE: return self.has_selectable_networks()
-        return False
-
-    def page_has_back(self, page):
-        if page is DESTROY_PAGE: return True
-        return False
-
-    def validate_input(self, page, errors):
-        if page is LIST_PAGE:
-            network = self.get_selected_network()
-            self.get_libvirt().destroy_network(network)
-            return True
-        return False
-
-    def get_destroy_network_page(self, screen):
-        return [Label("Network Destroyed"),
-                Label("%s has been destroyed." % self.get_selected_network())]
-
-def DestroyNetwork():
-    screen = DestroyNetworkConfigScreen()
-    screen.start()
diff --git a/src/virtManagerTui/netmenu.py b/src/virtManagerTui/netmenu.py
index 4fb3a32..370452d 100644
--- a/src/virtManagerTui/netmenu.py
+++ b/src/virtManagerTui/netmenu.py
@@ -22,7 +22,7 @@ import traceback
 from menuscreen      import MenuScreen
 from definenet       import DefineNetwork
 from startnetwork    import StartNetwork
-from destroynetwork  import DestroyNetwork
+from stopnetwork     import StopNetwork
 from undefinenetwork import UndefineNetwork
 from listnetworks    import ListNetworks
 
@@ -31,7 +31,7 @@ import logging
 
 DEFINE_NETWORK   = 1
 START_NETWORK    = 2
-DESTROY_NETWORK  = 3
+STOP_NETWORK     = 3
 UNDEFINE_NETWORK = 4
 LIST_NETWORKS    = 5
 
@@ -42,14 +42,14 @@ class NetworkMenuScreen(MenuScreen):
     def get_menu_items(self):
         return (("Define A Network",   DEFINE_NETWORK),
                 ("Start A Network",    START_NETWORK),
-                ("Destroy A Network",  DESTROY_NETWORK),
+                ("Stop A Network",     STOP_NETWORK),
                 ("Undefine A Network", UNDEFINE_NETWORK),
                 ("List Networks",      LIST_NETWORKS))
 
     def handle_selection(self, item):
         if   item is DEFINE_NETWORK:   DefineNetwork()
         elif item is START_NETWORK:    StartNetwork()
-        elif item is DESTROY_NETWORK:  DestroyNetwork()
+        elif item is STOP_NETWORK:     StopNetwork()
         elif item is UNDEFINE_NETWORK: UndefineNetwork()
         elif item is LIST_NETWORKS:    ListNetworks()
 
diff --git a/src/virtManagerTui/stopnetwork.py b/src/virtManagerTui/stopnetwork.py
new file mode 100644
index 0000000..b9d62f9
--- /dev/null
+++ b/src/virtManagerTui/stopnetwork.py
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+#
+# stopnetwork.py - Copyright (C) 2009 Red Hat, Inc.
+# Written by Darryl L. Pierce <dpierce at redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA  02110-1301, USA.  A copy of the GNU General Public License is
+# also available at http://www.gnu.org/copyleft/gpl.html.
+
+from snack import *
+from configscreen import *
+
+LIST_PAGE = 1
+STOP_PAGE = 2
+
+class StopNetworkConfigScreen(NetworkListConfigScreen):
+    def __init__(self):
+        NetworkListConfigScreen.__init__(self, "Stop A Network")
+
+    def get_elements_for_page(self, screen, page):
+        if   page is LIST_PAGE: return self.get_network_list_page(screen, defined = False)
+        elif page is STOP_PAGE: return self.get_stop_network_page(screen)
+
+    def page_has_next(self, page):
+        if page is LIST_PAGE: return self.has_selectable_networks()
+        return False
+
+    def page_has_back(self, page):
+        if page is STOP_PAGE: return True
+        return False
+
+    def validate_input(self, page, errors):
+        if page is LIST_PAGE:
+            network = self.get_selected_network()
+            self.get_libvirt().stop_network(network)
+            return True
+        return False
+
+    def get_stop_network_page(self, screen):
+        return [Label("Network Stoped"),
+                Label("%s has been stoped." % self.get_selected_network())]
+
+def StopNetwork():
+    screen = StopNetworkConfigScreen()
+    screen.start()
-- 
1.7.5.1




More information about the virt-tools-list mailing list