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

Aline Manera alinefm at linux.vnet.ibm.com
Thu Jan 2 19:17:27 UTC 2014


Reviewed-by: Aline Manera <alinefm at linux.vnet.ibm.com>

On 01/02/2014 08:22 AM, shaohef at linux.vnet.ibm.com wrote:
> 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)




More information about the Kimchi-devel mailing list