Commit 5765c6be authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼

resilience: fix after switching to switch-softwaretype recipe

This was broken in 8725ab1a.

 * recipe/pbs: slave-instance-list is already a list of JSON
 * slave-instance-list is not a configuration but directly a parameter
from slapos
parent 030f718c
......@@ -57,7 +57,7 @@ class Recipe(GenericSlapRecipe, Notify, Callback):
def _options(self, options):
options['rdiff-backup-data-folder'] = ""
if 'slave-instance-list' in options:
for slave in json.loads(options['slave-instance-list']):
for slave in options['slave-instance-list']:
if slave['type'] == 'pull':
options['rdiff-backup-data-folder'] = str(os.path.join(options['directory'], slave['name'], 'rdiff-backup-data'))
......@@ -299,8 +299,7 @@ class Recipe(GenericSlapRecipe, Notify, Callback):
if self.optionIsTrue('client', True):
self.logger.info("Client mode")
slaves = json.loads(self.options['slave-instance-list'])
slaves = self.options['slave-instance-list']
known_hosts = KnownHostsFile(self.options['known-hosts'])
with known_hosts:
for slave in slaves:
......
......@@ -82,7 +82,7 @@ class PBSTest(unittest.TestCase):
'run-directory': run_directory,
'cron-entries': cron_directory,
'known-hosts': 'TEST_KNOWN_HOSTS',
'slave-instance-list': '''[
'slave-instance-list': [
{
"url": "http://url.to.pull/",
"type": "pull",
......@@ -101,7 +101,6 @@ class PBSTest(unittest.TestCase):
"frequency": "TEST_FREQUENCY"
}
]
'''
})
recipe._install()
......
......@@ -14,7 +14,7 @@
# not need these here).
[template]
filename = instance.cfg
md5sum = ec70348dd71b319590a5c5837f3d2e45
md5sum = 8d6878ff1d2e75010c50a1a2b0c13b24
[template-runner]
filename = instance-runner.cfg
......
......@@ -74,6 +74,7 @@ template = ${instance-runner-import:target}
rendered = $${buildout:directory}/instance-runner-import.cfg
mode = 640
context =
key pbsready_import_template_path template-pbsready-import:rendered
key template_runner_path instance-base-runner:rendered
key slapparameter_dict slap-configuration:configuration
raw software_release_bin ${buildout:bin-directory}
......@@ -82,7 +83,6 @@ context =
raw bash_executable_location ${bash:location}/bin/bash
raw sqlite3_executable_location ${sqlite3:location}/bin/sqlite3
raw rsync_executable_location ${rsync:location}/bin/rsync
raw pbsready_import_template_path ${pbsready-import:output}
raw software_release_information_template ${template-resilient-software-release-information:destination}/${template-resilient-software-release-information:filename}
[slap-configuration]
......
......@@ -14,11 +14,11 @@
# not need these here).
[pbsready]
filename = pbsready.cfg.in
md5sum = 5b2fe1b35f6c8eaed0a0e6a10dc12cfe
md5sum = 2bd6f853ace04ea84dffe29acfce92df
[pbsready-import]
filename = pbsready-import.cfg.in
md5sum = fdf64dc6d3ecf457c91e32dca91362b0
md5sum = 1717549c74efed7ab449013dbf8db9e6
[pbsready-export]
filename = pbsready-export.cfg.in
......@@ -26,7 +26,7 @@ md5sum = 2b0c71b085cfe8017f28098c160b1f49
[template-pull-backup]
filename = instance-pull-backup.cfg.in
md5sum = ca195935e53e033eed72b6b1f5be6bc9
md5sum = 382d9b57faac92da3c723760f2210c13
[template-replicated]
filename = template-replicated.cfg.in
......@@ -38,7 +38,7 @@ md5sum = 071b1034ee8f5cc14f79b16fdeba2813
[template-resilient-templates]
filename = template-resilient-templates.cfg.in
md5sum = 097a14371efde11465ab4bd08ef3131b
md5sum = 3b426db6fddce431b363d095a22dd698
[instance-frozen]
filename = instance-frozen.cfg.in
......
......@@ -124,7 +124,7 @@ run-directory = $${basedirectory:run}
pull-push-maximum-run = 5
# XXX: this should be named "notifier-host"
notifier-url = http://[$${notifier:host}]:$${notifier:port}
slave-instance-list = {{ slapparameter_dict.get('slave_instance_list', '[]') }}
slave-instance-list = {{ dumps(slave_instance_list) }}
ignore-known-hosts-file = {{ slapparameter_dict.get('ignore-known-hosts-file', 'false') }}
# To get a verbose feed about PBS state
instance-root-name = $${monitor-instance-parameter:root-instance-title}
......
[buildout]
extends = ${pbsready:output}
extends = {{ pbsready_template_path }}
parts +=
resiliency-takeover-script
......@@ -14,9 +14,6 @@ parts +=
backup-signature-link
[slap-parameter]
on-notification =
[resilient-publish-connection-parameter]
notification-url = http://[$${notifier:host}]:$${notifier:port}/notify
takeover-url = http://[$${resilient-web-takeover-httpd-configuration-file:listening-ip}]:$${resilient-web-takeover-httpd-configuration-file:listening-port}/
......@@ -43,7 +40,7 @@ ip = $${notifier:host}
# is received
recipe = slapos.cookbook:notifier.callback
callbacks-directory = $${notifier:callbacks-directory}
on-notification-id = $${slap-parameter:on-notification}
on-notification-id = {{ slapparameter_dict.get('on-notification', '') }}
callbacks-list =
# warning the order of the 2 callbacks is important for now
# it should be fixed later
......
......@@ -63,9 +63,6 @@ cgi-bin = $${rootdirectory:srv}/cgi-bin
monitor-resilient = $${monitor-directory:private}/resilient
[slap-parameter]
authorized-key =
#----------------
#--
#-- Deploy cron.
......@@ -198,7 +195,7 @@ wrapper-path = $${rootdirectory:bin}/raw_sshd
[sshd-pbs-authorized-key]
<= sshd-raw-server
recipe = slapos.cookbook:dropbear.add_authorized_key
key = $${slap-parameter:authorized-key}
key = {{ slapparameter_dict.get('authorized-key', '') }}
[sshd-server]
recipe = collective.recipe.template
......
[template-pbsready]
recipe = slapos.recipe.template:jinja2
template = ${pbsready:output}
rendered = $${buildout:directory}/pbsready.cfg
extensions = jinja2.ext.do
context =
key slapparameter_dict slap-configuration:configuration
[template-pbsready-export]
recipe = slapos.recipe.template:jinja2
template = ${pbsready-export:target}
......@@ -5,10 +13,19 @@ rendered = $${buildout:directory}/pbsready-exporter.cfg
mode = 640
context =
key slapparameter_dict slap-configuration:configuration
raw pbsready_template_path ${pbsready:output}
raw pbsready_template_path $${template-pbsready:rendered}
raw bash_executable_location ${bash:location}/bin/bash
raw logrotate_executable_location ${logrotate:location}/usr/sbin/logrotate
[template-pbsready-import]
recipe = slapos.recipe.template:jinja2
template = ${pbsready-import:output}
rendered = $${buildout:directory}/pbsready-importer.cfg
extensions = jinja2.ext.do
context =
key slapparameter_dict slap-configuration:configuration
raw pbsready_template_path $${template-pbsready:rendered}
[instance-frozen]
recipe = slapos.recipe.template:jinja2
template = ${instance-frozen:output}
......@@ -23,5 +40,7 @@ template = ${template-pull-backup:output}
rendered = $${buildout:directory}/template-pull-backup.cfg
extensions = jinja2.ext.do
context =
key slave_instance_list slap-configuration:slave-instance-list
key slapparameter_dict slap-configuration:configuration
key ipv6 slap-configuration:ipv6-random
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