Only use scalar parameters as references in class name
so that we avoid side effect of list elements being merged twice in the
same list.
This commit adds a new "scalar_parameters" reclass config option
(defaults to False) used to indicate where to find scalar parameters in
node parameters dict.
diff --git a/reclass/core.py b/reclass/core.py
index 67b0f92..f35450f 100644
--- a/reclass/core.py
+++ b/reclass/core.py
@@ -172,6 +172,15 @@
else:
return Parameters({}, self._settings, '')
+ def _get_scalar_parameters(self, node_parameters):
+ if self._settings.scalar_parameters:
+ scalars = node_parameters.as_dict().get(
+ self._settings.scalar_parameters, {})
+ return Parameters(
+ {self._settings.scalar_parameters: scalars}, self._settings, '__scalar__')
+ else:
+ return Parameters({}, self._settings, '')
+
def _get_inventory(self, all_envs, environment, queries):
'''
Returns a dictionary of NodeInventory objects, one per matching node. Exports
@@ -229,7 +238,7 @@
base_entity.merge(self._get_class_mappings_entity(node_entity))
base_entity.merge(self._get_input_data_entity())
base_entity.merge_parameters(self._get_automatic_parameters(nodename, node_entity.environment))
- base_entity.merge_parameters(Parameters(node_entity.parameters, self._settings, ''))
+ base_entity.merge_parameters(self._get_scalar_parameters(node_entity.parameters))
seen = {}
merge_base = self._recurse_entity(base_entity, seen=seen, nodename=nodename,
environment=node_entity.environment)
diff --git a/reclass/defaults.py b/reclass/defaults.py
index f50a8ad..7ea797e 100644
--- a/reclass/defaults.py
+++ b/reclass/defaults.py
@@ -56,6 +56,7 @@
ESCAPE_CHARACTER = '\\'
AUTOMATIC_RECLASS_PARAMETERS = True
+SCALAR_RECLASS_PARAMETERS = False
DEFAULT_ENVIRONMENT = 'base'
CLASS_MAPPINGS_MATCH_PATH = False
diff --git a/reclass/settings.py b/reclass/settings.py
index e9e8a36..08fdea5 100644
--- a/reclass/settings.py
+++ b/reclass/settings.py
@@ -20,6 +20,7 @@
'allow_none_override': defaults.OPT_ALLOW_NONE_OVERRIDE,
'automatic_parameters': defaults.AUTOMATIC_RECLASS_PARAMETERS,
'class_mappings_match_path': defaults.CLASS_MAPPINGS_MATCH_PATH,
+ 'scalar_parameters': defaults.SCALAR_RECLASS_PARAMETERS,
'default_environment': defaults.DEFAULT_ENVIRONMENT,
'delimiter': defaults.PARAMETER_INTERPOLATION_DELIMITER,
'dict_key_override_prefix':