Fix: Instantiation fails with single VNFD
When executing "Instantiate a VNF instance" with single VNFD, it fails with an error. This is because in instantiation, it's not possible to consider that VNFD is single, and an error will occur when trying to get the information of VNFD imported on the multiple premise. In this patch, if the VNFD is single, that is, if the imported VNFD doesn't exist, fix to skipping the subsequent VNFD information getting process. In unittest, I found an error in the existing single VNFD, so correct it as well. Change-Id: I9e664ec156bdcf3a95ecc1c6a0b582604f7f0335 Closes-Bug: #1886634
This commit is contained in:
parent
f1a0c7ebc0
commit
362b30066a
|
@ -756,6 +756,18 @@ node_types:
|
|||
ntt.nslab.VNF:
|
||||
derived_from: tosca.nodes.nfv.VNF
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
description: ID of this VNF
|
||||
default: vnf_id
|
||||
vendor:
|
||||
type: string
|
||||
description: name of the vendor who generate this VNF
|
||||
default: vendor
|
||||
version:
|
||||
type: version
|
||||
description: version of the software for this VNF
|
||||
default: 1.0
|
||||
descriptor_id:
|
||||
type: string
|
||||
constraints: [ valid_values: [ b1bb0ce7-ebca-4fa7-95ed-4840d70a1177 ] ]
|
||||
|
|
|
@ -315,6 +315,33 @@ class TestVnflcmDriver(db_base.SqlTestCase):
|
|||
self.assertEqual("INSTANTIATED", vnf_instance_obj.instantiation_state)
|
||||
shutil.rmtree(fake_csar)
|
||||
|
||||
@mock.patch.object(objects.VnfResource, 'create')
|
||||
@mock.patch.object(objects.VnfPackageVnfd, 'get_by_id')
|
||||
@mock.patch.object(objects.VnfInstance, "save")
|
||||
def test_instantiate_vnf_with_single_vnfd(self, mock_vnf_instance_save,
|
||||
mock_vnf_package_vnfd, mock_create):
|
||||
vnf_package_vnfd = fakes.return_vnf_package_vnfd()
|
||||
vnf_package_id = vnf_package_vnfd.package_uuid
|
||||
mock_vnf_package_vnfd.return_value = vnf_package_vnfd
|
||||
instantiate_vnf_req_dict = fakes.get_dummy_instantiate_vnf_request()
|
||||
instantiate_vnf_req_obj = \
|
||||
objects.InstantiateVnfRequest.obj_from_primitive(
|
||||
instantiate_vnf_req_dict, self.context)
|
||||
vnf_instance_obj = fakes.return_vnf_instance()
|
||||
|
||||
fake_csar = os.path.join(self.temp_dir, vnf_package_id)
|
||||
cfg.CONF.set_override('vnf_package_csar_path', self.temp_dir,
|
||||
group='vnf_package')
|
||||
test_utils.copy_csar_files(
|
||||
fake_csar, "sample_vnfpkg_no_meta_single_vnfd")
|
||||
self._mock_vnf_manager(vnf_resource_count=2)
|
||||
driver = vnflcm_driver.VnfLcmDriver()
|
||||
driver.instantiate_vnf(self.context, vnf_instance_obj,
|
||||
instantiate_vnf_req_obj)
|
||||
self.assertEqual(2, mock_create.call_count)
|
||||
self.assertEqual("INSTANTIATED", vnf_instance_obj.instantiation_state)
|
||||
shutil.rmtree(fake_csar)
|
||||
|
||||
@mock.patch.object(objects.VnfInstance, "save")
|
||||
@mock.patch.object(vim_client.VimClient, "get_vim")
|
||||
@mock.patch.object(objects.VnfResourceList, "get_by_vnf_instance_id")
|
||||
|
|
|
@ -214,7 +214,7 @@ def _get_param_data(vnfd_dict, instantiate_vnf_req):
|
|||
input_attributes = vnfd_dict.get('topology_template', {}).get('inputs')
|
||||
if substitution_map is not None:
|
||||
subs_map_node_type = substitution_map.get('node_type')
|
||||
import_paths = vnfd_dict.get('imports')
|
||||
import_paths = vnfd_dict.get('imports', {})
|
||||
for imp_path in import_paths:
|
||||
with open(imp_path) as file_obj:
|
||||
import_data = yaml.safe_load(file_obj)
|
||||
|
|
Loading…
Reference in New Issue