[virt-tools-list] [PATCH 06/10] Updated startnetwork.py to use vmmNetwork.

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


It also verifies that the network can be started before attempting to
start it.

Deleted the old libvirtworker.create_domain() API.
---
 src/virtManagerTui/configscreen.py  |    4 ++--
 src/virtManagerTui/libvirtworker.py |    6 +-----
 src/virtManagerTui/startnetwork.py  |   14 +++++++++-----
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/virtManagerTui/configscreen.py b/src/virtManagerTui/configscreen.py
index e997631..8468f40 100644
--- a/src/virtManagerTui/configscreen.py
+++ b/src/virtManagerTui/configscreen.py
@@ -191,8 +191,8 @@ class NetworkListConfigScreen(ConfigScreen):
     def __init__(self, title):
         ConfigScreen.__init__(self, title)
 
-    def get_network_list_page(self, screen, defined=True, created=True):
-        uuids = self.get_libvirt().list_networks(defined, created)
+    def get_network_list_page(self, screen, defined=True, started=True):
+        uuids = self.get_libvirt().list_networks(defined, started)
         result = None
 
         if len(uuids) > 0:
diff --git a/src/virtManagerTui/libvirtworker.py b/src/virtManagerTui/libvirtworker.py
index 677f252..5b74139 100644
--- a/src/virtManagerTui/libvirtworker.py
+++ b/src/virtManagerTui/libvirtworker.py
@@ -185,6 +185,7 @@ class LibvirtWorker:
         uuid -- the network's identifier
 
         '''
+        self.__vmmconn.tick()
         result = self.__vmmconn.get_net(uuid)
         if result is None: raise Exception("No such network exists: uuid=%s" % uuid)
 
@@ -232,11 +233,6 @@ class LibvirtWorker:
 
         self.__conn.networkDefineXML(xml)
 
-    def create_network(self, name):
-        '''Creates a defined network.'''
-        network = self.get_network(name)
-        network.create()
-
     def destroy_network(self, name):
         '''Destroys the specified network.'''
         network = self.get_network(name)
diff --git a/src/virtManagerTui/startnetwork.py b/src/virtManagerTui/startnetwork.py
index a54da8c..5d80fa3 100644
--- a/src/virtManagerTui/startnetwork.py
+++ b/src/virtManagerTui/startnetwork.py
@@ -29,7 +29,7 @@ class StartNetworkConfigScreen(NetworkListConfigScreen):
         NetworkListConfigScreen.__init__(self, "Start A Network")
 
     def get_elements_for_page(self, screen, page):
-        if   page is LIST_PAGE:  return self.get_network_list_page(screen, created = False)
+        if   page is LIST_PAGE:  return self.get_network_list_page(screen, started = False)
         elif page is START_PAGE: return self.get_start_network_page(screen)
 
     def page_has_next(self, page):
@@ -40,12 +40,16 @@ class StartNetworkConfigScreen(NetworkListConfigScreen):
 
     def validate_input(self, page, errors):
         if page is LIST_PAGE:
-            self.get_libvirt().start_network(self.get_selected_network())
-            return True
+            network = self.get_selected_network()
+            if network.is_active():
+                errors.append("%s is already started." % network.get_name())
+            else:
+                network.start()
+                return True
 
     def get_start_network_page(self, screen):
-        return [Label("Network Started"),
-                Label("%s was successfully started." % self.get_selected_network())]
+        network = self.get_selected_network()
+        return [Label("%s was successfully started." % network.get_name())]
 
 def StartNetwork():
     screen = StartNetworkConfigScreen()
-- 
1.7.5.1




More information about the virt-tools-list mailing list