[Kimchi-devel] [PATCH V7 6/7] template supports networks: update mockmodel
shaohef at linux.vnet.ibm.com
shaohef at linux.vnet.ibm.com
Fri Jan 3 09:32:58 UTC 2014
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 | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py
index 348127a..9488078 100644
--- a/src/kimchi/mockmodel.py
+++ b/src/kimchi/mockmodel.py
@@ -200,6 +200,13 @@ 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', []):
+ try:
+ self._get_network(net_name)
+ except NotFoundError:
+ raise InvalidParameter("Network '%s' specified by template "
+ "does not exist" % net_name)
+
t = MockVMTemplate(params, self)
self._mock_templates[name] = t
return name
@@ -217,6 +224,13 @@ 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', []):
+ try:
+ self._get_network(net_name)
+ except NotFoundError:
+ raise InvalidParameter("Network '%s' specified by template "
+ "does not exist" % net_name)
+
self.template_delete(name)
try:
ident = self.templates_create(new_t)
@@ -457,7 +471,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