From 2edb3bd51f626f8204ab0834879ecfc7cfc6db90 Mon Sep 17 00:00:00 2001 From: doantungbk Date: Sat, 31 Dec 2016 01:36:03 -0800 Subject: [PATCH] Fix: nested resources are ignored The current "resource-list" method in Tacker just mentioned to the first-layered resources. Meanwhile scaling feature used the nested template which contains VNF discription. Therefore, the nested resources are ignored in the scaling case. This spec will fix this issue. Co-Authored-By: venkatamahesh Closes-Bug: #1629028 Change-Id: I0a4258873f7898a009a155f2b048638cdbc581d9 --- .../tests/functional/vnfm/test_tosca_vnf_scale.py | 11 ++++++++++- tacker/vnfm/infra_drivers/openstack/openstack.py | 13 ++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/tacker/tests/functional/vnfm/test_tosca_vnf_scale.py b/tacker/tests/functional/vnfm/test_tosca_vnf_scale.py index ac468aedb..0b06a6b83 100644 --- a/tacker/tests/functional/vnfm/test_tosca_vnf_scale.py +++ b/tacker/tests/functional/vnfm/test_tosca_vnf_scale.py @@ -61,6 +61,15 @@ class VnfTestToscaScale(base.BaseTackerTest): self.assertEqual(count, len(json.loads(vnf['mgmt_url'])['VDU1'])) _wait(2) + # Get nested resources when vnf is in active state + vnf_details = self.client.list_vnf_resources(vnf_id)['resources'] + resources_list = list() + for vnf_detail in vnf_details: + resources_list.append(vnf_detail['name']) + self.assertIn('VDU1', resources_list) + + self.assertIn('CP1', resources_list) + self.assertIn('G1', resources_list) def _scale(type, count): body = {"scale": {'type': type, 'policy': 'SP1'}} @@ -93,4 +102,4 @@ class VnfTestToscaScale(base.BaseTackerTest): # Delete vnfd_instance self.addCleanup(self.client.delete_vnfd, vnfd_id) self.addCleanup(self.wait_until_vnf_delete, vnf_id, - constants.VNF_CIRROS_DELETE_TIMEOUT) + constants.VNF_CIRROS_DELETE_TIMEOUT) diff --git a/tacker/vnfm/infra_drivers/openstack/openstack.py b/tacker/vnfm/infra_drivers/openstack/openstack.py index d13e6e60a..e479fb522 100644 --- a/tacker/vnfm/infra_drivers/openstack/openstack.py +++ b/tacker/vnfm/infra_drivers/openstack/openstack.py @@ -391,14 +391,17 @@ class OpenStack(abstract_driver.DeviceAbstractDriver, @log.log def get_resource_info(self, plugin, context, vnf_info, auth_attr, region_name=None): - stack_id = vnf_info['instance_id'] + instance_id = vnf_info['instance_id'] heatclient = hc.HeatClient(auth_attr, region_name) try: - resources_ids = heatclient.resource_get_list(stack_id) + # nested_depth=2 is used to get VDU resources + # in case of nested template + resources_ids =\ + heatclient.resource_get_list(instance_id, nested_depth=2) details_dict = {resource.resource_name: - {"id": resource.physical_resource_id, - "type": resource.resource_type} - for resource in resources_ids} + {"id": resource.physical_resource_id, + "type": resource.resource_type} + for resource in resources_ids} return details_dict # Raise exception when Heat API service is not available except Exception: