Add temporary request-edge recipe

parent 4fb649d2
......@@ -159,6 +159,7 @@ setup(name=name,
'pwgen.stable = slapos.recipe.pwgen:StablePasswordGeneratorRecipe',
'request = slapos.recipe.request:Recipe',
'request.serialised = slapos.recipe.request:Serialised',
'request.edge = slapos.recipe.request:RequestEdge',
'requestoptional = slapos.recipe.request:RequestOptional',
'reverseproxy.nginx = slapos.recipe.reverse_proxy_nginx:Recipe',
'seleniumrunner = slapos.recipe.seleniumrunner:Recipe',
......
......@@ -215,7 +215,6 @@ class RequestOptional(Recipe):
update = install
class Serialised(Recipe):
def _filterForStorage(self, partition_parameter_kw):
return wrap(partition_parameter_kw)
......@@ -225,3 +224,36 @@ class Serialised(Recipe):
return json.loads(instance.getConnectionParameter(JSON_SERIALISED_MAGIC_KEY))
except slapmodule.NotFoundError:
return {}
CONNECTION_PARAMETER_STRING = 'connection-'
class RequestEdge(Recipe):
"""
For each country in country-list, do a request.
"""
def __init__(self, buildout, name, options):
self.logger = logging.getLogger(name)
self.options = options
self.request_dict = {}
# Keep a copy of original options dict
original_options = options.copy()
for country in options['country-list'].split(','):
# Request will have its own copy of options dict
local_options = original_options.copy()
local_options['name'] = '%s-%s' % (country, name)
self.request_dict[country] = Recipe(buildout, name, local_options)
# "Bubble" all connection parameters
for option, value in local_options.iteritems():
if option.startswith(CONNECTION_PARAMETER_STRING):
self.options['%s-%s' % (option, country)] = value
def install(self):
for country, request in self.request_dict.iteritems():
request.install()
return []
update = install
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