Commit 4bb47083 authored by Alain Takoudjou's avatar Alain Takoudjou

factorize the code of boinc recipe

parent 28bed57e
...@@ -103,7 +103,7 @@ class Recipe(GenericBaseRecipe): ...@@ -103,7 +103,7 @@ class Recipe(GenericBaseRecipe):
#Define environment variable here #Define environment variable here
python = os.path.join(self.home, 'bin/python') python = os.path.join(self.home, 'bin/python')
python_path = self.boinc_egg + ":" + os.environ['PYTHONPATH'] python_path = self.boinc_egg
if not os.path.exists(python): if not os.path.exists(python):
os.symlink(self.pythonbin, python) os.symlink(self.pythonbin, python)
for f in os.listdir(self.developegg): for f in os.listdir(self.developegg):
...@@ -112,8 +112,8 @@ class Recipe(GenericBaseRecipe): ...@@ -112,8 +112,8 @@ class Recipe(GenericBaseRecipe):
python_path += ":" + dir python_path += ":" + dir
bin_dir = os.path.join(self.home, 'bin') bin_dir = os.path.join(self.home, 'bin')
environment = dict( environment = dict(
PATH=self.svn + ':' + bin_dir + ':' + self.perl + ':' + os.environ['PATH'], PATH=os.pathsep.join([self.svn, bin_dir, self.perl, os.environ['PATH']]),
PYTHONPATH=python_path, PYTHONPATH=os.pathsep.join([python_path, os.environ['PYTHONPATH']]),
) )
#Generate wrapper for php #Generate wrapper for php
...@@ -134,7 +134,7 @@ class Recipe(GenericBaseRecipe): ...@@ -134,7 +134,7 @@ class Recipe(GenericBaseRecipe):
dict(mysql_port=self.mysqlport, mysql_host=self.mysqlhost, dict(mysql_port=self.mysqlport, mysql_host=self.mysqlhost,
mysql_user=self.username, mysql_password=self.password, mysql_user=self.username, mysql_password=self.password,
database=self.database, database=self.database,
file_status=file_status, python_path=python_path file_status=file_status, environment=environment
) )
) )
...@@ -160,6 +160,18 @@ class Recipe(GenericBaseRecipe): ...@@ -160,6 +160,18 @@ class Recipe(GenericBaseRecipe):
) )
path_list.append(install_wrapper) path_list.append(install_wrapper)
#generate sh script for project configuration
bash = os.path.join(self.home, 'bin', 'project_config.sh')
sh_script = self.createFile(bash,
self.substituteTemplate(self.getTemplateFilename('project_config.in'),
dict(dash=self.options['dash'].strip(),
uldl_pid=self.options['apache-pid'].strip(),
user=slapuser, fullname=self.fullname,
copyright=self.copyright, installroot=self.installroot))
)
path_list.append(sh_script)
os.chmod(bash , 0700)
#After make_project run configure_script to perform and restart apache php services #After make_project run configure_script to perform and restart apache php services
service_status = os.path.join(self.home, '.start_service') service_status = os.path.join(self.home, '.start_service')
parameter = dict( parameter = dict(
...@@ -171,10 +183,8 @@ class Recipe(GenericBaseRecipe): ...@@ -171,10 +183,8 @@ class Recipe(GenericBaseRecipe):
xadd=os.path.join(self.installroot, 'bin/xadd'), xadd=os.path.join(self.installroot, 'bin/xadd'),
environment=environment, environment=environment,
service_status=service_status, service_status=service_status,
project=niceprojectname, drop_install=drop_install,
fullname=self.fullname, sedconfig=bash
copyright=self.copyright,
drop_install=drop_install
) )
start_service = self.createPythonScript( start_service = self.createPythonScript(
os.path.join(self.wrapperdir, 'config_project'), os.path.join(self.wrapperdir, 'config_project'),
...@@ -191,8 +201,8 @@ class Recipe(GenericBaseRecipe): ...@@ -191,8 +201,8 @@ class Recipe(GenericBaseRecipe):
installroot=self.installroot, drop_install=drop_install, installroot=self.installroot, drop_install=drop_install,
mysql_port=self.mysqlport, mysql_host=self.mysqlhost, mysql_port=self.mysqlport, mysql_host=self.mysqlhost,
mysql_user=self.username, mysql_password=self.password, mysql_user=self.username, mysql_password=self.password,
database=self.database, PATH=environment['PATH'], database=self.database, environment=environment,
python_path=python_path, start_boinc=start_boinc) start_boinc=start_boinc)
start_wrapper = self.createPythonScript(os.path.join(self.wrapperdir, start_wrapper = self.createPythonScript(os.path.join(self.wrapperdir,
'start_boinc'), 'start_boinc'),
'%s.configure.restart_boinc' % __name__, '%s.configure.restart_boinc' % __name__,
...@@ -211,14 +221,14 @@ class App(GenericBaseRecipe): ...@@ -211,14 +221,14 @@ class App(GenericBaseRecipe):
def downloadFiles(self): def downloadFiles(self):
"""This is used to download app files if necessary and update options values""" """This is used to download app files if necessary and update options values"""
for key in ('template-result', 'template-wu', 'input-file', 'binary'): for key in ('input-file', 'template-result', 'template-wu', 'binary'):
option = self.options[key].strip() param = self.options[key].strip()
if option and (option.startswith('http') or option.startswith('ftp')): if param and (param.startswith('http') or param.startswith('ftp')):
#download the specified file #download the specified file
cache = os.path.join(self.options['home'].strip(), 'temp') cache = os.path.join(self.options['home'].strip(), 'tmp')
downloader = zc.buildout.download.Download(self.buildout['buildout'], downloader = zc.buildout.download.Download(self.buildout['buildout'],
hash_name=True, cache=cache) hash_name=True, cache=cache)
path, _ = downloader(option, md5sum=None) path, _ = downloader(param, md5sum=None)
mode = 0600 mode = 0600
if key == 'binary': if key == 'binary':
mode = 0700 mode = 0700
...@@ -243,8 +253,9 @@ class App(GenericBaseRecipe): ...@@ -243,8 +253,9 @@ class App(GenericBaseRecipe):
print "Invalid argement values...operation cancelled" print "Invalid argement values...operation cancelled"
return False return False
#write application to install #write application to install
toInstall = open(os.path.join(self.options['home'].strip(), request_file = os.path.join(self.options['home'].strip(),
'.install_' + self.appname + self.version), 'w') '.install_' + self.appname + self.version)
toInstall = open(request_file, 'w')
toInstall.write('install or update') toInstall.write('install or update')
toInstall.close() toInstall.close()
return True return True
...@@ -258,9 +269,8 @@ class App(GenericBaseRecipe): ...@@ -258,9 +269,8 @@ class App(GenericBaseRecipe):
path_list = [] path_list = []
package = self.options['boinc'].strip() package = self.options['boinc'].strip()
#Define environment variable here #Define environment variable here
boinc_egg = os.path.join(package, 'lib/python2.7/site-packages')
developegg = self.options['develop-egg'].strip() developegg = self.options['develop-egg'].strip()
python_path = boinc_egg + ":" + os.environ['PYTHONPATH'] python_path = os.path.join(package, 'lib/python2.7/site-packages')
home = self.options['home'].strip() home = self.options['home'].strip()
user = pwd.getpwuid(os.stat(home).st_uid)[0] user = pwd.getpwuid(os.stat(home).st_uid)[0]
perl = self.options['perl-binary'].strip() perl = self.options['perl-binary'].strip()
...@@ -271,17 +281,15 @@ class App(GenericBaseRecipe): ...@@ -271,17 +281,15 @@ class App(GenericBaseRecipe):
python_path += ":" + dir python_path += ":" + dir
bin_dir = os.path.join(home, 'bin') bin_dir = os.path.join(home, 'bin')
environment = dict( environment = dict(
PATH=svn + ':' + bin_dir + ':' + perl + ':' + os.environ['PATH'], PATH=os.pathsep.join([svn, bin_dir, perl, os.environ['PATH']]),
PYTHONPATH=python_path, PYTHONPATH=os.pathsep.join([python_path, os.environ['PYTHONPATH']]),
) )
#generate project.xml and config.xml script updater #generate project.xml and config.xml script updater
bash = os.path.join(home, 'bin', 'update_config.sh') bash = os.path.join(home, 'bin', 'update_config.sh')
sh_script = self.createFile(bash, sh_script = self.createFile(bash,
self.substituteTemplate(self.getTemplateFilename('sed_update.in'), self.substituteTemplate(self.getTemplateFilename('sed_update.in'),
dict(dash=self.options['dash'].strip(), dict(dash=self.options['dash'].strip()))
uldl_pid=self.options['apache-pid'].strip(),
user=user))
) )
path_list.append(sh_script) path_list.append(sh_script)
os.chmod(bash , 0700) os.chmod(bash , 0700)
...@@ -311,7 +319,7 @@ class App(GenericBaseRecipe): ...@@ -311,7 +319,7 @@ class App(GenericBaseRecipe):
bash=bash, home_dir=home, bash=bash, home_dir=home,
) )
deploy_app = self.createPythonScript( deploy_app = self.createPythonScript(
os.path.join(wrapperdir, self.appname), os.path.join(wrapperdir, 'boinc_app'),
'%s.configure.deployApp' % __name__, parameter '%s.configure.deployApp' % __name__, parameter
) )
path_list.append(deploy_app) path_list.append(deploy_app)
......
This diff is collapsed.
#!%(dash)s
sed -i "/remove the die/d" %(installroot)s/html/ops/create_forums.php
sed -i "s#REPLACE WITH PROJECT NAME#%(fullname)s#" %(installroot)s/html/project/project.inc
sed -i "s#REPLACE WITH COPYRIGHT HOLDER#%(copyright)s#" %(installroot)s/html/project/project.inc
sed -i.old -e "/<\/config>/i\<uldl_pid>%(uldl_pid)s</uldl_pid>" %(installroot)s/config.xml
sed -i.old -e "/<\/config>/i\<httpd_user>%(user)s</httpd_user>" %(installroot)s/config.xml
...@@ -10,7 +10,5 @@ sed -i.old -e "/<\/boinc>/i\<app>\n<name>$1</name>\n<user_friendly_name>$1</user ...@@ -10,7 +10,5 @@ sed -i.old -e "/<\/boinc>/i\<app>\n<name>$1</name>\n<user_friendly_name>$1</user
sed -i.old -e "/<\/daemons>/i\<daemon>\n<cmd>\nsample_bitwise_validator -d 3 -app $1\n</cmd>\n</daemon>" $2/config.xml sed -i.old -e "/<\/daemons>/i\<daemon>\n<cmd>\nsample_bitwise_validator -d 3 -app $1\n</cmd>\n</daemon>" $2/config.xml
sed -i.old -e "/<\/daemons>/i\<daemon>\n<cmd>\nsample_assimilator -d 3 -app $1\n</cmd>\n</daemon>" $2/config.xml sed -i.old -e "/<\/daemons>/i\<daemon>\n<cmd>\nsample_assimilator -d 3 -app $1\n</cmd>\n</daemon>" $2/config.xml
sed -i.old -e "/<\/config>/i\<uldl_pid>%(uldl_pid)s</uldl_pid>" $2/config.xml
sed -i.old -e "/<\/config>/i\<httpd_user>%(user)s</httpd_user>" $2/config.xml
fi fi
\ No newline at end of file
...@@ -43,7 +43,7 @@ exec-extension = ...@@ -43,7 +43,7 @@ exec-extension =
#Please read Boinc platform before update platform value: http://boinc.berkeley.edu/trac/wiki/BoincPlatforms #Please read Boinc platform before update platform value: http://boinc.berkeley.edu/trac/wiki/BoincPlatforms
platform = x86_64-pc-linux-gnu platform = x86_64-pc-linux-gnu
#Work Unit number number of work unit #Work Unit number number of work unit
wu-number = 4 wu-number = 2
[template-base] [template-base]
recipe = slapos.recipe.download recipe = slapos.recipe.download
......
...@@ -41,7 +41,7 @@ eggs = ...@@ -41,7 +41,7 @@ eggs =
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-boinc.cfg url = ${:_profile_base_location_}/instance-boinc.cfg
output = ${buildout:directory}/template-boinc.cfg output = ${buildout:directory}/template-boinc.cfg
md5sum = 003bff525faa1e63913fa5f38c18becd md5sum = 22de71bad135ab3c760c63e537dcb182
mode = 0644 mode = 0644
#Template for deploying MySQL Database Server #Template for deploying MySQL Database Server
...@@ -57,7 +57,7 @@ recipe = slapos.recipe.download ...@@ -57,7 +57,7 @@ recipe = slapos.recipe.download
url = ${:_profile_base_location_}/template/${:filename} url = ${:_profile_base_location_}/template/${:filename}
mode = 0644 mode = 0644
filename = apache.in filename = apache.in
md5sum = 0b3825a4a0ec82e279609d1f9dc72da4 md5sum = 030892494ce87357e6e09dcd89187bf4
location = ${buildout:parts-directory}/${:_buildout_section_name_} location = ${buildout:parts-directory}/${:_buildout_section_name_}
# Local development # Local development
......
...@@ -20,7 +20,9 @@ parts = ...@@ -20,7 +20,9 @@ parts =
eggs-directory = ${buildout:eggs-directory} eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory} develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true #temporary solution
newest = false
offline = false
# Creation of all needed directories # Creation of all needed directories
...@@ -226,7 +228,7 @@ wu-number = $${slap-parameter:wu-number} ...@@ -226,7 +228,7 @@ wu-number = $${slap-parameter:wu-number}
binary = $${slap-parameter:binary} binary = $${slap-parameter:binary}
platform = $${slap-parameter:platform} platform = $${slap-parameter:platform}
extension = $${slap-parameter:extension} extension = $${slap-parameter:extension}
template-result = $${slap-parameter:template-wu} template-result = $${slap-parameter:template-result}
template-wu = $${slap-parameter:template-wu} template-wu = $${slap-parameter:template-wu}
input-file = $${slap-parameter:input-file} input-file = $${slap-parameter:input-file}
......
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