[Kimchi-devel] [PATCH V7 5/7] template supports networks: update model

Aline Manera alinefm at linux.vnet.ibm.com
Fri Jan 3 17:17:40 UTC 2014


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

On 01/03/2014 07:32 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/model.py | 14 ++++++++++++++
>   1 file changed, 14 insertions(+)
>
> diff --git a/src/kimchi/model.py b/src/kimchi/model.py
> index 572b316..cbde74a 100644
> --- a/src/kimchi/model.py
> +++ b/src/kimchi/model.py
> @@ -678,6 +678,13 @@ class Model(object):
>
>       def templates_create(self, params):
>           name = params['name']
> +        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)
> +
>           with self.objstore as session:
>               if name in session.get_list('template'):
>                   raise InvalidOperation("Template already exists")
> @@ -698,6 +705,13 @@ class Model(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)




More information about the Kimchi-devel mailing list