Check mgmt_driver in TOSCA template supported by VNFM
If the mgmt_driver is checked in the first place, then there is no problem when the VNF is created. Change-Id: I6a37cf93f4c7c2bbfab7ce68ea65a34f11407633 Closes-Bug: #1611228
This commit is contained in:
parent
355c5b0842
commit
360980a68b
4
releasenotes/notes/bug-1611228-c7b09ef670e420f6.yaml
Normal file
4
releasenotes/notes/bug-1611228-c7b09ef670e420f6.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Check the validation of mgmt_driver before creating the VNF.
|
@ -47,6 +47,10 @@ class VNFInUse(exceptions.InUse):
|
||||
message = _('VNF %(vnf_id)s is still in use')
|
||||
|
||||
|
||||
class InvalidMgmtDriver(exceptions.InvalidInput):
|
||||
message = _('Invalid Mgmt driver %(mgmt_driver_name)s.')
|
||||
|
||||
|
||||
class InvalidInfraDriver(exceptions.InvalidInput):
|
||||
message = _('VIM type %(vim_name)s is not supported as an infra driver')
|
||||
|
||||
|
@ -224,7 +224,7 @@ class TestVNFMPlugin(db_base.SqlTestCase):
|
||||
@mock.patch('tacker.vnfm.plugin.toscautils.get_mgmt_driver')
|
||||
def test_create_vnfd(self, mock_get_mgmt_driver, mock_tosca_template,
|
||||
mock_update_imports):
|
||||
mock_get_mgmt_driver.return_value = 'dummy_mgmt_driver'
|
||||
mock_get_mgmt_driver.return_value = 'noop'
|
||||
mock_tosca_template.return_value = mock.ANY
|
||||
|
||||
vnfd_obj = utils.get_dummy_vnfd_obj()
|
||||
@ -233,7 +233,7 @@ class TestVNFMPlugin(db_base.SqlTestCase):
|
||||
self.assertIn('id', result)
|
||||
self.assertEqual('dummy_vnfd', result['name'])
|
||||
self.assertEqual('dummy_vnfd_description', result['description'])
|
||||
self.assertEqual('dummy_mgmt_driver', result['mgmt_driver'])
|
||||
self.assertEqual('noop', result['mgmt_driver'])
|
||||
self.assertIn('service_types', result)
|
||||
self.assertIn('attributes', result)
|
||||
self.assertIn('created_at', result)
|
||||
@ -533,3 +533,12 @@ class TestVNFMPlugin(db_base.SqlTestCase):
|
||||
policies = self.vnfm_plugin.get_vnf_policies(self.context, vnf_id,
|
||||
filters={'name': 'vdu1_cpu_usage_monitoring_policy'})
|
||||
self.assertEqual(1, len(policies))
|
||||
|
||||
@mock.patch('tacker.vnfm.plugin.toscautils.get_mgmt_driver')
|
||||
def test_mgmt_driver(self, mock_get_mgmt_driver):
|
||||
mock_get_mgmt_driver.return_value = 'dummy_mgmt_driver'
|
||||
|
||||
vnfd_obj = utils.get_dummy_vnfd_obj()
|
||||
self.assertRaises(vnfm.InvalidMgmtDriver,
|
||||
self.vnfm_plugin.create_vnfd,
|
||||
self.context, vnfd_obj)
|
||||
|
@ -216,6 +216,12 @@ class VNFMPlugin(vnfm_db.VNFMPluginDb, VNFMMgmtMixin):
|
||||
|
||||
vnfd_dict['mgmt_driver'] = toscautils.get_mgmt_driver(
|
||||
tosca)
|
||||
|
||||
if vnfd_dict['mgmt_driver'] not in cfg.CONF.tacker.mgmt_driver:
|
||||
LOG.error("Invalid mgmt_driver in TOSCA template")
|
||||
raise vnfm.InvalidMgmtDriver(
|
||||
mgmt_driver_name=vnfd_dict['mgmt_driver'])
|
||||
|
||||
LOG.debug('vnfd %s', vnfd)
|
||||
|
||||
def add_vnf_to_monitor(self, context, vnf_dict):
|
||||
|
Loading…
Reference in New Issue
Block a user