Commit 65ecb29d authored by Alain Takoudjou's avatar Alain Takoudjou

Update request Boinc-application to use Json parameter

parent a1e0d3c4
...@@ -28,6 +28,7 @@ from slapos.recipe.librecipe import GenericBaseRecipe ...@@ -28,6 +28,7 @@ from slapos.recipe.librecipe import GenericBaseRecipe
import os import os
import subprocess import subprocess
import pwd import pwd
import json
import signal import signal
import zc.buildout import zc.buildout
...@@ -223,10 +224,10 @@ class App(GenericBaseRecipe): ...@@ -223,10 +224,10 @@ class App(GenericBaseRecipe):
"""This recipe allow to deploy an scientific applications using boinc """This recipe allow to deploy an scientific applications using boinc
Note that recipe use depend on boinc-server parameter""" Note that recipe use depend on boinc-server parameter"""
def downloadFiles(self): def downloadFiles(self, app):
"""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 ('input-file', 'template-result', 'template-wu', 'binary'): for key in ('input-file', 'template-result', 'template-wu', 'binary'):
param = self.options[key].strip() param = app[key]
if param and (param.startswith('http') or param.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(), 'tmp') cache = os.path.join(self.options['home'].strip(), 'tmp')
...@@ -237,39 +238,61 @@ class App(GenericBaseRecipe): ...@@ -237,39 +238,61 @@ class App(GenericBaseRecipe):
if key == 'binary': if key == 'binary':
mode = 0700 mode = 0700
os.chmod(path, mode) os.chmod(path, mode)
self.options[key] = path app[key] = path
def checkOptions(self): def getAppList(self):
"""Check if parameter send is valid to install or update application""" """Load parameters,
if not self.options['app-name'].strip() or \ check if parameter send is valid to install or update application"""
not self.options['version'].strip(): app_list = json.loads(self.options['boinc-app-list'])
return False if not app_list:
self.appname = self.options['app-name'].strip() return None
self.version = self.options['version'].strip() default_template_result = self.options.get('default-template-result', '').strip()
#for non exist application, check if parameter is complete default_template_wu = self.options.get('default-template-wu', '').strip()
default_extension = self.options.get('default-extension', '').strip()
default_platform = self.options.get('default-platform', '').strip()
for app in app_list:
for version in app_list[app]:
current_app = app_list[app][version]
#Use default value if empty and Use_default is True
#Initialize all values to empty if not define by the user
if current_app['use_default']:
current_app['template-result'] = current_app.get('template-result',
default_template_result).strip()
current_app['template-wu'] = current_app.get('template-wu',
default_template_wu).strip()
current_app['extension'] = current_app.get('extension',
default_extension).strip()
current_app['platform'] = current_app.get('platform',
default_platform).strip()
else:
current_app['template-result'] = current_app.get('template-result', '').strip()
current_app['template-wu'] = current_app.get('template-wu', '').strip()
current_app['extension'] = current_app.get('extension', '').strip()
current_app['platform'] = current_app.get('platform', '').strip()
current_app['input-file'] = current_app.get('input-file', '').strip()
current_app['wu-number'] = current_app.get('wu-number', 1)
#for new application, check if parameter is complete
appdir = os.path.join(self.options['installroot'].strip(), 'apps', appdir = os.path.join(self.options['installroot'].strip(), 'apps',
self.options['app-name'].strip(), app, version)
self.options['version'].strip())
if not os.path.exists(appdir): if not os.path.exists(appdir):
if not self.options['template-result'].strip() or not self.options['binary'].strip() \ if not current_app['template-result'] or not current_app['binary'] \
or not self.options['input-file'].strip() or not self.options['template-wu'].strip() \ or not current_app['input-file'] or not current_app['template-wu'] \
or not self.options['wu-number'].strip() or not self.options['platform'].strip(): or not current_app['platform']:
print "Invalid argement values...operation cancelled" print "BOINC-APP: ERROR - Invalid argements values for % ...operation cancelled" % app
return False app_list[app][version] = None
continue
#write application to install #write application to install
request_file = os.path.join(self.options['home'].strip(), request_file = os.path.join(self.options['home'].strip(),
'.install_' + self.appname + self.version) '.install_' + app + version)
toInstall = open(request_file, 'w') toInstall = open(request_file, 'w')
toInstall.write('install or update') toInstall.write('install or update')
toInstall.close() toInstall.close()
return True return app_list
def install(self): def install(self):
self.appname = ''
self.version = '' app_list = self.getAppList()
if not self.checkOptions():
#don't deploy empty or invalid 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
...@@ -299,36 +322,42 @@ class App(GenericBaseRecipe): ...@@ -299,36 +322,42 @@ class App(GenericBaseRecipe):
os.chmod(bash , 0700) os.chmod(bash , 0700)
#If useful, download necessary files and update options path #If useful, download necessary files and update options path
self.downloadFiles()
start_boinc = os.path.join(home, '.start_boinc') start_boinc = os.path.join(home, '.start_boinc')
installroot = self.options['installroot'].strip() installroot = self.options['installroot'].strip()
platform = self.options['platform'].strip()
apps_dir = os.path.join(installroot, 'apps') apps_dir = os.path.join(installroot, 'apps')
bin_name = self.appname +"_"+ self.version +"_"+ \
platform + self.options['extension'].strip()
application = os.path.join(apps_dir, self.appname, self.version, platform)
wrapperdir = self.options['wrapper-dir'].strip() wrapperdir = self.options['wrapper-dir'].strip()
project = self.options['project'].strip() project = self.options['project'].strip()
lockfile = os.path.join(self.options['home'].strip(), 'app_install.lock') lockfile = os.path.join(self.options['home'].strip(), 'app_install.lock')
fd = os.open(lockfile, os.O_RDWR|os.O_CREAT) fd = os.open(lockfile, os.O_RDWR|os.O_CREAT)
os.close( fd ) os.close( fd )
parameter = dict(installroot=installroot, project=project, for appname in app_list:
appname=self.appname, binary_name=bin_name, for version in app_list[appname]:
version=self.version, platform=platform, if not app_list[appname][version]:
continue
self.downloadFiles(app_list[appname][version])
platform = app_list[appname][version]['platform']
application = os.path.join(apps_dir, appname, version, platform)
if app_list[appname][version]['binary'] and not platform:
print "BOINC-APP: WARNING - Cannot specify binary without giving platform value"
app_list[appname][version]['binary'] = '' #Binary will not be updated
parameter = dict(installroot=installroot,
appname=appname, project=project,
version=version, platform=platform,
application=application, environment=environment, application=application, environment=environment,
start_boinc=start_boinc, start_boinc=start_boinc,
wu_number=int(self.options['wu-number'].strip()), wu_number=app_list[appname][version]['wu-number'],
t_result=self.options['template-result'].strip(), t_result=app_list[appname][version]['template-result'],
t_wu=self.options['template-wu'].strip(), t_wu=app_list[appname][version]['template-wu'],
t_input=self.options['input-file'].strip(), t_input=app_list[appname][version]['input-file'],
binary=self.options['binary'].strip(), binary=app_list[appname][version]['binary'],
extension=app_list[appname][version]['extension'],
bash=bash, home_dir=home, bash=bash, home_dir=home,
lockfile=lockfile, lockfile=lockfile,
) )
deploy_app = self.createPythonScript( deploy_app = self.createPythonScript(
os.path.join(wrapperdir, 'boinc_%s' % self.appname), os.path.join(wrapperdir, 'boinc_%s' % appname),
'%s.configure.deployApp' % __name__, parameter '%s.configure.deployApp' % __name__, parameter
) )
path_list.append(deploy_app) path_list.append(deploy_app)
......
...@@ -211,7 +211,9 @@ def deployManagement(args): ...@@ -211,7 +211,9 @@ def deployManagement(args):
args['appname'] + numversion + '_result') args['appname'] + numversion + '_result')
t_wu = os.path.join(args['templates'], t_wu = os.path.join(args['templates'],
args['appname'] + numversion + '_wu') args['appname'] + numversion + '_wu')
binary = os.path.join(args['application'], args['binary_name']) binary_name = args['appname'] +"_"+ args['version'] +"_"+ \
args['platform'] + args['extension']
binary = os.path.join(args['application'], binary_name)
signBin = False signBin = False
if not os.path.exists(base_app): if not os.path.exists(base_app):
os.mkdir(base_app) os.mkdir(base_app)
......
...@@ -8,5 +8,5 @@ offline = true ...@@ -8,5 +8,5 @@ offline = true
[switch_softwaretype] [switch_softwaretype]
recipe = slapos.cookbook:softwaretype recipe = slapos.cookbook:softwaretype
default = ${boinc-instance:output} default = ${template-boinc:output}
mariadb = ${template-mariadb:output} mariadb = ${template-mariadb:output}
\ No newline at end of file
...@@ -5,9 +5,8 @@ develop = ...@@ -5,9 +5,8 @@ develop =
${:parts-directory}/slapos.cookbook-repository ${:parts-directory}/slapos.cookbook-repository
parts = parts =
boinc-instance
template template
boinc-application application
template_wu template_wu
template_result template_result
template_input template_input
...@@ -21,22 +20,16 @@ extends = ...@@ -21,22 +20,16 @@ extends =
../../stack/boinc/buildout.cfg ../../stack/boinc/buildout.cfg
#Generate All instances templates #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 = ab01f101cc6280ef07ea61a22a1432d0
[template] [template]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance.cfg url = ${:_profile_base_location_}/instance.cfg
output = ${buildout:directory}/template.cfg output = ${buildout:directory}/template.cfg
mode = 0644 mode = 0644
md5sum = d097ddeeee5d89881d097efe6165caf6 md5sum = 4a286795a6822ee6d53743191d5374a6
#Download Boinc Application Binary and configure project #Download Boinc Application Binary and configure project
[boinc-application] [application]
recipe = hexagonit.recipe.download recipe = hexagonit.recipe.download
url = ${boinc:location}/libexec/examples/upper_case url = ${boinc:location}/libexec/examples/upper_case
download-only = true download-only = true
...@@ -44,11 +37,6 @@ filename = upper_case ...@@ -44,11 +37,6 @@ filename = upper_case
#Application configuration #Application configuration
app-name = upper_case app-name = upper_case
version = 1.00 version = 1.00
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 number number of work unit
wu-number = 2
[template-base] [template-base]
recipe = slapos.recipe.download recipe = slapos.recipe.download
...@@ -60,21 +48,30 @@ mode = 0644 ...@@ -60,21 +48,30 @@ mode = 0644
url = ${:_profile_base_location_}/templates/template_result url = ${:_profile_base_location_}/templates/template_result
filename = template_result filename = template_result
location = ${buildout:parts-directory}/${:_buildout_section_name_} location = ${buildout:parts-directory}/${:_buildout_section_name_}
#md5sum = md5sum = a3f0e9fd559cadcb2f297b952f8face8
[template_wu] [template_wu]
<= template-base <= template-base
url = ${:_profile_base_location_}/templates/template_wu url = ${:_profile_base_location_}/templates/template_wu
filename = template_wu filename = template_wu
location = ${buildout:parts-directory}/${:_buildout_section_name_} location = ${buildout:parts-directory}/${:_buildout_section_name_}
#md5sum = md5sum = 66d7ec85ce15e65d2858c11b75fb9574
[template_input] [template_input]
<= template-base <= template-base
url = ${:_profile_base_location_}/input/input_file url = ${:_profile_base_location_}/input/input_file
filename = input_file filename = input_file
location = ${buildout:parts-directory}/${:_buildout_section_name_} location = ${buildout:parts-directory}/${:_buildout_section_name_}
#md5sum = md5sum = 6f8db599de986fab7a21625b7916589c
[boinc-application]
app-list = {"${application:app-name}":{"${application:version}":{"use_default":true, "wu-number":2, "input-file":"${template_input:location}/${template_input:filename}", "binary":"${application:location}/${application:filename}"}}}
[boinc-default]
template-result = ${template_result:location}/${template_result:filename}
template-wu = ${template_wu:location}/${template_wu:filename}
platform = x86_64-pc-linux-gnu
extension =
# Local development # Local development
[slapos.cookbook-repository] [slapos.cookbook-repository]
......
...@@ -34,7 +34,7 @@ eggs = ...@@ -34,7 +34,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 = 20e9e2276e3cbc6504bf065eabbe13a7 md5sum = cc95919d5400c4dfcd16646f25ba8c96
mode = 0644 mode = 0644
#Template for deploying MySQL Database Server #Template for deploying MySQL Database Server
...@@ -53,6 +53,15 @@ filename = apache.in ...@@ -53,6 +53,15 @@ filename = apache.in
md5sum = 030892494ce87357e6e09dcd89187bf4 md5sum = 030892494ce87357e6e09dcd89187bf4
location = ${buildout:parts-directory}/${:_buildout_section_name_} location = ${buildout:parts-directory}/${:_buildout_section_name_}
[boinc-default]
template-result =
template-wu =
extension =
platform = x86_64-pc-linux-gnu
[boinc-application]
app-list = {}
[networkcache] [networkcache]
# signature certificates of the following uploaders. # signature certificates of the following uploaders.
# Romain Courteaud # Romain Courteaud
......
...@@ -13,7 +13,6 @@ parts = ...@@ -13,7 +13,6 @@ parts =
cron-entry-boinc cron-entry-boinc
promise promise
slapmonitor slapmonitor
slapreport
frontend-promise frontend-promise
content-promise content-promise
publish-connection-informations publish-connection-informations
...@@ -184,7 +183,7 @@ bytes = 4 ...@@ -184,7 +183,7 @@ bytes = 4
recipe = slapos.cookbook:boinc recipe = slapos.cookbook:boinc
home = $${buildout:directory} home = $${buildout:directory}
project = $${slap-parameter:project} project = $${slap-parameter:project}
#http://[$${apache-php:ip}]:$${apache-php:port}/ #url-base = http://[$${apache-php:ip}]:$${apache-php:port}/
url-base = $${request-frontend:connection-site_url} url-base = $${request-frontend:connection-site_url}
fullname = $${slap-parameter:full-name} fullname = $${slap-parameter:full-name}
copyright = $${slap-parameter:copyright-holder} copyright = $${slap-parameter:copyright-holder}
...@@ -223,15 +222,11 @@ mysql-port = $${stunnel:local-port} ...@@ -223,15 +222,11 @@ mysql-port = $${stunnel:local-port}
recipe = slapos.cookbook:boinc.app recipe = slapos.cookbook:boinc.app
#appname and version is require to update any existing application #appname and version is require to update any existing application
#otherwise, the recipe would try to install a new one #otherwise, the recipe would try to install a new one
app-name = $${slap-parameter:app-name} boinc-app-list = $${slap-parameter:boinc-app-list}
version = $${slap-parameter:version} default-template-result = $${slap-parameter:default-template-result}
wu-number = $${slap-parameter:wu-number} default-template-wu = $${slap-parameter:default-template-wu}
binary = $${slap-parameter:binary} default-extension = $${slap-parameter:default-extension}
platform = $${slap-parameter:platform} default-platform = $${slap-parameter:default-platform}
extension = $${slap-parameter:extension}
template-result = $${slap-parameter:template-result}
template-wu = $${slap-parameter:template-wu}
input-file = $${slap-parameter:input-file}
# Deploy logrotate, cron, configure it # Deploy logrotate, cron, configure it
[logrotate] [logrotate]
...@@ -321,19 +316,6 @@ shell-path = ${dash:location}/bin/dash ...@@ -321,19 +316,6 @@ shell-path = ${dash:location}/bin/dash
slapmonitor-path = ${buildout:bin-directory}/slapmonitor slapmonitor-path = ${buildout:bin-directory}/slapmonitor
path = $${basedirectory:scripts}/slapmonitor path = $${basedirectory:scripts}/slapmonitor
[slapreport]
recipe = slapos.cookbook:slapreport
pid-file = $${basedirectory:run}/apache.pid
database-path = $${basedirectory:log}/slapmonitor.db
consumption-log-path = $${basedirectory:log}/instance_consumption.log
logbox-ip = 87.98.152.12
logbox-port = 5122
logbox-user = admin
logbox-passwd = passer
shell-path = ${dash:location}/bin/dash
slapreport-path = ${buildout:bin-directory}/slapreport
path = $${basedirectory:scripts}/slapreport
# Publish all instance parameters (url of instance) # Publish all instance parameters (url of instance)
[publish-connection-informations] [publish-connection-informations]
...@@ -372,20 +354,18 @@ dbname = boinctest ...@@ -372,20 +354,18 @@ 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 #definition of BOINC parameter
binary = #boinc-app-list is a Json data for all application to deploy
app-name = # boinc-app-list = {"MY_APP1":{VERSION1:{
version = # use_default:true, "binary":"MY_BINARY",
platform = # "platform":"", "extension":"", "template-result":"",
extension = # "template-wu":"", "wu-number":1, "input-file":"INPUT"},
template-result = # "VERSION2":{use_default:false, ...}}}
template-wu = # "app-name" parameter is now boinc-app-list[key]
wu-number = boinc-app-list = ${boinc-application:app-list}
input-file = default-template-result = ${boinc-default:template-result}
default-template-wu = ${boinc-default:template-wu}
default-extension = ${boinc-default:extension}
default-platform = ${boinc-default:platform}
# Default value if no domain is specified # Default value if no domain is specified
domain = domain =
# Default value if no ssh parameter is specified
logbox-ip =
logbox-port =
logbox-user =
logbox-passwd =
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