Commit 1cdca39e authored by Vincent Pelletier's avatar Vincent Pelletier

request: Prepare support for plain python list options.

parent d8c528d0
...@@ -33,6 +33,12 @@ import traceback ...@@ -33,6 +33,12 @@ import traceback
DEFAULT_SOFTWARE_TYPE = 'RootSoftwareInstance' DEFAULT_SOFTWARE_TYPE = 'RootSoftwareInstance'
def getListOption(option_dict, key, default=()):
result = option_dict.get(key, default)
if isinstance(result, basestring):
result = result.split()
return result
class Recipe(object): class Recipe(object):
""" """
Request a partition to a slap master. Request a partition to a slap master.
...@@ -91,18 +97,18 @@ class Recipe(object): ...@@ -91,18 +97,18 @@ class Recipe(object):
self.logger = logging.getLogger(name) self.logger = logging.getLogger(name)
software_url = options['software-url'] software_url = options['software-url']
name = options['name'] name = options['name']
return_parameters = options.get('return', '').split() return_parameters = getListOption(options, 'return')
if not return_parameters: if not return_parameters:
self.logger.debug("No parameter to return to main instance." self.logger.debug("No parameter to return to main instance."
"Be careful about that...") "Be careful about that...")
software_type = options.get('software-type', DEFAULT_SOFTWARE_TYPE) software_type = options.get('software-type', DEFAULT_SOFTWARE_TYPE)
filter_kw = dict( filter_kw = dict(
(x, options['sla-' + x]) for x in options.get('sla', '').split() (x, options['sla-' + x]) for x in getListOption(options, 'sla')
if options['sla-' + x] if options['sla-' + x]
) )
partition_parameter_kw = self._filterForStorage(dict( partition_parameter_kw = self._filterForStorage(dict(
(x, options['config-' + x]) (x, options['config-' + x])
for x in options.get('config', '').split() for x in getListOption(options, 'config')
)) ))
slave = options.get('slave', 'false').lower() in \ slave = options.get('slave', 'false').lower() in \
librecipe.GenericBaseRecipe.TRUE_VALUES librecipe.GenericBaseRecipe.TRUE_VALUES
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment