[Kimchi-devel] [PATCH V2 1/2] Fix non persistent network handling (backend)

Rodrigo Trujillo rodrigo.trujillo at linux.vnet.ibm.com
Fri Mar 21 12:24:06 UTC 2014


If some network is not persistent and the user tries to stop it, it is
going to be removed by libvirt and causes an error in Kimchi.
This patch changes the backend in order to get persistent information
and expose this information. It also changes API.md.

Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
---
 docs/API.md                    | 2 ++
 src/kimchi/control/networks.py | 3 ++-
 src/kimchi/model/networks.py   | 3 ++-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/docs/API.md b/docs/API.md
index 672ef14..b8f941a 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -504,6 +504,8 @@ A interface represents available interface on host.
     * interface: The name of a bridge network interface on the host.  All traffic
                  on this network will be bridged through the indicated interface.
                  The interface is a bridge or ethernet/bonding device.
+    * persistent: If 'true', network will persist after a system reboot or be stopped.
+                  All networks created by Kimchi are persistent.
 
 * **DELETE**: Remove the Network
 * **POST**: *See Network Actions*
diff --git a/src/kimchi/control/networks.py b/src/kimchi/control/networks.py
index 95e8523..b905891 100644
--- a/src/kimchi/control/networks.py
+++ b/src/kimchi/control/networks.py
@@ -45,4 +45,5 @@ class Network(Resource):
                 'interface': self.info['interface'],
                 'subnet': self.info['subnet'],
                 'dhcp': self.info['dhcp'],
-                'state': self.info['state']}
+                'state': self.info['state'],
+                'persistent': self.info['persistent']}
diff --git a/src/kimchi/model/networks.py b/src/kimchi/model/networks.py
index 27abd54..5cd5b7e 100644
--- a/src/kimchi/model/networks.py
+++ b/src/kimchi/model/networks.py
@@ -231,7 +231,8 @@ class NetworkModel(object):
                 'vms': self._get_vms_attach_to_a_network(name),
                 'in_use': self._is_network_in_use(name),
                 'autostart': network.autostart() == 1,
-                'state':  network.isActive() and "active" or "inactive"}
+                'state':  network.isActive() and "active" or "inactive",
+                'persistent': True if network.isPersistent() else False}
 
     def _is_network_in_use(self, name):
         # The network "default" is used for Kimchi proposal and should not be
-- 
1.8.5.3




More information about the Kimchi-devel mailing list