diff --git a/slapos/recipe/slapconfiguration.py b/slapos/recipe/slapconfiguration.py index bdb9bf1667e6e8413cafd7ee4af14c82659100b7..ba8c6a5f5e4604d1182b7d8aeb9fdd579e823b0e 100644 --- a/slapos/recipe/slapconfiguration.py +++ b/slapos/recipe/slapconfiguration.py @@ -25,14 +25,8 @@ # ############################################################################## import slapos.slap -import json from ConfigParser import RawConfigParser -cast_dict = { - 'json': (True, json.dumps), - 'str': (False, str), -} - class Recipe(object): """ Retrieves slap partition parameters, and makes them available to other @@ -59,33 +53,22 @@ class Recipe(object): Partition identifier. Example: ${slap-connection:partition-id} - unsafe (optional, 0 by default) - Enables formats which are unsafe when represented back into a buildout - text file. Set to 0 to explicitly disable unsafe formats, any other - integer value to enable them. Output: - slap-software-type.<format> - Current partition's software type, serialised in each available format. - <format> - All partition parameters serialised in that format as values. - Example: - json = {"foo": "bar"} - <format>.key - One key per partition parameter, prefixed with serialisation format - followed by a dot. Example: - json.foo = "bar" - - Supported serialisation formats: - json (safe) - JavaScript Object Notation - str (unsafe) - Python string representation. + slap-software-type + Current partition's software type. + configuration + Dict of all parameters. + configuration.<key> + One key per partition parameter. + Partition parameter whose name cannot be represented unambiguously in + buildout syntax are ignored. They cannot be accessed from buildout syntax + anyway, and are available through "configuration" output key. """ # XXX: used to detect if a configuration key is a valid section key. This # assumes buildout uses ConfigParser - which is currently the case. - OPTCRE = RawConfigParser.OPTCRE + OPTCRE_match = RawConfigParser.OPTCRE.match def __init__(self, buildout, name, options): slap = slapos.slap.slap() @@ -100,21 +83,14 @@ class Recipe(object): ).getInstanceParameterDict() # XXX: those are not partition parameters, strictly speaking. # Discard them, and make them available as separate section keys. - slap_software_type = parameter_dict.pop('slap_software_type') + options['slap-software-type'] = parameter_dict.pop( + 'slap_software_type') del parameter_dict['ip_list'] - allow_unsafe = bool(int(options.get('unsafe', '0'))) - match = self.OPTCRE.match - for name, (safe, cast) in cast_dict.iteritems(): - if not safe and not allow_unsafe: + options['configuration'] = parameter_dict + match = self.OPTCRE_match + for key, value in parameter_dict.iteritems(): + if match(key) is not None: continue - options['slap-software-type.' + name] = cast(slap_software_type) - options[name] = cast(parameter_dict) - for key, value in parameter_dict.iteritems(): - if match(key) is not None: - # It should be OK to skip silently and unconditionally: such - # parameter cannot be accessed in a well-formed buildout - # config. - continue - options[name + '.' + key] = cast(value) + options['configuration.' + key] = value install = update = lambda self: [] diff --git a/software/erp5/instance.cfg.in b/software/erp5/instance.cfg.in index beac389c1d07f1fb807662e32912e8d27ce86a78..24f2b8fad9fbb1c857b1f9f28f8486931d5554c5 100644 --- a/software/erp5/instance.cfg.in +++ b/software/erp5/instance.cfg.in @@ -21,8 +21,8 @@ extra-context = context = key eggs_directory buildout:eggs-directory key develop_eggs_directory buildout:develop-eggs-directory - jsonkey slap_software_type slap-parameters:slap-software-type.json - jsonkey slapparameter_dict slap-parameters:json + key slap_software_type slap-parameters:slap-software-type + key slapparameter_dict slap-parameters:configuration ${:extra-context} [dynamic-template-tidstorage-parameters] diff --git a/software/erp5/software.cfg b/software/erp5/software.cfg index 0ac947bff8bb1186becc33c31f8c3c354208180d..cf2f252ecec6d9b0f1491cf6152fb9418128342a 100644 --- a/software/erp5/software.cfg +++ b/software/erp5/software.cfg @@ -149,7 +149,7 @@ configurator_bt5_list = erp5_core_proxy_field_legacy erp5_full_text_myisam_catal # XXX: "template.cfg" is hardcoded in instanciation recipe filename = template.cfg template = ${:_profile_base_location_}/instance.cfg.in -md5sum = 0f3dcf0e156025d6b8f5f3efdd161282 +md5sum = 19a9d18674848128bb358eceff728a1d extra-context = key apache_location apache:location key aspell_location aspell:location