[Kimchi-devel] [PATCH V3 3/3] Fix non persistent network handling (mockmodel/tests)

Rodrigo Trujillo rodrigo.trujillo at linux.vnet.ibm.com
Tue Mar 25 12:33:01 UTC 2014


This patch adds the persistent information to mockmodel and tests to
check if it is true.

Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
---
 src/kimchi/mockmodel.py | 7 ++++++-
 tests/test_model.py     | 1 +
 tests/test_rest.py      | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py
index faf1049..ba4365f 100644
--- a/src/kimchi/mockmodel.py
+++ b/src/kimchi/mockmodel.py
@@ -625,7 +625,11 @@ class MockModel(object):
         if self._is_network_in_use(name):
             raise InvalidOperation("KCHNET0018E", {'name': name})
 
-        self._get_network(name).info['state'] = 'inactive'
+        network = _get_network(name)
+        if not network.info['persistent']:
+            self.network_delete(name)
+
+        network.info['state'] = 'inactive'
 
     def network_delete(self, name):
         if self._is_network_in_use(name):
@@ -1008,6 +1012,7 @@ class MockNetwork(object):
                      'subnet': '192.168.122.0/24',
                      'dhcp': {'start': '192.168.122.128',
                               'stop':  '192.168.122.254'},
+                     'persistent': True
                      }
 
 
diff --git a/tests/test_model.py b/tests/test_model.py
index 69f9b5b..b8e6d47 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -632,6 +632,7 @@ class ModelTests(unittest.TestCase):
             self.assertEquals('inactive', networkinfo['state'])
             self.assertEquals([], networkinfo['vms'])
             self.assertTrue(networkinfo['autostart'])
+            self.assertTrue(networkinfo['persistent'])
 
             inst.network_activate(name)
             rollback.prependDefer(inst.network_deactivate, name)
diff --git a/tests/test_rest.py b/tests/test_rest.py
index 3f2e449..929b7ab 100644
--- a/tests/test_rest.py
+++ b/tests/test_rest.py
@@ -1297,6 +1297,7 @@ class RestTests(unittest.TestCase):
         network = json.loads(request(host, port,
                                      '/networks/test-network').read())
         self.assertEquals('inactive', network['state'])
+        self.assertTrue(network['persistent'])
 
         # activate the network
         resp = request(host, port,
-- 
1.8.5.3




More information about the Kimchi-devel mailing list