Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Vincent Bechu
slapos
Commits
4bb47083
Commit
4bb47083
authored
Oct 16, 2012
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
factorize the code of boinc recipe
parent
28bed57e
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
133 additions
and
103 deletions
+133
-103
slapos/recipe/boinc/__init__.py
slapos/recipe/boinc/__init__.py
+33
-25
slapos/recipe/boinc/configure.py
slapos/recipe/boinc/configure.py
+86
-71
slapos/recipe/boinc/template/project_config.in
slapos/recipe/boinc/template/project_config.in
+7
-0
slapos/recipe/boinc/template/sed_update.in
slapos/recipe/boinc/template/sed_update.in
+0
-2
software/boinc/software.cfg
software/boinc/software.cfg
+1
-1
stack/boinc/buildout.cfg
stack/boinc/buildout.cfg
+2
-2
stack/boinc/instance-boinc.cfg
stack/boinc/instance-boinc.cfg
+4
-2
No files found.
slapos/recipe/boinc/__init__.py
View file @
4bb47083
...
@@ -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
(),
't
e
mp'
)
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
)
...
...
slapos/recipe/boinc/configure.py
View file @
4bb47083
...
@@ -31,9 +31,10 @@ import subprocess
...
@@ -31,9 +31,10 @@ import subprocess
import
time
import
time
import
shutil
import
shutil
import
re
import
re
import
filecmp
def
checkMysql
(
args
):
def
checkMysql
(
args
):
sys
.
path
+=
args
[
'
python_path
'
].
split
(
':'
)
sys
.
path
+=
args
[
'
environment'
][
'PYTHONPATH
'
].
split
(
':'
)
import
MySQLdb
import
MySQLdb
#Sleep until mysql server becomes available
#Sleep until mysql server becomes available
while
True
:
while
True
:
...
@@ -65,6 +66,61 @@ def checkFile(file, stime):
...
@@ -65,6 +66,61 @@ def checkFile(file, stime):
break
break
def
restart_boinc
(
args
):
"""Stop (if currently is running state) and start all Boinc service"""
if
args
[
'drop_install'
]:
checkFile
(
args
[
'service_status'
],
3
)
else
:
checkMysql
(
args
)
print
"Restart Boinc..."
env
=
os
.
environ
env
[
'PATH'
]
=
args
[
'environment'
][
'PATH'
]
env
[
'PYTHONPATH'
]
=
args
[
'environment'
][
'PYTHONPATH'
]
binstart
=
os
.
path
.
join
(
args
[
'installroot'
],
'bin/start'
)
binstop
=
os
.
path
.
join
(
args
[
'installroot'
],
'bin/stop'
)
os
.
system
(
binstop
)
os
.
system
(
binstart
)
writeFile
(
args
[
'start_boinc'
],
"started"
)
print
"Done."
def
check_installRequest
(
args
):
print
"Cheking if needed to install %s..."
%
args
[
'appname'
]
install_request_file
=
os
.
path
.
join
(
args
[
'home_dir'
],
'.install_'
+
args
[
'appname'
]
+
args
[
'version'
])
if
not
os
.
path
.
exists
(
install_request_file
):
print
"No install or update request for %s version %s..."
%
(
args
[
'appname'
],
args
[
'version'
])
return
False
os
.
unlink
(
install_request_file
)
return
True
def
copy_file
(
source
,
dest
):
""""Copy file with source to dest with auto replace
return True if file has been copied and dest ha been replaced
"""
result
=
False
if
source
and
os
.
path
.
exists
(
source
):
if
os
.
path
.
exists
(
dest
):
if
filecmp
.
cmp
(
dest
,
source
):
return
False
os
.
unlink
(
dest
)
result
=
True
shutil
.
copy
(
source
,
dest
)
return
result
def
startProcess
(
launch_args
,
env
=
None
,
cwd
=
None
,
stdout
=
subprocess
.
PIPE
):
process
=
subprocess
.
Popen
(
launch_args
,
stdout
=
stdout
,
stderr
=
subprocess
.
STDOUT
,
env
=
env
,
cwd
=
cwd
)
result
=
process
.
communicate
()[
0
]
if
process
.
returncode
is
None
or
process
.
returncode
!=
0
:
print
"Failed to execute executable.
\
n
The error was: %s"
%
result
return
False
return
True
def
services
(
args
):
def
services
(
args
):
"""This function configure a new installed boinc project instance"""
"""This function configure a new installed boinc project instance"""
print
"Checking if needed to install or reinstall Boinc-server..."
print
"Checking if needed to install or reinstall Boinc-server..."
...
@@ -81,11 +137,11 @@ def services(args):
...
@@ -81,11 +137,11 @@ def services(args):
if
not
startProcess
(
htpwd_args
):
if
not
startProcess
(
htpwd_args
):
return
return
print
"
Running xadd script
..."
print
"
execute script xadd
..."
env
=
os
.
environ
env
=
os
.
environ
env
[
'PATH'
]
=
args
[
'environment'
][
'PATH'
]
env
[
'PATH'
]
=
args
[
'environment'
][
'PATH'
]
env
[
'PYTHONPATH'
]
=
args
[
'environment'
][
'PYTHONPATH'
]
env
[
'PYTHONPATH'
]
=
args
[
'environment'
][
'PYTHONPATH'
]
if
not
startProcess
([
args
[
'xadd'
]
],
env
):
if
not
startProcess
([
os
.
path
.
join
(
args
[
'installroot'
],
'bin/xadd'
)
],
env
):
return
return
print
"Update files and directories permissions..."
print
"Update files and directories permissions..."
upload
=
os
.
path
.
join
(
args
[
'installroot'
],
'upload'
)
upload
=
os
.
path
.
join
(
args
[
'installroot'
],
'upload'
)
...
@@ -103,11 +159,8 @@ def services(args):
...
@@ -103,11 +159,8 @@ def services(args):
os
.
system
(
"chmod -R o+r "
+
inc
)
os
.
system
(
"chmod -R o+r "
+
inc
)
os
.
system
(
"chmod o+x "
+
languages
)
os
.
system
(
"chmod o+x "
+
languages
)
os
.
system
(
"chmod o+x "
+
compiled
)
os
.
system
(
"chmod o+x "
+
compiled
)
os
.
system
(
"sed -i '/remove the die/d' %s"
%
forum_file
)
sed_args
=
[
args
[
'sedconfig'
]]
subprocess
.
Popen
([
"sed -i 's#REPLACE WITH PROJECT NAME#%s#' %s"
%
(
args
[
'fullname'
],
startProcess
(
sed_args
)
project_inc
)],
shell
=
True
,
stdout
=
subprocess
.
PIPE
).
communicate
()[
0
]
subprocess
.
Popen
([
"sed -i 's#REPLACE WITH COPYRIGHT HOLDER#%s#' %s"
%
(
args
[
'copyright'
],
project_inc
)],
shell
=
True
,
stdout
=
subprocess
.
PIPE
).
communicate
()[
0
]
#Execute php create_forum.php...
#Execute php create_forum.php...
print
"Boinc Forum: Execute php create_forum.php..."
print
"Boinc Forum: Execute php create_forum.php..."
...
@@ -118,32 +171,10 @@ def services(args):
...
@@ -118,32 +171,10 @@ def services(args):
writeFile
(
args
[
'service_status'
],
"started"
)
writeFile
(
args
[
'service_status'
],
"started"
)
def
restart_boinc
(
args
):
"""Stop (if currently is running state) and start all Boinc service"""
if
args
[
'drop_install'
]:
checkFile
(
args
[
'service_status'
],
3
)
else
:
checkMysql
(
args
)
print
"Restart Boinc..."
os
.
environ
[
'PATH'
]
=
args
[
'PATH'
]
binstart
=
os
.
path
.
join
(
args
[
'installroot'
],
'bin/start'
)
binstop
=
os
.
path
.
join
(
args
[
'installroot'
],
'bin/stop'
)
os
.
system
(
binstop
)
os
.
system
(
binstart
)
writeFile
(
args
[
'start_boinc'
],
"started"
)
print
"Done."
def
deployApp
(
args
):
def
deployApp
(
args
):
"""Fully deploy or redeploy or update a BOINC application using existing BOINC instance"""
"""Fully deploy or redeploy or update a BOINC application using existing BOINC instance"""
print
"Cheking if needed to install %s..."
%
args
[
'appname'
]
if
not
check_installRequest
(
args
):
install_request_file
=
os
.
path
.
join
(
args
[
'home_dir'
],
'.install_'
+
args
[
'appname'
]
+
args
[
'version'
])
if
not
os
.
path
.
exists
(
install_request_file
):
print
"No install or update request for %s version %s..."
%
(
args
[
'appname'
],
args
[
'version'
])
return
return
os
.
unlink
(
install_request_file
)
token
=
os
.
path
.
join
(
args
[
'installroot'
],
"."
+
args
[
'appname'
]
+
args
[
'version'
])
token
=
os
.
path
.
join
(
args
[
'installroot'
],
"."
+
args
[
'appname'
]
+
args
[
'version'
])
newInstall
=
False
newInstall
=
False
if
os
.
path
.
exists
(
token
):
if
os
.
path
.
exists
(
token
):
...
@@ -156,18 +187,23 @@ def deployApp(args):
...
@@ -156,18 +187,23 @@ def deployApp(args):
newInstall
=
True
newInstall
=
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)
checkFile
(
args
[
'start_boinc'
],
3
)
checkFile
(
args
[
'start_boinc'
],
3
)
env
=
os
.
environ
env
[
'PATH'
]
=
args
[
'environment'
][
'PATH'
]
env
[
'PYTHONPATH'
]
=
args
[
'environment'
][
'PYTHONPATH'
]
print
"setup directories..."
print
"setup directories..."
numversion
=
args
[
'version'
].
replace
(
'.'
,
''
)
args
[
'inputfile'
]
=
os
.
path
.
join
(
args
[
'installroot'
],
'download'
,
args
[
'inputfile'
]
=
os
.
path
.
join
(
args
[
'installroot'
],
'download'
,
args
[
'appname'
]
+
args
[
'version'
]
+
'_input'
)
args
[
'appname'
]
+
numversion
+
'_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'
)
t_result
=
os
.
path
.
join
(
args
[
'templates'
],
t_result
=
os
.
path
.
join
(
args
[
'templates'
],
args
[
'appname'
]
+
args
[
'version'
]
+
'_result'
)
args
[
'appname'
]
+
numversion
+
'_result'
)
t_wu
=
os
.
path
.
join
(
args
[
'templates'
],
t_wu
=
os
.
path
.
join
(
args
[
'templates'
],
args
[
'appname'
]
+
args
[
'version'
]
+
'_wu'
)
args
[
'appname'
]
+
numversion
+
'_wu'
)
binary
=
os
.
path
.
join
(
args
[
'application'
],
args
[
'binary_name'
])
binary
=
os
.
path
.
join
(
args
[
'application'
],
args
[
'binary_name'
])
signBin
=
False
if
not
os
.
path
.
exists
(
base_app
):
if
not
os
.
path
.
exists
(
base_app
):
os
.
mkdir
(
base_app
)
os
.
mkdir
(
base_app
)
if
newInstall
:
if
newInstall
:
...
@@ -177,32 +213,24 @@ def deployApp(args):
...
@@ -177,32 +213,24 @@ def deployApp(args):
os
.
mkdir
(
args
[
'application'
])
os
.
mkdir
(
args
[
'application'
])
if
not
os
.
path
.
exists
(
args
[
'templates'
]):
if
not
os
.
path
.
exists
(
args
[
'templates'
]):
os
.
mkdir
(
args
[
'templates'
])
os
.
mkdir
(
args
[
'templates'
])
if
args
[
't_result'
]:
copy_file
(
args
[
't_result'
],
t_result
)
if
os
.
path
.
exists
(
t_result
):
copy_file
(
args
[
't_wu'
],
t_wu
)
os
.
unlink
(
t_result
)
signBin
=
copy_file
(
args
[
'binary'
],
binary
)
shutil
.
copy
(
args
[
't_result'
],
t_result
)
if
args
[
't_wu'
]:
if
os
.
path
.
exists
(
t_wu
):
os
.
unlink
(
t_wu
)
shutil
.
copy
(
args
[
't_wu'
],
t_wu
)
if
args
[
't_input'
]:
if
args
[
't_input'
]:
if
os
.
path
.
exists
(
args
[
'inputfile'
]):
if
os
.
path
.
exists
(
args
[
'inputfile'
]):
os
.
unlink
(
args
[
'inputfile'
])
os
.
unlink
(
args
[
'inputfile'
])
os
.
symlink
(
args
[
't_input'
],
args
[
'inputfile'
])
os
.
symlink
(
args
[
't_input'
],
args
[
'inputfile'
])
if
args
[
'binary'
]
and
args
[
'platform'
]:
if
os
.
path
.
exists
(
binary
):
os
.
unlink
(
binary
)
shutil
.
copy
(
args
[
'binary'
],
binary
)
if
newInstall
:
project_xml
=
os
.
path
.
join
(
args
[
'installroot'
],
'project.xml'
)
findapp
=
re
.
search
(
"<name>(%s)</name>"
%
args
[
'appname'
],
open
(
project_xml
,
'r'
).
read
())
if
not
findapp
:
print
"Adding '"
+
args
[
'appname'
]
+
"' to project.xml..."
print
"Adding '"
+
args
[
'appname'
]
+
"' to project.xml..."
print
"Adding deamon for application to config.xml..."
print
"Adding deamon for application to config.xml..."
project_xml
=
os
.
path
.
join
(
args
[
'installroot'
],
'project.xml'
)
config_xml
=
os
.
path
.
join
(
args
[
'installroot'
],
'config.xml'
)
sed_args
=
[
args
[
'bash'
],
args
[
'appname'
],
args
[
'installroot'
]]
sed_args
=
[
args
[
'bash'
],
args
[
'appname'
],
args
[
'installroot'
]]
startProcess
(
sed_args
)
startProcess
(
sed_args
)
if
args
[
'binary'
]
and
args
[
'platform'
]
:
if
signBin
:
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'
)
...
@@ -215,13 +243,10 @@ def deployApp(args):
...
@@ -215,13 +243,10 @@ def deployApp(args):
return
return
output
.
close
()
output
.
close
()
print
"Running xadd script..."
print
"execute script xadd..."
env
=
os
.
environ
env
[
'PATH'
]
=
args
[
'environment'
][
'PATH'
]
env
[
'PYTHONPATH'
]
=
args
[
'environment'
][
'PYTHONPATH'
]
if
not
startProcess
([
os
.
path
.
join
(
args
[
'installroot'
],
'bin/xadd'
)],
env
):
if
not
startProcess
([
os
.
path
.
join
(
args
[
'installroot'
],
'bin/xadd'
)],
env
):
return
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'
)
p_version
=
subprocess
.
Popen
([
updt_version
],
stdout
=
subprocess
.
PIPE
,
p_version
=
subprocess
.
Popen
([
updt_version
],
stdout
=
subprocess
.
PIPE
,
...
@@ -240,7 +265,6 @@ def deployApp(args):
...
@@ -240,7 +265,6 @@ def deployApp(args):
print
"Restart Boinc..."
print
"Restart Boinc..."
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'
)
sys
.
environ
=
env
os
.
system
(
binstop
)
os
.
system
(
binstop
)
os
.
system
(
binstart
)
os
.
system
(
binstart
)
...
@@ -249,30 +273,21 @@ def deployApp(args):
...
@@ -249,30 +273,21 @@ def deployApp(args):
def
create_wu
(
args
,
env
):
def
create_wu
(
args
,
env
):
t_result
=
"templates/"
+
args
[
'appname'
]
+
args
[
'version'
]
+
'_result'
"""Create or update number of work unit for an existing boinc application"""
t_wu
=
"templates/"
+
args
[
'appname'
]
+
args
[
'version'
]
+
'_wu'
numversion
=
args
[
'version'
].
replace
(
'.'
,
''
)
t_result
=
"templates/"
+
args
[
'appname'
]
+
numversion
+
'_result'
t_wu
=
"templates/"
+
args
[
'appname'
]
+
numversion
+
'_wu'
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'
,
'--min_quorum'
,
'1'
,
'--target_nresults'
,
'1'
,
args
[
'appname'
]
+
args
[
'version'
]
+
'_input'
]
args
[
'appname'
]
+
numversion
+
'_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
)
+
numversion
+
'_nodelete'
startProcess
(
launch_args
,
env
,
args
[
'installroot'
])
startProcess
(
launch_args
,
env
,
args
[
'installroot'
])
def
startProcess
(
launch_args
,
env
=
None
,
cwd
=
None
,
stdout
=
subprocess
.
PIPE
):
process
=
subprocess
.
Popen
(
launch_args
,
stdout
=
stdout
,
stderr
=
subprocess
.
STDOUT
,
env
=
env
,
cwd
=
cwd
)
result
=
process
.
communicate
()[
0
]
if
process
.
returncode
is
None
or
process
.
returncode
!=
0
:
print
"Failed to execute executable.
\
n
The error was: %s"
%
result
return
False
return
True
def
runCmd
(
args
):
def
runCmd
(
args
):
"""Wait for Boinc Client started and run boinc cmd"""
"""Wait for Boinc Client started and run boinc cmd"""
client_config
=
os
.
path
.
join
(
args
[
'installdir'
],
'client_state.xml'
)
client_config
=
os
.
path
.
join
(
args
[
'installdir'
],
'client_state.xml'
)
...
...
slapos/recipe/boinc/template/project_config.in
0 → 100644
View file @
4bb47083
#!%(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
slapos/recipe/boinc/template/sed_update.in
View file @
4bb47083
...
@@ -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
software/boinc/software.cfg
View file @
4bb47083
...
@@ -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
...
...
stack/boinc/buildout.cfg
View file @
4bb47083
...
@@ -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 = 0
b3825a4a0ec82e279609d1f9dc72da
4
md5sum = 0
30892494ce87357e6e09dcd89187bf
4
location = ${buildout:parts-directory}/${:_buildout_section_name_}
location = ${buildout:parts-directory}/${:_buildout_section_name_}
# Local development
# Local development
...
...
stack/boinc/instance-boinc.cfg
View file @
4bb47083
...
@@ -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}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment