diff options
author | Steve Baker <sbaker@redhat.com> | 2014-08-20 10:04:03 +1200 |
---|---|---|
committer | Steve Baker <sbaker@redhat.com> | 2014-09-01 09:55:20 +1200 |
commit | 0a9f80bdeec0e9875d7651a876913085ea742b9e (patch) | |
tree | defd499f91c1b40166cb22a5c85cb2946b396d18 /heat/engine/resources/resource_group.py | |
parent | 0d90181c502bb4adf3f7bb114dffebed78615f71 (diff) | |
download | heat-0a9f80bdeec0e9875d7651a876913085ea742b9e.tar.gz |
ResourceGroup make do_prop_replace class method
This refactor allows subclasses to override _do_prop_replace so
that properties can be populated by the specific needs of the subclass.
Change-Id: I1ebe382b8efd010e128fa9c452d5ddb580237c1e
Partial-Blueprint: deployment-multiple-servers
Diffstat (limited to 'heat/engine/resources/resource_group.py')
-rw-r--r-- | heat/engine/resources/resource_group.py | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/heat/engine/resources/resource_group.py b/heat/engine/resources/resource_group.py index abbd88840..3c53d506a 100644 --- a/heat/engine/resources/resource_group.py +++ b/heat/engine/resources/resource_group.py @@ -203,29 +203,29 @@ class ResourceGroup(stack_resource.StackResource): res_def[self.RESOURCE_DEF_PROPERTIES] = clean return res_def + def _handle_repl_val(self, res_name, val): + repl_var = self.properties[self.INDEX_VAR] + recurse = lambda x: self._handle_repl_val(res_name, x) + if isinstance(val, basestring): + return val.replace(repl_var, res_name) + elif isinstance(val, collections.Mapping): + return dict(zip(val, map(recurse, val.values()))) + elif isinstance(val, collections.Sequence): + return map(recurse, val) + return val + + def _do_prop_replace(self, res_name, res_def_template): + res_def = copy.deepcopy(res_def_template) + props = res_def[self.RESOURCE_DEF_PROPERTIES] + if props: + props = self._handle_repl_val(res_name, props) + res_def[self.RESOURCE_DEF_PROPERTIES] = props + return res_def + def _assemble_nested(self, names, include_all=False): res_def = self._build_resource_definition(include_all) - def handle_repl_val(repl_var, res_name, val): - recurse = lambda x: handle_repl_val(repl_var, res_name, x) - if isinstance(val, basestring): - return val.replace(repl_var, res_name) - elif isinstance(val, collections.Mapping): - return dict(zip(val, map(recurse, val.values()))) - elif isinstance(val, collections.Sequence): - return map(recurse, val) - return val - - def do_prop_replace(repl_var, res_name, res_def): - props = res_def[self.RESOURCE_DEF_PROPERTIES] - if props: - props = handle_repl_val(repl_var, res_name, props) - res_def[self.RESOURCE_DEF_PROPERTIES] = props - return res_def - - repl_var = self.properties[self.INDEX_VAR] - resources = dict((k, do_prop_replace(repl_var, k, - copy.deepcopy(res_def))) + resources = dict((k, self._do_prop_replace(k, res_def)) for k in names) child_template = copy.deepcopy(template_template) child_template['resources'] = resources |