Commit b9a5e418 authored by Alain Takoudjou's avatar Alain Takoudjou

Update boinc-client and allow to run multiple client on the same physical computer

parent b1b87312
...@@ -12,7 +12,6 @@ extends = ...@@ -12,7 +12,6 @@ extends =
../automake/buildout.cfg ../automake/buildout.cfg
../libtool/buildout.cfg ../libtool/buildout.cfg
../pkgconfig/buildout.cfg ../pkgconfig/buildout.cfg
../cyrus-sasl/buildout.cfg
../openldap/buildout.cfg ../openldap/buildout.cfg
../gnutls/buildout.cfg ../gnutls/buildout.cfg
../../stack/slapos.cfg ../../stack/slapos.cfg
...@@ -39,7 +38,7 @@ location = ${buildout:parts-directory}/BOINC ...@@ -39,7 +38,7 @@ location = ${buildout:parts-directory}/BOINC
[boinc-patch] [boinc-patch]
recipe = slapos.recipe.download recipe = slapos.recipe.download
url = ${:_profile_base_location_}/boinc-abs-path.patch url = ${:_profile_base_location_}/boinc-abs-path.patch
md5sum = 4f385abae9da5ebea7a73d316ebda318 md5sum = 412acedfbcdc8a9a7f196a02465da248
location = ${buildout:parts-directory}/${:_buildout_section_name_} location = ${buildout:parts-directory}/${:_buildout_section_name_}
filename = boinc-abs-path.patch filename = boinc-abs-path.patch
...@@ -73,7 +72,6 @@ configure-options = ...@@ -73,7 +72,6 @@ configure-options =
--disable-server --disable-server
--with-pkg-config --with-pkg-config
--with-ssl=${openssl:location} --with-ssl=${openssl:location}
--with-libsasl2=${cyrus-sasl:location}/lib
--with-libldap=${openldap:location}/lib --with-libldap=${openldap:location}/lib
--with-libgnutls=${gnutls:location}/lib --with-libgnutls=${gnutls:location}/lib
--with-libcurl=${curl:location}/lib --with-libcurl=${curl:location}/lib
......
...@@ -238,7 +238,8 @@ class App(GenericBaseRecipe): ...@@ -238,7 +238,8 @@ class App(GenericBaseRecipe):
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())) uldl_pid=self.options['apache-pid'].strip(),
user=self.options['user']))
) )
path_list.append(sh_script) path_list.append(sh_script)
os.chmod(bash , 0700) os.chmod(bash , 0700)
...@@ -280,21 +281,49 @@ class App(GenericBaseRecipe): ...@@ -280,21 +281,49 @@ class App(GenericBaseRecipe):
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"""
def __init__(self, buildout, name, options):
#get current uig to create a unique rpc-port for this client
stat_info = os.stat(options['install-dir'].strip())
options['rpc-port'] = pwd.getpwuid(stat_info.st_uid)[2] + 5000
return GenericBaseRecipe.__init__(self, buildout, name, options)
def install(self): def install(self):
path_list = [] path_list = []
boincbin = self.options['boinc-bin'].strip() boincbin = self.options['boinc-bin'].strip()
cmdbin = self.options['cmd-bin'].strip()
installdir = self.options['install-dir'].strip() installdir = self.options['install-dir'].strip()
url = self.options['server-url'].strip() url = self.options['server-url'].strip()
key = self.options['key'].strip() key = self.options['key'].strip()
boinc_wrapper = self.options['client-wrapper'].strip() boinc_wrapper = self.options['client-wrapper'].strip()
cmd_wrapper = self.options['cmd-wrapper'].strip()
remote_host = os.path.join(installdir, 'remote_hosts.cfg')
open(remote_host, 'w').write(self.options['ip'].strip())
#Generate wrapper for boinc_client #Generate wrapper for boinc cmd
client_wrapper = self.createPythonScript(boinc_wrapper, base_cmd = [cmdbin, '--host', str(self.options['rpc-port']),
'slapos.recipe.librecipe.execute.execute', '--passwd', self.options['passwd'].strip()]
([boincbin, '--dir', installdir, '--attach_project', url, key]) cc_cmd = ''
if self.options['cconfig'].strip() != '':
config_dest = os.path.join(installdir, 'cc_config.xml')
file = open(config_dest, 'w')
file.write(open(self.options['cconfig'].strip(), 'r').read())
file.close()
cc_cmd = '--read_cc_config'
cmd = self.createPythonScript(cmd_wrapper,
'%s.configure.runCmd' % __name__,
dict(base_cmd=base_cmd, cc_cmd=cc_cmd, installdir=installdir,
project_url=url, key=key)
) )
path_list.append(client_wrapper) path_list.append(cmd)
return path_list
update = install #Generate BOINC client wrapper
boinc = self.createPythonScript(boinc_wrapper,
\ No newline at end of file 'slapos.recipe.librecipe.execute.execute',
[boincbin, '--allow_multiple_clients', '--gui_rpc_port',
str(self.options['rpc-port']), '--allow_remote_gui_rpc',
'--dir', installdir, '--redirectio', '--check_all_logins']
)
path_list.append(boinc)
return path_list
...@@ -30,6 +30,7 @@ import sys ...@@ -30,6 +30,7 @@ import sys
import subprocess import subprocess
import time import time
import shutil import shutil
import re
def checkMysql(args): def checkMysql(args):
sys.path += args['python_path'].split(':') sys.path += args['python_path'].split(':')
...@@ -45,15 +46,22 @@ def checkMysql(args): ...@@ -45,15 +46,22 @@ def checkMysql(args):
conn.close() conn.close()
print "Successfully connect to MySQL database... " print "Successfully connect to MySQL database... "
if args.has_key('file_status'): if args.has_key('file_status'):
file = open(args['file_status'], 'w') writeFile(args['file_status'], "starting")
file.write("starting")
file.close()
break break
except Exception, ex: except Exception, ex:
print "The result is: \n" + ex.message print "The result is: \n" + ex.message
print "Could not connect to MySQL database... sleep for 2 secondes" print "Could not connect to MySQL database... sleep for 2 secondes"
time.sleep(2) time.sleep(2)
def checkFile(file, stime):
"""Loop until 'file' is created (exist)"""
while True:
print "Search for file %s..." % file
if not os.path.exists(file):
print "File not found... sleep for %s secondes" % stime
time.sleep(stime)
else:
break
def services(args): def services(args):
"""This function configure a new installed boinc project instance""" """This function configure a new installed boinc project instance"""
...@@ -62,13 +70,7 @@ def services(args): ...@@ -62,13 +70,7 @@ def services(args):
print "Not need to install Boinc-server...skipped" print "Not need to install Boinc-server...skipped"
return return
#Sleep until file 'boinc_project'.readme exist #Sleep until file 'boinc_project'.readme exist
while True: checkFile(args['readme'], 3)
print "Search for file %s..." % args['readme']
if not os.path.exists(args['readme']):
print "File not found... sleep for 3 secondes"
time.sleep(3)
else:
break
topath = os.path.join(args['installroot'], 'html/ops/.htpasswd') topath = os.path.join(args['installroot'], 'html/ops/.htpasswd')
print "Generating .htpasswd file... File=%s" % topath print "Generating .htpasswd file... File=%s" % topath
...@@ -111,20 +113,12 @@ def services(args): ...@@ -111,20 +113,12 @@ def services(args):
if not startProcess(["php", forum_file], env, cwd): if not startProcess(["php", forum_file], env, cwd):
return return
status = open(args['service_status'], "w") writeFile(args['service_status'], "started")
status.write("started")
status.close()
def restart_boinc(args): def restart_boinc(args):
"""Stop (if currently is running state) and start all Boinc service""" """Stop (if currently is running state) and start all Boinc service"""
if args['drop_install']: if args['drop_install']:
while True: checkFile(args['service_status'], 3)
print "Search for file %s..." % args['service_status']
if not os.path.exists(args['service_status']):
print "File not found... sleep for 3 secondes"
time.sleep(3)
else:
break
else: else:
checkMysql(args) checkMysql(args)
print "Restart Boinc..." print "Restart Boinc..."
...@@ -133,9 +127,7 @@ def restart_boinc(args): ...@@ -133,9 +127,7 @@ def restart_boinc(args):
binstop = os.path.join(args['installroot'], 'bin/stop') binstop = os.path.join(args['installroot'], 'bin/stop')
os.system(binstop) os.system(binstop)
os.system(binstart) os.system(binstart)
status = open(args['start_boinc'], "w") writeFile(args['start_boinc'], "started")
status.write("started")
status.close()
print "Done." print "Done."
def deployApp(args): def deployApp(args):
...@@ -155,13 +147,7 @@ def deployApp(args): ...@@ -155,13 +147,7 @@ def deployApp(args):
args['previous_wu'] = 0 args['previous_wu'] = 0
dropapp = True dropapp = True
#Sleep until file .start_boinc exist (File indicate that BOINC has been started) #Sleep until file .start_boinc exist (File indicate that BOINC has been started)
while True: checkFile(args['start_boinc'], 3)
print "Search for file %s..." % args['start_boinc']
if not os.path.exists(args['start_boinc']):
print "File not found... sleep for 3 secondes"
time.sleep(3)
else:
break
print "setup directories..." print "setup directories..."
args['inputfile'] = os.path.join(args['installroot'], 'download', args['inputfile'] = os.path.join(args['installroot'], 'download',
...@@ -243,9 +229,7 @@ def deployApp(args): ...@@ -243,9 +229,7 @@ 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(token, 'w') writeFile(token, str(args['wu_number']))
sfile.write(str(args['wu_number']))
sfile.close()
def create_wu(args, env): def create_wu(args, env):
t_result = "templates/" + args['appname'] + '_result' t_result = "templates/" + args['appname'] + '_result'
...@@ -253,14 +237,15 @@ def create_wu(args, env): ...@@ -253,14 +237,15 @@ def create_wu(args, env):
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', '', '--appname', args['appname'], '--wu_name', '',
'--wu_template', t_wu, '--result_template', t_result, '--wu_template', t_wu, '--result_template', t_result,
'--min_quorum', '1', '--target_nresults', '1',
args['appname']+'_input'] args['appname']+'_input']
for i in range(args['previous_wu'], args['wu_number']): 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['appname'] + str(i+1) + args['version'] + '_nodelete' launch_args[4] = args['appname'] + str(i+1) + args['version'] + '_nodelete'
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, stdout=subprocess.PIPE):
process = subprocess.Popen(launch_args, stdout=subprocess.PIPE, process = subprocess.Popen(launch_args, stdout=stdout,
stderr=subprocess.STDOUT, env=env, stderr=subprocess.STDOUT, env=env,
cwd=cwd) cwd=cwd)
result = process.communicate()[0] result = process.communicate()[0]
...@@ -269,4 +254,24 @@ def startProcess(launch_args, env=None, cwd=None): ...@@ -269,4 +254,24 @@ def startProcess(launch_args, env=None, cwd=None):
return False return False
return True return True
def runCmd(args):
\ No newline at end of file """Wait for Boinc Client started and run boinc cmd"""
client_config = os.path.join(args['installdir'], 'client_state.xml')
checkFile(client_config, 5)
time.sleep(10)
#Scan client state xml to find client ipv4 adress
host = result = re.search("<ip_addr>([\w\d\.:]+)</ip_addr>",
open(client_config, 'r').read()).group(1)
args['base_cmd'][2] = host + ':' + args['base_cmd'][2]
print "Run boinccmd with host at %s " % args['base_cmd'][2]
project_args = args['base_cmd'] + ['--project_attach', args['project_url'],
args['key']]
startProcess(project_args, cwd=args['installdir'])
if args['cc_cmd'] != '':
#Load or reload cc_config file
startProcess(args['base_cmd'] + [args['cc_cmd']], cwd=args['installdir'])
def writeFile(file, content):
f = open(file, 'w')
f.write(content)
f.close()
\ No newline at end of file
[buildout]
parts =
boinc-client
publish-connection-informations
eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true
[rootdirectory]
recipe = slapos.cookbook:mkdirectory
etc = $${buildout:directory}/etc/
var = $${buildout:directory}/var/
srv = $${buildout:directory}/srv/
bin = $${buildout:directory}/bin/
tmp = $${buildout:directory}/tmp/
[basedirectory]
recipe = slapos.cookbook:mkdirectory
log = $${rootdirectory:var}/log/
services = $${rootdirectory:etc}/run/
run = $${rootdirectory:var}/run/
backup = $${rootdirectory:srv}/backup/
promises = $${rootdirectory:etc}/promise/
boinc = $${rootdirectory:srv}/boinc/
[boinc-passwd]
recipe = slapos.cookbook:generate.password
storage-path = $${basedirectory:boinc}/gui_rpc_auth.cfg
bytes = 8
[boinc-client]
recipe = slapos.cookbook:boinc.client
install-dir = $${basedirectory:boinc}
client-wrapper = $${basedirectory:services}/boinc_client
cmd-wrapper = $${basedirectory:services}/boinc_cmd
#specifie a cc_config.xml file to boinc client, use cconfig
ip = $${slap-network-information:global-ipv6}
passwd = $${boinc-passwd:passwd}
cconfig =
boinc-bin = ${boinc:location}/bin/boinc_client
cmd-bin = ${boinc:location}/bin/boinccmd
server-url = $${slap-parameter:project_url}
key = $${slap-parameter:key}
# Publish all instance parameters
[publish-connection-informations]
recipe = slapos.cookbook:publish
project-url = $${slap-parameter:project_url}
account-key = $${slap-parameter:key}
remote-host = $${boinc-client:ip}
rpc-port = $${boinc-client:rpc-port}
rpc-passwd = $${boinc-passwd:passwd}
[slap-parameter]
#please provide project_url and your session key via SlapOS Master (instance parameters)
project_url =
key =
[buildout] [buildout]
parts = parts =
instance switch_softwaretype
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
[rootdirectory] [switch_softwaretype]
recipe = slapos.cookbook:mkdirectory recipe = slapos.cookbook:softwaretype
etc = $${buildout:directory}/etc/ default = ${template-boinc:output}
var = $${buildout:directory}/var/ \ No newline at end of file
srv = $${buildout:directory}/srv/
bin = $${buildout:directory}/bin/
tmp = $${buildout:directory}/tmp/
[basedirectory]
recipe = slapos.cookbook:mkdirectory
log = $${rootdirectory:var}/log/
services = $${rootdirectory:etc}/run/
run = $${rootdirectory:var}/run/
backup = $${rootdirectory:srv}/backup/
promises = $${rootdirectory:etc}/promise/
boinc = $${rootdirectory:srv}/boinc/
[instance]
recipe = slapos.cookbook:boinc.client
install-dir = $${basedirectory:boinc}
client-wrapper = $${basedirectory:services}/boinc_client
#specifie a cc_config.xml file to boinc client, use cconfig
cconfig =
boinc-bin = ${boinc:location}/bin/boinc_client
server-url = $${slap-parameter:project_url}
key = $${slap-parameter:key}
[slap-parameter]
#please provide project_url and your session key via SlapOS Master (instance parameters)
project_url = http://[2001:470:1f14:169:f070:3202:6eee:903f]:8080/boinc_test/
key = 1_16e214b9bd0735f9aaef03ee413b8711
[buildout] [buildout]
develop =
/srv/slapgrid/slappart19/srv//runner/project/slapos.github
parts= parts=
slapos-cookbook slapos-cookbook
boinc boinc
template template
template-boinc
extends = extends =
../../component/boinc-client/buildout.cfg ../../component/boinc-client/buildout.cfg
...@@ -13,68 +17,17 @@ extends = ...@@ -13,68 +17,17 @@ extends =
# Default template for boinc-client instance. # Default template for boinc-client instance.
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance.cfg url = ${:_profile_base_location_}/instance.cfg
md5sum = e0b6e4ea739bbc4bf59a9009b7b0aa80 md5sum = 79f4d781c1b385d2afa75ae4077c5381
output = ${buildout:directory}/template.cfg output = ${buildout:directory}/template.cfg
mode = 0644 mode = 0644
[versions] [template-boinc]
Jinja2 = 2.6 # Default template for boinc-client instance.
Werkzeug = 0.8.3 recipe = slapos.recipe.template
buildout-versions = 1.7 url = ${:_profile_base_location_}/instance-boinc.cfg
hexagonit.recipe.cmmi = 1.6 md5sum = 147fd101d507c4f8eba9694e25571d4e
lxml = 3.0alpha2 output = ${buildout:directory}/template-boinc.cfg
meld3 = 0.6.8 mode = 0644
plone.recipe.command = 1.1
slapos.recipe.download = 1.0.dev-r4053
slapos.recipe.template = 2.4.2
# Required by:
# slapos.core==0.28.6
Flask = 0.9
# Required by:
# slapos.cookbook==0.60-dev
PyXML = 0.8.4
# Required by:
# hexagonit.recipe.cmmi==1.6
hexagonit.recipe.download = 1.5.1
# Required by:
# slapos.cookbook==0.60-dev
inotifyx = 0.2.0
# Required by:
# slapos.cookbook==0.60-dev
netaddr = 0.7.10
# Required by:
# slapos.core==0.28.6
netifaces = 0.8
# Required by:
# slapos.cookbook==0.60-dev
# slapos.core==0.28.6
# zc.buildout==1.6.0-dev-SlapOS-006
# zc.recipe.egg==1.3.2
setuptools = 0.6c12dev-r88846
# Required by:
# slapos.cookbook==0.60-dev
slapos.core = 0.28.6
# Required by:
# slapos.core==0.28.6
supervisor = 3.0a12
# Required by:
# slapos.cookbook==0.60-dev
xml-marshaller = 0.9.7
# Required by:
# slapos.cookbook==0.60-dev
zc.recipe.egg = 1.3.2
# Required by: [versions]
# slapos.core==0.28.6 lxml = 2.3.6
zope.interface = 4.0.1 \ No newline at end of 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