From be6ceb11f7fb66cb7c8f3bc97eb9374ade0e9e17 Mon Sep 17 00:00:00 2001 From: dharmendra Date: Thu, 31 Jan 2019 22:49:30 -0800 Subject: [PATCH] Improve the returned Message for nsd-create When creating nsd with non-existent vnfd in tosca template, we got internal error. This patch will fix this and will return with NotFound error. Partially Implements: blueprint improve-return-message Closes-Bug: #1710801 Change-Id: I7e9da552673088fe36e244d4658ad243e21a1fca --- tacker/common/exceptions.py | 2 +- tacker/db/vnfm/vnfm_db.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tacker/common/exceptions.py b/tacker/common/exceptions.py index 00caf8aed..72b2a6d97 100644 --- a/tacker/common/exceptions.py +++ b/tacker/common/exceptions.py @@ -58,7 +58,7 @@ class BadRequest(TackerException): class NotFound(TackerException): - pass + message = _('%(resource)s %(name)s not Found') class Conflict(TackerException): diff --git a/tacker/db/vnfm/vnfm_db.py b/tacker/db/vnfm/vnfm_db.py index bcdb3199f..440aed66b 100644 --- a/tacker/db/vnfm/vnfm_db.py +++ b/tacker/db/vnfm/vnfm_db.py @@ -341,6 +341,8 @@ class VNFMPluginDb(vnfm.VNFMPluginBase, db_base.CommonDbMixin): def get_vnfd(self, context, vnfd_id, fields=None): vnfd_db = self._get_resource(context, VNFD, vnfd_id) + if not vnfd_db: + raise exceptions.NotFound(resource='VNFD', name=vnfd_id) return self._make_vnfd_dict(vnfd_db) def get_vnfds(self, context, filters, fields=None):