nsd-create failed abnormally if import sesction missing in template
While creating ns descriptor with a template which missing import section, create command failed abnormally with error message: internal server error. This patch will fix the issue and will raise TOSCA parser error. Change-Id: I0c4a07b4fe1e6c87dc17e24c22f34e34fa6fd71e Closes-bug: #1814855
This commit is contained in:
parent
8a761105a0
commit
af30f95205
|
@ -623,7 +623,11 @@ class NfvoPlugin(nfvo_db_plugin.NfvoPluginDb, vnffg_db.VnffgPluginDbMixin,
|
|||
LOG.debug('nsd_dict: %s', inner_nsd_dict)
|
||||
|
||||
vnfm_plugin = manager.TackerManager.get_service_plugins()['VNFM']
|
||||
vnfd_imports = inner_nsd_dict['imports']
|
||||
vnfd_imports = inner_nsd_dict.get('imports')
|
||||
if not vnfd_imports:
|
||||
LOG.error('VNFD import section is missing')
|
||||
raise nfvo.ToscaParserFailed(
|
||||
error_msg_details='VNFD import section is missing')
|
||||
inner_nsd_dict['imports'] = []
|
||||
new_files = []
|
||||
for vnfd_name in vnfd_imports:
|
||||
|
|
|
@ -1083,6 +1083,16 @@ class TestNfvoPlugin(db_base.SqlTestCase):
|
|||
self.assertIn('created_at', result)
|
||||
self.assertIn('updated_at', result)
|
||||
|
||||
def test_create_nsd_without_vnfd_imports(self):
|
||||
nsd_obj = utils.get_dummy_nsd_obj()
|
||||
# Remove vnfd import section from nsd.
|
||||
nsd_obj['nsd']['attributes']['nsd'].pop('imports')
|
||||
with patch.object(TackerManager, 'get_service_plugins') as \
|
||||
mock_plugins:
|
||||
mock_plugins.return_value = {'VNFM': FakeVNFMPlugin()}
|
||||
self.assertRaises(nfvo.ToscaParserFailed,
|
||||
self.nfvo_plugin.create_nsd, self.context, nsd_obj)
|
||||
|
||||
def test_create_nsd_inline(self):
|
||||
nsd_obj = utils.get_dummy_nsd_obj_inline()
|
||||
with patch.object(TackerManager, 'get_service_plugins') as \
|
||||
|
|
Loading…
Reference in New Issue