Commit 730f737e authored by Alain Takoudjou's avatar Alain Takoudjou

Allow to update wu and deploy a fully boinc-app using slapparameter

parent dd314877
...@@ -185,11 +185,15 @@ class Recipe(GenericBaseRecipe): ...@@ -185,11 +185,15 @@ class Recipe(GenericBaseRecipe):
#Generate Boinc start project wrapper #Generate Boinc start project wrapper
start_args = [os.path.join(self.installroot, 'bin/start')] start_args = [os.path.join(self.installroot, 'bin/start')]
start_boinc = os.path.join(self.home, '.start_boinc')
if os.path.exists(start_boinc):
os.unlink(start_boinc)
boinc_parameter = dict(service_status=service_status, boinc_parameter = dict(service_status=service_status,
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, PATH=environment['PATH'],
python_path=python_path, 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__,
...@@ -208,7 +212,10 @@ class App(GenericBaseRecipe): ...@@ -208,7 +212,10 @@ class App(GenericBaseRecipe):
def install(self): def install(self):
if self.options['app-name'].strip() == '' or \
self.options['version'].strip() == '':
#don't deploy empty application...skipped
return []
path_list = [] path_list = []
package = self.options['boinc'].strip() package = self.options['boinc'].strip()
#Define environment variable here #Define environment variable here
...@@ -232,12 +239,13 @@ class App(GenericBaseRecipe): ...@@ -232,12 +239,13 @@ class App(GenericBaseRecipe):
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()))
) )
path_list.append(sh_script) path_list.append(sh_script)
os.chmod(bash , 0700) os.chmod(bash , 0700)
service_status = os.path.join(home, '.start_service') start_boinc = os.path.join(home, '.start_boinc')
installroot = self.options['installroot'].strip() installroot = self.options['installroot'].strip()
version = self.options['version'].strip() version = self.options['version'].strip()
platform = self.options['platform'].strip() platform = self.options['platform'].strip()
...@@ -253,9 +261,8 @@ class App(GenericBaseRecipe): ...@@ -253,9 +261,8 @@ class App(GenericBaseRecipe):
appname=appname, binary_name=bin_name, appname=appname, binary_name=bin_name,
version=version, platform=platform, version=version, platform=platform,
application=application, environment=environment, application=application, environment=environment,
service_status=service_status, start_boinc=start_boinc,
wu_name=self.options['wu-name'].strip(), wu_number=int(self.options['wu-number'].strip()),
wu_number=self.options['wu-number'].strip(),
t_result=self.options['template-result'].strip(), t_result=self.options['template-result'].strip(),
t_wu=self.options['template-wu'].strip(), t_wu=self.options['template-wu'].strip(),
t_input=self.options['input-file'].strip(), t_input=self.options['input-file'].strip(),
...@@ -270,6 +277,7 @@ class App(GenericBaseRecipe): ...@@ -270,6 +277,7 @@ class App(GenericBaseRecipe):
return path_list return path_list
update = install
class Client(GenericBaseRecipe): class Client(GenericBaseRecipe):
"""Deploy a fully fonctionnal boinc client connected to a boinc server instance""" """Deploy a fully fonctionnal boinc client connected to a boinc server instance"""
......
...@@ -131,32 +131,41 @@ def restart_boinc(args): ...@@ -131,32 +131,41 @@ def restart_boinc(args):
os.environ['PATH'] = args['PATH'] os.environ['PATH'] = args['PATH']
binstart = os.path.join(args['installroot'], 'bin/start') binstart = os.path.join(args['installroot'], 'bin/start')
binstop = os.path.join(args['installroot'], 'bin/stop') binstop = os.path.join(args['installroot'], 'bin/stop')
# startProcess([binstart], env)
# startProcess([binstop], env)
os.system(binstop) os.system(binstop)
os.system(binstart) os.system(binstart)
status = open(args['start_boinc'], "w")
status.write("started")
status.close()
print "Done." print "Done."
def deployApp(args): def deployApp(args):
"""Fully deploy or redeploy or update a BOINC application using existing BOINC instance"""
print "Cheking if needed to install %s..." % args['appname'] print "Cheking if needed to install %s..." % args['appname']
if os.path.exists(os.path.join(args['installroot'], "." + args['appname'])): token = os.path.join(args['installroot'], "." + args['appname'] + args['version'])
print args['appname'] + " is already installed in this Boinc instance... skipped" dropapp = False
if os.path.exists(token):
args['previous_wu'] = int(open(token, 'r').read().strip())
if args['previous_wu'] >= args['wu_number']:
print args['appname'] + " version " + args['version'] + " is already installed in this Boinc instance... skipped"
return return
#Sleep until file .start_service exist (Mark the end of boinc configuration) else:
print args['appname'] + " Work units will be updated from %s to %s" % (
args['previous_wu'], args['wu_number'])
else:
args['previous_wu'] = 0
dropapp = True
#Sleep until file .start_boinc exist (File indicate that BOINC has been started)
while True: while True:
print "Search for file %s..." % args['service_status'] print "Search for file %s..." % args['start_boinc']
if not os.path.exists(args['service_status']): if not os.path.exists(args['start_boinc']):
print "File not found... sleep for 3 secondes" print "File not found... sleep for 3 secondes"
time.sleep(3) time.sleep(3)
else: else:
break break
print "sleeps for 30 seconds while waiting for the end of the execution of boinc_start"
time.sleep(30)
print "setup directories..." print "setup directories..."
args['inputfile'] = os.path.join(args['installroot'], 'download', args['inputfile'] = os.path.join(args['installroot'], 'download',
args['appname']+'_input') args['appname'] + '_input')
base_app = os.path.join(args['installroot'], 'apps', args['appname']) base_app = os.path.join(args['installroot'], 'apps', args['appname'])
base_app_version = os.path.join(base_app, args['version']) base_app_version = os.path.join(base_app, args['version'])
args['templates'] = os.path.join(args['installroot'], 'templates') args['templates'] = os.path.join(args['installroot'], 'templates')
...@@ -164,6 +173,7 @@ def deployApp(args): ...@@ -164,6 +173,7 @@ def deployApp(args):
t_wu = os.path.join(args['templates'], args['appname']+'_wu') t_wu = os.path.join(args['templates'], args['appname']+'_wu')
if not os.path.exists(base_app): if not os.path.exists(base_app):
os.mkdir(base_app) os.mkdir(base_app)
if dropapp:
if os.path.exists(base_app_version): if os.path.exists(base_app_version):
shutil.rmtree(base_app_version) shutil.rmtree(base_app_version)
os.mkdir(base_app_version) os.mkdir(base_app_version)
...@@ -189,13 +199,6 @@ def deployApp(args): ...@@ -189,13 +199,6 @@ def deployApp(args):
sed_args = [args['bash'], args['appname'], args['installroot']] sed_args = [args['bash'], args['appname'], args['installroot']]
startProcess(sed_args) startProcess(sed_args)
print "Running xadd script..."
env = os.environ
env['PATH'] = args['environment']['PATH']
env['PYTHONPATH'] = args['environment']['PYTHONPATH']
if not startProcess([os.path.join(args['installroot'], 'bin/xadd')], env):
return
print "Sign the application binary..." print "Sign the application binary..."
sign = os.path.join(args['installroot'], 'bin/sign_executable') sign = os.path.join(args['installroot'], 'bin/sign_executable')
privateKeyFile = os.path.join(args['installroot'], 'keys/code_sign_private') privateKeyFile = os.path.join(args['installroot'], 'keys/code_sign_private')
...@@ -208,6 +211,14 @@ def deployApp(args): ...@@ -208,6 +211,14 @@ def deployApp(args):
print "Failed to execute bin/sign_executable.\nThe error was: %s" % result print "Failed to execute bin/sign_executable.\nThe error was: %s" % result
return return
output.close() output.close()
#END if drop-app HERE
print "Running xadd script..."
env = os.environ
env['PATH'] = args['environment']['PATH']
env['PYTHONPATH'] = args['environment']['PYTHONPATH']
if not startProcess([os.path.join(args['installroot'], 'bin/xadd')], env):
return
print "Running script bin/update_versions..." print "Running script bin/update_versions..."
updt_version = os.path.join(args['installroot'], 'bin/update_versions') updt_version = os.path.join(args['installroot'], 'bin/update_versions')
...@@ -232,20 +243,21 @@ def deployApp(args): ...@@ -232,20 +243,21 @@ def deployApp(args):
os.system(binstart) os.system(binstart)
print "Boinc Application deployment is done... writing end signal file..." print "Boinc Application deployment is done... writing end signal file..."
sfile = open(os.path.join(args['installroot'], "."+args['appname']), 'w') sfile = open(token, 'w')
sfile.write("done") sfile.write(str(args['wu_number']))
sfile.close() sfile.close()
def create_wu(args, env): def create_wu(args, env):
count = int(args['wu_number']) t_result = "templates/" + args['appname'] + '_result'
t_wu = "templates/" + args['appname'] + '_wu'
wu_name = 'wu_' + args['appname'] + args['version']
launch_args = [os.path.join(args['installroot'], 'bin/create_work'), launch_args = [os.path.join(args['installroot'], 'bin/create_work'),
'--appname', args['appname'], '--wu_name', args['wu_name'], '--appname', args['appname'], '--wu_name', wu_name,
'--wu_template', "templates/"+args['appname'] + '_wu', '--wu_template', t_wu, '--result_template', t_result,
'--result_template', "templates/"+args['appname'] + '_result',
args['appname']+'_input'] args['appname']+'_input']
for i in range(count): for i in range(args['previous_wu'], args['wu_number']):
print "Creating project wroker %s..." % str(i+1) print "Creating project wroker %s..." % str(i+1)
launch_args[4] = args['wu_name']+str(i+1) launch_args[4] = wu_name + str(i+1)
startProcess(launch_args, env, args['installroot']) startProcess(launch_args, env, args['installroot'])
def startProcess(launch_args, env=None, cwd=None): def startProcess(launch_args, env=None, cwd=None):
......
...@@ -16,7 +16,10 @@ parts = ...@@ -16,7 +16,10 @@ parts =
frontend-promise frontend-promise
content-promise content-promise
publish-connection-informations publish-connection-informations
#User application
boinc-app boinc-app
#slap application
slap-application
extends = ${template-boinc:output} extends = ${template-boinc:output}
...@@ -30,11 +33,10 @@ app-name = ${boinc-application:app-name} ...@@ -30,11 +33,10 @@ app-name = ${boinc-application:app-name}
version = ${boinc-application:version} version = ${boinc-application:version}
platform = ${boinc-application:platform} platform = ${boinc-application:platform}
extension = ${boinc-application:exec-extension} extension = ${boinc-application:exec-extension}
dash = ${dash:location}/bin/dash
#templates #templates
template-result = ${template_result:location}/${template_result:filename} template-result = ${template_result:location}/${template_result:filename}
template-wu = ${template_wu:location}/${template_wu:filename} template-wu = ${template_wu:location}/${template_wu:filename}
#Work Unit #Work Unit
wu-name = ${boinc-application:wu-name}
wu-number = ${boinc-application:wu-number} wu-number = ${boinc-application:wu-number}
input-file = ${template_input:location}/${template_input:filename} input-file = ${template_input:location}/${template_input:filename}
[buildout] [buildout]
develop =
/srv/slapgrid/slappart19/srv//runner/project/slapos.github
parts = parts =
boinc-instance boinc-instance
template template
...@@ -9,8 +12,8 @@ parts = ...@@ -9,8 +12,8 @@ parts =
template_input template_input
slapos-cookbook slapos-cookbook
instance-egg instance-egg
slapos.cookbook-repository # slapos.cookbook-repository
check-recipe # check-recipe
extends = extends =
../../stack/boinc/buildout.cfg ../../stack/boinc/buildout.cfg
...@@ -21,7 +24,7 @@ recipe = slapos.recipe.template ...@@ -21,7 +24,7 @@ recipe = slapos.recipe.template
url = ${:_profile_base_location_}/boinc-app.cfg url = ${:_profile_base_location_}/boinc-app.cfg
output = ${buildout:directory}/template-app.cfg output = ${buildout:directory}/template-app.cfg
mode = 0644 mode = 0644
md5sum = c30c21128e6522d0d6578466f5792517 md5sum = ab01f101cc6280ef07ea61a22a1432d0
[template] [template]
recipe = slapos.recipe.template recipe = slapos.recipe.template
...@@ -42,9 +45,8 @@ version = 1.0 ...@@ -42,9 +45,8 @@ version = 1.0
exec-extension = 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: wu-name without blanc space: wu-number number of work unit #Work Unit number number of work unit
wu-name = simpletest wu-number = 4
wu-number = 1
[template-base] [template-base]
recipe = slapos.recipe.download recipe = slapos.recipe.download
......
[buildout] [buildout]
# Local development # Local development
develop = #develop =
${:parts-directory}/slapos.cookbook-repository # ${:parts-directory}/slapos.cookbook-repository
parts = parts =
slapos-cookbook slapos-cookbook
...@@ -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 = 2ab17fad66dd07677367fcb7283d55e5 md5sum = 6746390ac3e19a8b1b933e0722084675
mode = 0644 mode = 0644
#Template for deploying MySQL Database Server #Template for deploying MySQL Database Server
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
parts = parts =
boinc-server boinc-server
slap-application
certificate-authority certificate-authority
ca-stunnel ca-stunnel
logrotate logrotate
...@@ -72,7 +73,7 @@ stunnel-binary = ${stunnel:location}/bin/stunnel ...@@ -72,7 +73,7 @@ stunnel-binary = ${stunnel:location}/bin/stunnel
remote-host = $${mariadb-urlparse:host} remote-host = $${mariadb-urlparse:host}
remote-port = $${mariadb-urlparse:port} remote-port = $${mariadb-urlparse:port}
local-host = $${slap-network-information:local-ipv4} local-host = $${slap-network-information:local-ipv4}
local-port = 3306 local-port = 33060
log-file = $${basedirectory:log}/stunnel.log log-file = $${basedirectory:log}/stunnel.log
config-file = $${directory:stunnel-conf}/stunnel.conf config-file = $${directory:stunnel-conf}/stunnel.conf
key-file = $${directory:stunnel-conf}/stunnel.key key-file = $${directory:stunnel-conf}/stunnel.key
...@@ -124,6 +125,7 @@ output = $${rootdirectory:etc}/apache.conf ...@@ -124,6 +125,7 @@ output = $${rootdirectory:etc}/apache.conf
document_root = $${rootdirectory:srv}/www/ document_root = $${rootdirectory:srv}/www/
pid_file = $${basedirectory:run}/apache.pid pid_file = $${basedirectory:run}/apache.pid
lock_file = $${basedirectory:run}/apache.lock lock_file = $${basedirectory:run}/apache.lock
cgid_sock = $${basedirectory:run}/cgid.sock
ip = $${slap-network-information:global-ipv6} ip = $${slap-network-information:global-ipv6}
port = 8080 port = 8080
error_log = $${directory:httpd-log}/error.log error_log = $${directory:httpd-log}/error.log
...@@ -194,11 +196,13 @@ develop-egg = ${buildout:develop-eggs-directory} ...@@ -194,11 +196,13 @@ develop-egg = ${buildout:develop-eggs-directory}
svn-binary = ${subversion:location}/bin svn-binary = ${subversion:location}/bin
perl-binary = ${perl:location}/bin perl-binary = ${perl:location}/bin
python-binary = ${buildout:executable} python-binary = ${buildout:executable}
dash = ${dash:location}/bin/dash
#Apache and php #Apache and php
ip = $${apache-php:ip} ip = $${apache-php:ip}
port = $${apache-php:port} port = $${apache-php:port}
htpasswd = ${apache:location}/bin/htpasswd htpasswd = ${apache:location}/bin/htpasswd
apache-pid = $${httpd-conf:pid_file}
php-ini = $${apache-php:php-ini-dir}/php.ini php-ini = $${apache-php:php-ini-dir}/php.ini
php-bin = ${apache-php:location}/bin/php php-bin = ${apache-php:location}/bin/php
php-wrapper = $${rootdirectory:bin}php php-wrapper = $${rootdirectory:bin}php
...@@ -210,6 +214,22 @@ mysql-database = $${mariadb-urlparse:path} ...@@ -210,6 +214,22 @@ mysql-database = $${mariadb-urlparse:path}
mysql-host = $${stunnel:local-host} mysql-host = $${stunnel:local-host}
mysql-port = $${stunnel:local-port} mysql-port = $${stunnel:local-port}
#This allow to deploy or to update Boinc application using only slapparameters from
#vifib BOINC instance parameters
[slap-application]
<= boinc-server
recipe = slapos.cookbook:boinc.app
#appname and version is require to update wu-number
app-name = $${slap-parameter:app-name}
version = $${slap-parameter:version}
wu-number = $${slap-parameter:wu-number}
binary = $${slap-parameter:binary}
platform = $${slap-parameter:platform}
extension = $${slap-parameter:extension}
template-result = $${slap-parameter:template-wu}
template-wu = $${slap-parameter:template-wu}
input-file = $${slap-parameter:input-file}
# Deploy logrotate, cron, configure it # Deploy logrotate, cron, configure it
[logrotate] [logrotate]
recipe = slapos.cookbook:logrotate recipe = slapos.cookbook:logrotate
...@@ -272,7 +292,7 @@ command = $${logrotate:wrapper} ...@@ -272,7 +292,7 @@ command = $${logrotate:wrapper}
recipe = slapos.cookbook:cron.d recipe = slapos.cookbook:cron.d
name = cronjob name = cronjob
frequency = 0,5,10,15,20,25,30,35,40,45,50,55 * * * * frequency = 0,5,10,15,20,25,30,35,40,45,50,55 * * * *
command = $${boinc-server:installroot}$${boinc-server:project}/bin/start --cron command = PATH=$${rootdirectory:bin}:$PATH $${boinc-server:installroot}/bin/start --cron
# Request frontend # Request frontend
...@@ -351,6 +371,16 @@ dbname = boinctest ...@@ -351,6 +371,16 @@ dbname = boinctest
project = boinc_test project = boinc_test
full-name = Boinc Project SAMPLE full-name = Boinc Project SAMPLE
copyright-holder = REPLACE WITH COPYRIGHT HOLDER copyright-holder = REPLACE WITH COPYRIGHT HOLDER
#This parameter is use to update or to deploy BOINC application
binary =
app-name =
version =
platform =
extension =
template-result =
template-wu =
wu-number =
input-file =
# Default value if no domain is specified # Default value if no domain is specified
domain = domain =
# Default value if no ssh parameter is specified # Default value if no ssh parameter is specified
......
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