From 2037aa0250cf75e4f2269f708b81caf70764acf2 Mon Sep 17 00:00:00 2001 From: Isaku Yamahata Date: Fri, 1 May 2015 05:06:53 -0700 Subject: [PATCH] vnfd: placement policy with availability zone Change-Id: Ibd555d6acaa1855e7a5fb2b2ae5dc87f648087dd --- tacker/vm/drivers/heat/heat.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tacker/vm/drivers/heat/heat.py b/tacker/vm/drivers/heat/heat.py index 6bbb78d0d..d046d03db 100644 --- a/tacker/vm/drivers/heat/heat.py +++ b/tacker/vm/drivers/heat/heat.py @@ -97,6 +97,7 @@ class DeviceHeat(abstract_driver.DeviceAbstractDriver): if key in kwargs: kwargs[key] = jsonutils.loads(kwargs.pop(key)) fields['parameters'].update(kwargs) + LOG.debug('vnfd_yaml %s', vnfd_yaml) if vnfd_yaml is not None: assert 'template' not in fields assert 'template_url' not in fields @@ -110,18 +111,24 @@ class DeviceHeat(abstract_driver.DeviceAbstractDriver): if vnfd_key in vnfd_dict: template_dict[key] = vnfd_dict[vnfd_key] - for vdu_id, vdu_dict in template_dict.get('vdus', []): - template_dict['resources'][vdu_id] = { + for vdu_id, vdu_dict in vnfd_dict.get('vdus', {}).items(): + template_dict.setdefault('resources', {})[vdu_id] = { "type": "OS::Nova::Server" } resource_dict = template_dict['resources'][vdu_id] - KEY_LIST = (('image_id', 'vm_image'), - ('instance_type', 'instance_type')) + KEY_LIST = (('image', 'vm_image'), + ('flavor', 'instance_type')) + resource_dict['properties'] = {} + properties = resource_dict['properties'] for (key, vdu_key) in KEY_LIST: - resource_dict[key] = vdu_dict[vdu_key] + properties[key] = vdu_dict[vdu_key] if 'network_interfaces' in vdu_dict: - resource_dict['networks'] = ( + properties['networks'] = ( vdu_dict['network_interfaces'].values()) + if ('placement_policy' in vdu_dict and + 'availability_zone' in vdu_dict['placement_policy']): + properties['availability_zone'] = vdu_dict[ + 'placement_policy']['availability_zone'] # monitoring_policy = vdu_dict.get('monitoring_policy', None) # failure_policy = vdu_dict.get('failure_policy', None)