From c242dbe1244dcd8c7e315578ede978b3c14a890b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=81ukasz=20Nowak?= <luke@nexedi.com>
Date: Thu, 10 Mar 2011 13:45:38 +0000
Subject: [PATCH]  - differentiate configuration of zope nodes with or without
 timer    service

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@44122 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../erp5/src/slapos/recipe/erp5/__init__.py   | 19 +++++++++++++------
 .../slapos/recipe/erp5/template/zope.conf.in  |  6 ------
 .../recipe/erp5/template/zope.conf.simple.in  |  6 ------
 .../erp5/template/zope.conf.timerservice.in   |  6 ++++++
 4 files changed, 19 insertions(+), 18 deletions(-)
 create mode 100644 slapos/recipe/erp5/src/slapos/recipe/erp5/template/zope.conf.timerservice.in

diff --git a/slapos/recipe/erp5/src/slapos/recipe/erp5/__init__.py b/slapos/recipe/erp5/src/slapos/recipe/erp5/__init__.py
index 3db6075571..578efe377a 100644
--- a/slapos/recipe/erp5/src/slapos/recipe/erp5/__init__.py
+++ b/slapos/recipe/erp5/src/slapos/recipe/erp5/__init__.py
@@ -115,12 +115,14 @@ class Recipe(BaseSlapRecipe):
           zeo_storagename=self.connection_dict['zeo_storagename'],
           ip=self.getLocalIPv4Address())
       port = 12001
-      distribution_list = [self.installZope(port=port, name='zope_distribution', **common_kw)] 
+      distribution_list = [self.installZope(port=port, name='zope_distribution',
+        with_timerservice=True, **common_kw)] 
       self.connection_dict.update(zope_distribution_node=' '.join(distribution_list))
       activity_list = []
       for i in xrange(1, int(self.parameter_dict.get('activity_node_amount', 0)) + 1):
         port += 1
-        activity_list.append(self.installZope(port=port, name='zope_activity_%s' % i, **common_kw))
+        activity_list.append(self.installZope(port=port, name='zope_activity_%s' % i,
+          with_timerservice=True, **common_kw))
       self.connection_dict.update(zope_activity_node=' '.join(activity_list))
       login_list = []
       for i in xrange(1, int(self.parameter_dict.get('login_node_amount', 0)) + 1):
@@ -441,7 +443,7 @@ class Recipe(BaseSlapRecipe):
     self.path_list.append(wrapper)
 
   def installZope(self, ip, port, name, zeo_address=None, zeo_storagename=None,
-      zodb_root_path=None):
+      zodb_root_path=None, with_timerservice=False):
     # Create zope configuration file
     zope_config = dict(
         products=self.options['products'],
@@ -476,12 +478,17 @@ class Recipe(BaseSlapRecipe):
     if zeo_address is None:
       zope_wrapper_template_location = self.getTemplateFilename(
           'zope.conf.simple.in')
+      with_timerservice = True
     else:
       zope_wrapper_template_location = self.getTemplateFilename('zope.conf.in')
 
-    zope_conf_path = self.createConfigurationFile("%s.conf" %
-        name, self.substituteTemplate(
-          zope_wrapper_template_location, zope_config))
+    zope_conf_content = self.substituteTemplate(
+        zope_wrapper_template_location, zope_config)
+    if with_timerservice:
+      zope_conf_content += self.substituteTemplate(
+          self.getTemplateFilename('zope.conf.timerservice.in'), zope_config)
+    zope_conf_path = self.createConfigurationFile("%s.conf" % name,
+        zope_conf_content)
     self.path_list.append(zope_conf_path)
     # Create init script
     wrapper = zc.buildout.easy_install.scripts([(name,
diff --git a/slapos/recipe/erp5/src/slapos/recipe/erp5/template/zope.conf.in b/slapos/recipe/erp5/src/slapos/recipe/erp5/template/zope.conf.in
index 365a025838..89370b7b4e 100644
--- a/slapos/recipe/erp5/src/slapos/recipe/erp5/template/zope.conf.in
+++ b/slapos/recipe/erp5/src/slapos/recipe/erp5/template/zope.conf.in
@@ -54,9 +54,3 @@ lock-filename %(lock-filename)s
 <zoperunner>
     program $INSTANCE/bin/runzope
 </zoperunner>
-
-# ERP5 Timer Service
-%%import timerserver
-<timer-server>
-  interval 5
-</timer-server>
diff --git a/slapos/recipe/erp5/src/slapos/recipe/erp5/template/zope.conf.simple.in b/slapos/recipe/erp5/src/slapos/recipe/erp5/template/zope.conf.simple.in
index ca2c0f281b..170a2f36eb 100644
--- a/slapos/recipe/erp5/src/slapos/recipe/erp5/template/zope.conf.simple.in
+++ b/slapos/recipe/erp5/src/slapos/recipe/erp5/template/zope.conf.simple.in
@@ -55,9 +55,3 @@ lock-filename %(lock-filename)s
 <zoperunner>
     program $INSTANCE/bin/runzope
 </zoperunner>
-
-# ERP5 Timer Service
-%%import timerserver
-<timer-server>
-  interval 5
-</timer-server>
diff --git a/slapos/recipe/erp5/src/slapos/recipe/erp5/template/zope.conf.timerservice.in b/slapos/recipe/erp5/src/slapos/recipe/erp5/template/zope.conf.timerservice.in
new file mode 100644
index 0000000000..707c6bab66
--- /dev/null
+++ b/slapos/recipe/erp5/src/slapos/recipe/erp5/template/zope.conf.timerservice.in
@@ -0,0 +1,6 @@
+
+# ERP5 Timer Service
+%%import timerserver
+<timer-server>
+  interval 5
+</timer-server>
-- 
2.30.9