Merge "Fix: nested resources are ignored"

This commit is contained in:
Jenkins 2017-01-06 00:34:57 +00:00 committed by Gerrit Code Review
commit a907fe70fb
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'}}

View File

@ -391,10 +391,13 @@ 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}