[Kimchi-devel] [PATCH V4 6/7] template supports networks: update mockmodel

shaohef at linux.vnet.ibm.com shaohef at linux.vnet.ibm.com
Tue Dec 31 12:49:38 UTC 2013


From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>

check all networks exist

Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
---
 src/kimchi/mockmodel.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py
index 348127a..8344bd3 100644
--- a/src/kimchi/mockmodel.py
+++ b/src/kimchi/mockmodel.py
@@ -200,6 +200,8 @@ class MockModel(object):
         name = params['name']
         if name in self._mock_templates:
             raise InvalidOperation("Template already exists")
+        for net_name in params.get(u'networks', []):
+            self._get_network(net_name)
         t = MockVMTemplate(params, self)
         self._mock_templates[name] = t
         return name
@@ -217,6 +219,9 @@ class MockModel(object):
         except Exception as e:
             raise InvalidParameter("Storagepool specified is not valid: %s." % e.message)
 
+        for net_name in params.get(u'networks', []):
+            self._get_network(net_name)
+
         self.template_delete(name)
         try:
             ident = self.templates_create(new_t)
@@ -457,7 +462,7 @@ class MockModel(object):
         try:
             return self._mock_networks[name]
         except KeyError:
-            raise NotFoundError()
+            raise NotFoundError("Network '%s'" % name)
 
     def network_lookup(self, name):
         network = self._get_network(name)
-- 
1.8.4.2




More information about the Kimchi-devel mailing list