This patch adds the persistent information to mock model and tests to
check if it is true.
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo(a)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 60e078a..dbdd57e 100644
--- a/src/kimchi/mockmodel.py
+++ b/src/kimchi/mockmodel.py
@@ -626,7 +626,11 @@ class MockModel(object):
if self._is_network_in_use(name):
raise InvalidOperation("KCHNET0018E", {'name': name})
- self._get_network(name).info['state'] = 'inactive'
+ network = self._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):
@@ -1009,6 +1013,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 ca4eeed..8f4573e 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