From d766d30455685eefc9fdd2598453155d1b728611 Mon Sep 17 00:00:00 2001 From: Bharath Thiruveedula Date: Fri, 16 Oct 2015 22:31:10 +0530 Subject: [PATCH] Remove check for service_type in openwrt mgmt driver Currently check for 'service_type' in openwrt fails, because of the change of 'service_type' from VNF level to VDU level. This patch will remove the check for 'service_type' in OpenWRT mgmt driver. Closes-Bug: #1506111 Change-Id: I1de206779841ca63e1f95cc9f5bd58496566acfe --- tacker/vm/drivers/heat/heat.py | 25 +++++++---------------- tacker/vm/mgmt_drivers/openwrt/openwrt.py | 4 +--- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/tacker/vm/drivers/heat/heat.py b/tacker/vm/drivers/heat/heat.py index c88130d12..cbde7f1eb 100644 --- a/tacker/vm/drivers/heat/heat.py +++ b/tacker/vm/drivers/heat/heat.py @@ -215,7 +215,6 @@ class DeviceHeat(abstract_driver.DeviceAbstractDriver): # overwrite parameters with given dev_attrs for device creation dev_attrs = device['attributes'].copy() - config_yaml = dev_attrs.pop('config', None) fields.update(dict((key, dev_attrs.pop(key)) for key in ('stack_name', 'template_url', 'template') if key in dev_attrs)) @@ -305,22 +304,6 @@ class DeviceHeat(abstract_driver.DeviceAbstractDriver): device['attributes']['monitoring_policy'] = jsonutils.dumps( monitoring_dict) - if config_yaml is not None: - config_dict = yaml.load(config_yaml) - resources = template_dict.setdefault('resources', {}) - for vdu_id, vdu_dict in config_dict.get('vdus', {}).items(): - if vdu_id not in resources: - continue - config = vdu_dict.get('config', None) - if not config: - continue - properties = resources[vdu_id].setdefault('properties', {}) - properties['config_drive'] = True - metadata = properties.setdefault('metadata', {}) - metadata.update(config) - for key, value in metadata.items(): - metadata[key] = value[:255] - heat_template_yaml = yaml.dump(template_dict) fields['template'] = heat_template_yaml if not device['attributes'].get('heat_template'): @@ -392,7 +375,13 @@ class DeviceHeat(abstract_driver.DeviceAbstractDriver): update_yaml = device['device'].get('attributes', {}).get('config', '') LOG.debug('yaml orig %(orig)s update %(update)s', {'orig': config_yaml, 'update': update_yaml}) - config_dict = yaml.load(config_yaml) or {} + + # If config_yaml is None, yaml.load() will raise Attribute Error. + # So set config_yaml to {}, if it is None. + if not config_yaml: + config_dict = {} + else: + config_dict = yaml.load(config_yaml) or {} update_dict = yaml.load(update_yaml) if not update_dict: return diff --git a/tacker/vm/mgmt_drivers/openwrt/openwrt.py b/tacker/vm/mgmt_drivers/openwrt/openwrt.py index 16d98ed7e..9daf003b5 100644 --- a/tacker/vm/mgmt_drivers/openwrt/openwrt.py +++ b/tacker/vm/mgmt_drivers/openwrt/openwrt.py @@ -68,9 +68,7 @@ class DeviceMgmtOpenWRT(abstract_driver.DeviceMGMTAbstractDriver): mgmt_constants.ACTION_UPDATE_DEVICE): return dev_attrs = device.get('attributes', {}) - service_type = dev_attrs.get('service_type') - if not service_type: - return + mgmt_url = jsonutils.loads(device.get('mgmt_url', '{}')) if not mgmt_url: return