From 6c7ca2c74a1847a9c807e738b638af0c67a6bca3 Mon Sep 17 00:00:00 2001
From: Alain Takoudjou <talino@tiolive.com>
Date: Thu, 6 Sep 2012 13:18:52 +0200
Subject: [PATCH] Allow Boinc Software to deploy many boinc-app at same time

---
 software/boinc/boinc-app.cfg             | 39 ++++++++++++++
 software/boinc/input/input_file          |  1 +
 software/boinc/instance.cfg              | 12 +++++
 software/boinc/software.cfg              | 69 +++++++++++++++++++++---
 software/boinc/templates/template_result | 13 +++++
 software/boinc/templates/template_wu     | 10 ++++
 6 files changed, 136 insertions(+), 8 deletions(-)
 create mode 100644 software/boinc/boinc-app.cfg
 create mode 100644 software/boinc/input/input_file
 create mode 100644 software/boinc/instance.cfg
 create mode 100644 software/boinc/templates/template_result
 create mode 100644 software/boinc/templates/template_wu

diff --git a/software/boinc/boinc-app.cfg b/software/boinc/boinc-app.cfg
new file mode 100644
index 000000000..77dd73886
--- /dev/null
+++ b/software/boinc/boinc-app.cfg
@@ -0,0 +1,39 @@
+[buildout]
+
+parts  = 
+  boinc-server
+  certificate-authority
+  ca-stunnel
+  logrotate
+  logrotate-entry-apache
+  logrotate-entry-stunnel
+  cron
+  cron-entry-logrotate
+  cron-entry-boinc
+  promise
+  slapmonitor
+  slapreport
+  frontend-promise
+  publish-connection-informations
+  boinc-app
+
+extends = ${template-boinc:output}
+
+#Deploy a Boinc application in existing boinc server instance. do the same thing for another boinc app instance
+[boinc-app]
+<= boinc-server
+recipe = slapos.cookbook:boinc.app
+binary = ${boinc-application:location}/${boinc-application:filename}
+#app-name should be unique (for all app deployed an boinc instance)
+app-name = ${boinc-application:app-name}
+version = ${boinc-application:version}
+platform = ${boinc-application:platform}
+extension = ${boinc-application:exec-extension}
+dash = ${dash:location}/bin/dash
+#templates
+template-result = ${template_result:location}/${template_result:filename}
+template-wu = ${template_wu:location}/${template_wu:filename}
+#Work Unit
+wu-name = ${boinc-application:wu-name}
+wu-number = ${boinc-application:wu-number}
+input-file = ${template_input:location}/${template_input:filename}
diff --git a/software/boinc/input/input_file b/software/boinc/input/input_file
new file mode 100644
index 000000000..f500b146d
--- /dev/null
+++ b/software/boinc/input/input_file
@@ -0,0 +1 @@
+test string
\ No newline at end of file
diff --git a/software/boinc/instance.cfg b/software/boinc/instance.cfg
new file mode 100644
index 000000000..083c65b0d
--- /dev/null
+++ b/software/boinc/instance.cfg
@@ -0,0 +1,12 @@
+[buildout]
+parts =
+  switch_softwaretype
+
+eggs-directory = ${buildout:eggs-directory}
+develop-eggs-directory = ${buildout:develop-eggs-directory}
+offline = true
+
+[switch_softwaretype]
+recipe = slapos.cookbook:softwaretype
+default = ${boinc-instance:output}
+mariadb = ${template-mariadb:output}
\ No newline at end of file
diff --git a/software/boinc/software.cfg b/software/boinc/software.cfg
index 9df90427f..ccce39aab 100644
--- a/software/boinc/software.cfg
+++ b/software/boinc/software.cfg
@@ -1,7 +1,14 @@
 [buildout]
 
-part = 
-  boinc-configuration
+parts = 
+  boinc-instance
+  template
+  boinc-application
+  template_wu
+  template_result
+  template_input
+  slapos-cookbook
+  instance-egg
 
 extends =
   ../../stack/boinc/buildout.cfg
@@ -9,9 +16,55 @@ extends =
 develop =
   /srv/slapgrid/slappart19/srv//runner/project/slapos.github
 
-#default Configuration for boinc project
-[boinc-configuration]
-recipe = plone.recipe.command
-command = echo "this part is not ready..."
-dbname = boinctest
-project = boinc_test
\ No newline at end of file
+#Generate All instances templates
+[boinc-instance]
+recipe = slapos.recipe.template
+url = ${:_profile_base_location_}/boinc-app.cfg
+output = ${buildout:directory}/template-app.cfg
+mode = 0644
+md5sum = ecec6192ac5b361e326cb2f1bd5f97dc
+
+[template]
+recipe = slapos.recipe.template
+url = ${:_profile_base_location_}/instance.cfg
+output = ${buildout:directory}/template.cfg
+mode = 0644
+md5sum = d097ddeeee5d89881d097efe6165caf6
+
+#Download Boinc Application Binary and configure project
+[boinc-application]
+recipe = hexagonit.recipe.download
+url = ${boinc:location}/libexec/examples/upper_case
+download-only = true
+filename = upper_case
+#Application configuration
+app-name = upper_case
+version = 1.0
+exec-extension = 
+#Please read Boinc platform before update platform value: http://boinc.berkeley.edu/trac/wiki/BoincPlatforms
+platform = x86_64-pc-linux-gnu
+#Work Unit: wu-name without blanc space: wu-number number of work unit
+wu-name = simpletest
+wu-number = 1
+
+[template_result]
+recipe = hexagonit.recipe.download
+url = ${:_profile_base_location_}/templates/template_result
+download-only = true
+filename = template_result
+#md5sum = 
+
+[template_wu]
+recipe = hexagonit.recipe.download
+url = ${:_profile_base_location_}/templates/template_wu
+download-only = true
+filename = template_wu
+#md5sum = 
+
+[template_input]
+recipe = hexagonit.recipe.download
+url = ${:_profile_base_location_}/input/input_file
+download-only = true
+filename = input_file
+#md5sum = 
+
diff --git a/software/boinc/templates/template_result b/software/boinc/templates/template_result
new file mode 100644
index 000000000..653ae9446
--- /dev/null
+++ b/software/boinc/templates/template_result
@@ -0,0 +1,13 @@
+<file_info>
+    <name><OUTFILE_0/></name>
+    <generated_locally/>
+    <upload_when_present/>
+    <max_nbytes>5000000</max_nbytes>
+    <url><UPLOAD_URL/></url>
+</file_info>
+<result>
+    <file_ref>
+        <file_name><OUTFILE_0/></file_name>
+        <open_name>out</open_name>
+    </file_ref>
+</result>
\ No newline at end of file
diff --git a/software/boinc/templates/template_wu b/software/boinc/templates/template_wu
new file mode 100644
index 000000000..603d03139
--- /dev/null
+++ b/software/boinc/templates/template_wu
@@ -0,0 +1,10 @@
+<file_info>
+    <number>0</number>
+</file_info>
+<workunit>
+    <file_ref>
+        <file_number>0</file_number>
+        <open_name>in</open_name>
+    </file_ref>
+    <command_line>-cpu_time 10</command_line>
+</workunit>
\ No newline at end of file
-- 
2.30.9