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 <Venkata.Kotha@infinite.com>
Closes-Bug: #1629028

Change-Id: I0a4258873f7898a009a155f2b048638cdbc581d9
This commit is contained in:
doantungbk 2016-12-31 01:36:03 -08:00
parent 1678b14346
commit 2edb3bd51f
2 changed files with 18 additions and 6 deletions

View File

@ -61,6 +61,15 @@ class VnfTestToscaScale(base.BaseTackerTest):
self.assertEqual(count, len(json.loads(vnf['mgmt_url'])['VDU1'])) self.assertEqual(count, len(json.loads(vnf['mgmt_url'])['VDU1']))
_wait(2) _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): def _scale(type, count):
body = {"scale": {'type': type, 'policy': 'SP1'}} body = {"scale": {'type': type, 'policy': 'SP1'}}
@ -93,4 +102,4 @@ class VnfTestToscaScale(base.BaseTackerTest):
# Delete vnfd_instance # Delete vnfd_instance
self.addCleanup(self.client.delete_vnfd, vnfd_id) self.addCleanup(self.client.delete_vnfd, vnfd_id)
self.addCleanup(self.wait_until_vnf_delete, vnf_id, self.addCleanup(self.wait_until_vnf_delete, vnf_id,
constants.VNF_CIRROS_DELETE_TIMEOUT) constants.VNF_CIRROS_DELETE_TIMEOUT)

View File

@ -391,14 +391,17 @@ class OpenStack(abstract_driver.DeviceAbstractDriver,
@log.log @log.log
def get_resource_info(self, plugin, context, vnf_info, auth_attr, def get_resource_info(self, plugin, context, vnf_info, auth_attr,
region_name=None): region_name=None):
stack_id = vnf_info['instance_id'] instance_id = vnf_info['instance_id']
heatclient = hc.HeatClient(auth_attr, region_name) heatclient = hc.HeatClient(auth_attr, region_name)
try: 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: details_dict = {resource.resource_name:
{"id": resource.physical_resource_id, {"id": resource.physical_resource_id,
"type": resource.resource_type} "type": resource.resource_type}
for resource in resources_ids} for resource in resources_ids}
return details_dict return details_dict
# Raise exception when Heat API service is not available # Raise exception when Heat API service is not available
except Exception: except Exception: