Commit 6a1d0093 authored by Romain Courteaud's avatar Romain Courteaud

Instanciate ZEO

parent 6af1f3ac
...@@ -205,9 +205,9 @@ SSLCARevocationPath %(ca_crl)s""" ...@@ -205,9 +205,9 @@ SSLCARevocationPath %(ca_crl)s"""
"key_auth_node_amount", 0)) "key_auth_node_amount", 0))
ip = self.getLocalIPv4Address() ip = self.getLocalIPv4Address()
storage_dict = self._requestZeoFileStorage('Zeo Server 1', 'main') # storage_dict = self._requestZeoFileStorage('Zeo Server 1', 'main')
zeo_conf = self.installZeo(ip) # zeo_conf = self.installZeo(ip)
tidstorage_config = dict(host=ip, port='6001') tidstorage_config = dict(host=ip, port='6001')
# XXX How to define good values for this? # XXX How to define good values for this?
...@@ -712,43 +712,47 @@ SSLCARevocationPath %(ca_crl)s""" ...@@ -712,43 +712,47 @@ SSLCARevocationPath %(ca_crl)s"""
return [] return []
def installZeo(self, ip): def installZeo(self, ip):
zodb_dir = os.path.join(self.data_root_directory, 'zodb') # zodb_dir = os.path.join(self.data_root_directory, 'zodb')
self._createDirectory(zodb_dir) # self._createDirectory(zodb_dir)
zeo_configuration_dict = {} zeo_configuration_dict = {}
zeo_number = 0 zeo_number = 0
for zeo_server in sorted(self._zeo_storage_dict.iterkeys()): for zeo_server in sorted(self._zeo_storage_dict.iterkeys()):
zeo_number += 1 zeo_number += 1
zeo_event_log = os.path.join(self.log_directory, 'zeo-%s.log'% zeo_number) # zeo_event_log = os.path.join(self.log_directory, 'zeo-%s.log'% zeo_number)
zeo_pid = os.path.join(self.run_directory, 'zeo-%s.pid'% zeo_number) # zeo_pid = os.path.join(self.run_directory, 'zeo-%s.pid'% zeo_number)
self.registerLogRotation('zeo-%s' % zeo_number, [zeo_event_log],
self.killpidfromfile + ' ' + zeo_pid + ' SIGUSR2') # self.registerLogRotation('zeo-%s' % zeo_number, [zeo_event_log],
config = dict( # self.killpidfromfile + ' ' + zeo_pid + ' SIGUSR2')
zeo_ip=ip,
zeo_port=self._zeo_storage_port_dict[zeo_server], # config = dict(
zeo_event_log=zeo_event_log, # zeo_ip=ip,
zeo_pid=zeo_pid, # zeo_port=self._zeo_storage_port_dict[zeo_server],
) # zeo_event_log=zeo_event_log,
storage_definition_list = [] # zeo_pid=zeo_pid,
for storage_name in sorted(self._zeo_storage_dict[zeo_server]): # )
path = os.path.join(zodb_dir, '%s.fs' % storage_name) # storage_definition_list = []
storage_definition_list.append("""<filestorage %(storage_name)s> # for storage_name in sorted(self._zeo_storage_dict[zeo_server]):
path %(path)s # path = os.path.join(zodb_dir, '%s.fs' % storage_name)
</filestorage>"""% dict(storage_name=storage_name, path=path)) # storage_definition_list.append("""<filestorage %(storage_name)s>
zeo_configuration_dict[storage_name] = dict( # path %(path)s
ip=ip, # </filestorage>"""% dict(storage_name=storage_name, path=path))
port=config['zeo_port'], # zeo_configuration_dict[storage_name] = dict(
path=path # ip=ip,
) # port=config['zeo_port'],
config['zeo_filestorage_snippet'] = '\n'.join(storage_definition_list) # path=path
zeo_conf_path = self.createConfigurationFile('zeo-%s.conf' % zeo_number, # )
self.substituteTemplate(self.getTemplateFilename('zeo.conf.in'), config)) # config['zeo_filestorage_snippet'] = '\n'.join(storage_definition_list)
self.path_list.append(zeo_conf_path) # zeo_conf_path = self.createConfigurationFile('zeo-%s.conf' % zeo_number,
wrapper = zc.buildout.easy_install.scripts([('zeo_%s' % zeo_number, # self.substituteTemplate(self.getTemplateFilename('zeo.conf.in'), config))
'slapos.recipe.librecipe.execute', 'execute')], self.ws, sys.executable, # self.path_list.append(zeo_conf_path)
self.wrapper_directory, arguments=[
self.options['runzeo_binary'].strip(), '-C', zeo_conf_path]
)[0] # wrapper = zc.buildout.easy_install.scripts([('zeo_%s' % zeo_number,
self.path_list.append(wrapper) # 'slapos.recipe.librecipe.execute', 'execute')], self.ws, sys.executable,
# self.wrapper_directory, arguments=[
# self.options['runzeo_binary'].strip(), '-C', zeo_conf_path]
# )[0]
# self.path_list.append(wrapper)
return zeo_configuration_dict return zeo_configuration_dict
def installRepozo(self, zodb_root_path): def installRepozo(self, zodb_root_path):
......
##############################################################################
#
# Copyright (c) 2011 Vifib SARL and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from slapos.recipe.librecipe import GenericBaseRecipe
class Recipe(GenericBaseRecipe):
"""
ZEO instance configuration.
wrapper-path -- location of the init script to generate
binary-path -- location of the runzeo command
ip -- ip of the zeo server
port -- port of the zeo server
log-path -- location of the log file
pid-path -- location of the pid file
conf-path -- location of the configuration file
zodb-path -- location of the zodb directory (which contains all storage)
storage -- string with list of all resquested storage
Example: event_module person_module
"""
def install(self):
snippet_filename = self.getTemplateFilename(
'zeo-filestorage-snippet.conf.in')
zodb_directory_path = self.options['zodb-path']
# Prepare all filestorages
filestorage_snippet = ""
for storage_name in self.options['storage'].split():
storage_path = os.path.join(zodb_directory_path, '%s.fs' % storage_name)
filestorage_snippet += self.substituteTemplate(
snippet_filename, dict(storage_name=storage_name, path=storage_path))
config = dict(
zeo_ip=self.options['ip'],
zeo_port=self.options['port'],
zeo_event_log=self.options['log-path'],
zeo_pid=self.options['pid-path'],
zeo_filestorage_snippet=filestorage_snippet,
)
# Create configuration file
template_filename = self.getTemplateFilename('zeo.conf.in')
configuration_path = self.createFile(
self.options['conf-path'],
self.substituteTemplate(template_filename, config))
# Create running wrapper
wrapper_path = self.createPythonScript(
self.options['wrapper-path'],
'slapos.recipe.librecipe.execute.execute',
arguments=[self.options['binary-path'].strip(), '-C', zeo_conf_path],
return [configuration_path, wrapper_path]
<filestorage %(storage_name)s>
path %(path)s
</filestorage>
[buildout]
parts =
zeo-instance
logrotate
logrotate-entry-zeo
cron
cron-entry-logrotate
publish-zeo-connection-information
gzip-binary = ${gzip:location}/bin/gzip
eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true
[rootdirectory]
recipe = slapos.cookbook:mkdirectory
etc = $${buildout:directory}/etc/
var = $${buildout:directory}/var/
srv = $${buildout:directory}/srv/
bin = $${buildout:directory}/bin/
[basedirectory]
recipe = slapos.cookbook:mkdirectory
log = $${rootdirectory:var}/log/
services = $${rootdirectory:etc}/run/
run = $${rootdirectory:var}/run/
backup = $${rootdirectory:srv}/backup/
zodb = $${rootdirectory:srv}/zodb/
[directory]
recipe = slapos.cookbook:mkdirectory
cron-entries = $${rootdirectory:etc}/cron.d/
crontabs = $${rootdirectory:etc}/crontabs/
cronstamps = $${rootdirectory:etc}/cronstamps/
cronoutput = $${basedirectory:log}/cron/
logrotate-backup = $${basedirectory:backup}/logrotate/
logrotate-entries = $${rootdirectory:etc}/logrotate.d/
[zeo-instance]
recipe = slapos.cookbook:zeo
log-path = $${rootdirectory:log}/zeo-$${slap-parameter:zeo-id}.log
pid-path = $${rootdirectory:run}/zeo-$${slap-parameter:zeo-id}.pid
conf-path = $${rootdirectory:etc}/zeo-$${slap-parameter:zeo-id}.conf
zodb-path = $${basedirectory:zodb}
ip = $${slap-network-information:local-ipv4}
port = $${slap-parameter:zeo-port}
storage = $${slap-parameter:storage_list}
wrapper-path = $${basedirectory:services}/zeo-$${slap-parameter:zeo-id}
binary-path = ${buildout:bin-directory}/runzeo
[publish-memcached-connection-information]
recipe = slapos.cookbook:publishurl
url = zeo://$${zeo-instance:ip}:$${zeo-instance:port}/
[cron]
recipe = slapos.cookbook:cron
dcrond-binary = ${dcron:location}/sbin/crond
cron-entries = $${directory:cron-entries}
crontabs = $${directory:crontabs}
cronstamps = $${directory:cronstamps}
catcher = $${cron-simplelogger:binary}
binary = $${basedirectory:services}/crond
[cron-simplelogger]
recipe = slapos.cookbook:simplelogger
binary = $${rootdirectory:bin}/cron_simplelogger
output = $${directory:cronoutput}
[cron-entry-logrotate]
<= cron
recipe = slapos.cookbook:cron.d
name = logrotate
frequency = 0 0 * * *
command = $${logrotate:wrapper}
[logrotate-entry-zeo]
<= logrotate
recipe = slapos.cookbook:logrotate.d
name = zeo-$${slap-parameter:zeo-id}
log = $${zeo-instance:log-path}
frequency = daily
rotate-num = 3650
sharedscripts = true
notifempty = true
create = true
post = $${killpidfromfile:binary} $${zeo-instance:pid-path} SIGUSR2
[killpidfromfile]
binary = $${notimplemented:getkillpidfromfilefromsoftware}
# rest of parts are candidates for some generic stuff
[logrotate]
recipe = slapos.cookbook:logrotate
# Binaries
logrotate-binary = ${logrotate:location}/usr/sbin/logrotate
gzip-binary = $${buildout:gzip-binary}
gunzip-binary = ${gzip:location}/bin/gunzip
# Directories
wrapper = $${rootdirectory:bin}/logrotate
conf = $${rootdirectory:etc}/logrotate.conf
logrotate-entries = $${directory:logrotate-entries}
backup = $${directory:logrotate-backup}
state-file = $${rootdirectory:srv}/logrotate.status
...@@ -23,7 +23,6 @@ rdiff_backup_binary = ${buildout:bin-directory}/rdiff-backup ...@@ -23,7 +23,6 @@ rdiff_backup_binary = ${buildout:bin-directory}/rdiff-backup
repozo_binary = ${buildout:bin-directory}/repozo repozo_binary = ${buildout:bin-directory}/repozo
runTestSuite_binary = ${buildout:bin-directory}/runTestSuite runTestSuite_binary = ${buildout:bin-directory}/runTestSuite
runUnitTest_binary = ${buildout:bin-directory}/runUnitTest runUnitTest_binary = ${buildout:bin-directory}/runUnitTest
runzeo_binary = ${buildout:bin-directory}/runzeo
runzope_binary = ${buildout:bin-directory}/runzope runzope_binary = ${buildout:bin-directory}/runzope
sphinx_searchd_binary = ${sphinx:location}/bin/searchd sphinx_searchd_binary = ${sphinx:location}/bin/searchd
tidstorage_repozo_binary = ${buildout:bin-directory}/tidstorage_repozo tidstorage_repozo_binary = ${buildout:bin-directory}/tidstorage_repozo
...@@ -87,3 +86,4 @@ kumofs = ${template-kumofs:output} ...@@ -87,3 +86,4 @@ kumofs = ${template-kumofs:output}
memcached = ${template-memcached:output} memcached = ${template-memcached:output}
cloudooo = ${template-cloudooo:output} cloudooo = ${template-cloudooo:output}
zope = ${template-zope:output} zope = ${template-zope:output}
zeo = ${template-zeo:output}
...@@ -63,6 +63,13 @@ md5sum = 7a7eda874008dcf64944d5c5075ae7eb ...@@ -63,6 +63,13 @@ md5sum = 7a7eda874008dcf64944d5c5075ae7eb
output = ${buildout:directory}/template-memcached.cfg output = ${buildout:directory}/template-memcached.cfg
mode = 0644 mode = 0644
[template-zeo]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-zeo.cfg
md5sum = 53a66a2b707cfda0efc0a4be4219641a
output = ${buildout:directory}/template-zeo.cfg
mode = 0644
[validator] [validator]
# Default json schema for instance parameters. # Default json schema for instance parameters.
recipe = slapos.recipe.template recipe = slapos.recipe.template
......
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