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
dfab94f0
Commit
dfab94f0
authored
Feb 08, 2018
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize GenericBaseRecipe.createPythonScript API
parent
d55a5d17
Changes
55
Show whitespace changes
Inline
Side-by-side
Showing
55 changed files
with
418 additions
and
660 deletions
+418
-660
slapos/recipe/accords/__init__.py
slapos/recipe/accords/__init__.py
+2
-2
slapos/recipe/addresiliency/__init__.py
slapos/recipe/addresiliency/__init__.py
+6
-14
slapos/recipe/addresiliency/takeover.py
slapos/recipe/addresiliency/takeover.py
+0
-11
slapos/recipe/apacheperl/__init__.py
slapos/recipe/apacheperl/__init__.py
+3
-3
slapos/recipe/apachephpconfigure/__init__.py
slapos/recipe/apachephpconfigure/__init__.py
+1
-1
slapos/recipe/apachephpconfigure/runner.py
slapos/recipe/apachephpconfigure/runner.py
+9
-15
slapos/recipe/boinc/__init__.py
slapos/recipe/boinc/__init__.py
+16
-20
slapos/recipe/boinc/configure.py
slapos/recipe/boinc/configure.py
+34
-48
slapos/recipe/bonjourgrid/__init__.py
slapos/recipe/bonjourgrid/__init__.py
+8
-8
slapos/recipe/certificate_authority/__init__.py
slapos/recipe/certificate_authority/__init__.py
+10
-19
slapos/recipe/certificate_authority/certificate_authority.py
slapos/recipe/certificate_authority/certificate_authority.py
+2
-4
slapos/recipe/cloud9/__init__.py
slapos/recipe/cloud9/__init__.py
+2
-7
slapos/recipe/condor/__init__.py
slapos/recipe/condor/__init__.py
+8
-11
slapos/recipe/condor/configure.py
slapos/recipe/condor/configure.py
+9
-11
slapos/recipe/davstorage/__init__.py
slapos/recipe/davstorage/__init__.py
+5
-11
slapos/recipe/dropbear.py
slapos/recipe/dropbear.py
+7
-14
slapos/recipe/duplicity.py
slapos/recipe/duplicity.py
+2
-4
slapos/recipe/erp5_test/__init__.py
slapos/recipe/erp5_test/__init__.py
+24
-38
slapos/recipe/erp5_test/test.py
slapos/recipe/erp5_test/test.py
+8
-10
slapos/recipe/erp5testnode/__init__.py
slapos/recipe/erp5testnode/__init__.py
+7
-7
slapos/recipe/generic_cloudooo/__init__.py
slapos/recipe/generic_cloudooo/__init__.py
+1
-1
slapos/recipe/generic_mysql/__init__.py
slapos/recipe/generic_mysql/__init__.py
+13
-4
slapos/recipe/generic_mysql/innobackupex.py
slapos/recipe/generic_mysql/innobackupex.py
+2
-3
slapos/recipe/generic_mysql/mysql.py
slapos/recipe/generic_mysql/mysql.py
+2
-4
slapos/recipe/haproxy/__init__.py
slapos/recipe/haproxy/__init__.py
+4
-4
slapos/recipe/haproxy/haproxy.py
slapos/recipe/haproxy/haproxy.py
+2
-2
slapos/recipe/lamp/__init__.py
slapos/recipe/lamp/__init__.py
+3
-3
slapos/recipe/librecipe/execute.py
slapos/recipe/librecipe/execute.py
+15
-42
slapos/recipe/librecipe/generic.py
slapos/recipe/librecipe/generic.py
+14
-12
slapos/recipe/logrotate.py
slapos/recipe/logrotate.py
+3
-2
slapos/recipe/mioga/instantiate.py
slapos/recipe/mioga/instantiate.py
+9
-9
slapos/recipe/mydumper.py
slapos/recipe/mydumper.py
+5
-9
slapos/recipe/mysql/__init__.py
slapos/recipe/mysql/__init__.py
+11
-11
slapos/recipe/novnc/__init__.py
slapos/recipe/novnc/__init__.py
+6
-7
slapos/recipe/pbs.py
slapos/recipe/pbs.py
+11
-27
slapos/recipe/re6stnet/__init__.py
slapos/recipe/re6stnet/__init__.py
+6
-13
slapos/recipe/re6stnet/re6stnet.py
slapos/recipe/re6stnet/re6stnet.py
+26
-57
slapos/recipe/redis/__init__.py
slapos/recipe/redis/__init__.py
+15
-6
slapos/recipe/redis/promise.py
slapos/recipe/redis/promise.py
+0
-18
slapos/recipe/seleniumrunner/__init__.py
slapos/recipe/seleniumrunner/__init__.py
+6
-14
slapos/recipe/seleniumrunner/testrunner.py
slapos/recipe/seleniumrunner/testrunner.py
+1
-6
slapos/recipe/shell.py
slapos/recipe/shell.py
+9
-21
slapos/recipe/shellinabox.py
slapos/recipe/shellinabox.py
+14
-31
slapos/recipe/signal_wrapper.py
slapos/recipe/signal_wrapper.py
+1
-1
slapos/recipe/simplehttpserver/__init__.py
slapos/recipe/simplehttpserver/__init__.py
+3
-4
slapos/recipe/simplelogger.py
slapos/recipe/simplelogger.py
+6
-9
slapos/recipe/sphinx/__init__.py
slapos/recipe/sphinx/__init__.py
+3
-3
slapos/recipe/squid/__init__.py
slapos/recipe/squid/__init__.py
+6
-10
slapos/recipe/sshkeys_authority.py
slapos/recipe/sshkeys_authority.py
+9
-18
slapos/recipe/stunnel/__init__.py
slapos/recipe/stunnel/__init__.py
+17
-23
slapos/recipe/tidstorage/__init__.py
slapos/recipe/tidstorage/__init__.py
+6
-6
slapos/recipe/wrapper.py
slapos/recipe/wrapper.py
+12
-7
slapos/recipe/zabbixagent/__init__.py
slapos/recipe/zabbixagent/__init__.py
+6
-6
slapos/recipe/zeo/__init__.py
slapos/recipe/zeo/__init__.py
+3
-3
slapos/test/recipe/test_re6stnet.py
slapos/test/recipe/test_re6stnet.py
+5
-6
No files found.
slapos/recipe/accords/__init__.py
View file @
dfab94f0
...
@@ -91,8 +91,8 @@ class Recipe(GenericSlapRecipe):
...
@@ -91,8 +91,8 @@ class Recipe(GenericSlapRecipe):
# Generate wrapper
# Generate wrapper
wrapper_location
=
self
.
createPythonScript
(
self
.
options
[
'accords-wrapper'
],
wrapper_location
=
self
.
createPythonScript
(
self
.
options
[
'accords-wrapper'
],
'%s.accords.runAccords'
%
__name__
,
__name__
+
'.accords.runAccords'
,
parameter_dict
)
(
parameter_dict
,)
)
path_list
.
append
(
wrapper_location
)
path_list
.
append
(
wrapper_location
)
# Generate helper for debug
# Generate helper for debug
...
...
slapos/recipe/addresiliency/__init__.py
View file @
dfab94f0
...
@@ -38,26 +38,18 @@ class Recipe(GenericSlapRecipe):
...
@@ -38,26 +38,18 @@ class Recipe(GenericSlapRecipe):
"""
"""
def
_install
(
self
):
def
_install
(
self
):
path_list
=
[]
slap_connection
=
self
.
buildout
[
'slap-connection'
]
slap_connection
=
self
.
buildout
[
'slap-connection'
]
takeover_wrapper
=
self
.
createPythonScript
(
return
self
.
createPythonScript
(
name
=
self
.
options
[
'wrapper-takeover'
],
self
.
options
[
'wrapper-takeover'
],
absolute_function
=
'slapos.recipe.addresiliency.takeover.run
'
,
__name__
+
'.takeover.takeover
'
,
arguments
=
{
kw
=
{
'server_url'
:
slap_connection
[
'server-url'
],
'server_url'
:
slap_connection
[
'server-url'
],
'key_file'
:
slap_connection
.
get
(
'key-file'
),
'key_file'
:
slap_connection
.
get
(
'key-file'
),
'cert_file'
:
slap_connection
.
get
(
'cert-file'
),
'cert_file'
:
slap_connection
.
get
(
'cert-file'
),
'computer_id'
:
slap_connection
[
'computer-id'
],
'computer_
gu
id'
:
slap_connection
[
'computer-id'
],
'partition_id'
:
slap_connection
[
'partition-id'
],
'partition_id'
:
slap_connection
[
'partition-id'
],
'software'
:
slap_connection
[
'software-release-url'
],
'software
_release
'
:
slap_connection
[
'software-release-url'
],
'namebase'
:
self
.
parameter_dict
[
'namebase'
],
'namebase'
:
self
.
parameter_dict
[
'namebase'
],
'takeover_triggered_file_path'
:
self
.
options
[
'takeover-triggered-file-path'
],
'takeover_triggered_file_path'
:
self
.
options
[
'takeover-triggered-file-path'
],
})
})
path_list
.
append
(
takeover_wrapper
)
return
path_list
slapos/recipe/addresiliency/takeover.py
View file @
dfab94f0
...
@@ -78,14 +78,3 @@ def takeover(server_url, key_file, cert_file, computer_guid,
...
@@ -78,14 +78,3 @@ def takeover(server_url, key_file, cert_file, computer_guid,
# Create "lock" file preventing equeue to run import scripts
# Create "lock" file preventing equeue to run import scripts
# XXX hardcoded
# XXX hardcoded
open
(
takeover_triggered_file_path
,
'w'
).
write
(
''
)
open
(
takeover_triggered_file_path
,
'w'
).
write
(
''
)
def
run
(
args
):
slapos
.
recipe
.
addresiliency
.
takeover
.
takeover
(
server_url
=
args
.
pop
(
'server_url'
),
key_file
=
args
.
pop
(
'key_file'
),
cert_file
=
args
.
pop
(
'cert_file'
),
computer_guid
=
args
.
pop
(
'computer_id'
),
partition_id
=
args
.
pop
(
'partition_id'
),
software_release
=
args
.
pop
(
'software'
),
namebase
=
args
.
pop
(
'namebase'
),
takeover_triggered_file_path
=
args
.
pop
(
'takeover_triggered_file_path'
))
slapos/recipe/apacheperl/__init__.py
View file @
dfab94f0
...
@@ -58,9 +58,9 @@ class Recipe(GenericBaseRecipe):
...
@@ -58,9 +58,9 @@ class Recipe(GenericBaseRecipe):
path_list
.
append
(
httpd_conf
)
path_list
.
append
(
httpd_conf
)
wrapper
=
self
.
createPythonScript
(
self
.
options
[
'wrapper'
],
wrapper
=
self
.
createPythonScript
(
self
.
options
[
'wrapper'
],
'slapos.recipe.librecipe.execute.
execute
'
,
'slapos.recipe.librecipe.execute.
generic_exec
'
,
[
self
.
options
[
'httpd-binary'
],
'-f'
,
self
.
options
[
'httpd-conf'
],
((
self
.
options
[
'httpd-binary'
],
'-f'
,
self
.
options
[
'httpd-conf'
],
'-DFOREGROUND'
]
'-DFOREGROUND'
),)
)
)
path_list
.
append
(
wrapper
)
path_list
.
append
(
wrapper
)
...
...
slapos/recipe/apachephpconfigure/__init__.py
View file @
dfab94f0
...
@@ -118,7 +118,7 @@ class Recipe(GenericBaseRecipe):
...
@@ -118,7 +118,7 @@ class Recipe(GenericBaseRecipe):
configureinstall_wrapper_path
=
self
.
createPythonScript
(
configureinstall_wrapper_path
=
self
.
createPythonScript
(
self
.
options
[
'configureinstall-location'
],
self
.
options
[
'configureinstall-location'
],
__name__
+
'.runner.executeRunner'
,
__name__
+
'.runner.executeRunner'
,
[
argument
,
delete
,
rename
,
chmod
,
data
]
(
argument
,
delete
,
rename
,
chmod
,
data
)
)
)
#TODO finish to port this and remove upper one
#TODO finish to port this and remove upper one
...
...
slapos/recipe/apachephpconfigure/runner.py
View file @
dfab94f0
import
subprocess
import
subprocess
def
executeRunner
(
arg
s
):
def
executeRunner
(
arg
uments
,
delete
,
rename
,
chmod
,
data
):
"""Start the instance configure. this may run a python script, move or/and rename
"""Start the instance configure. this may run a python script, move or/and rename
file or directory when dondition is filled. the condition may be when file exist or when an entry
file or directory when dondition is filled. the condition may be when file exist or when an entry
exist into database.
exist into database.
"""
"""
arguments
,
delete
,
rename
,
chmod
,
data
=
args
if
delete
:
if
delete
!=
[]:
print
"Calling lampconfigure with 'delete' arguments"
print
"Calling lampconfigure with 'delete' arguments"
result
=
subprocess
.
Popen
(
arguments
+
delete
)
subprocess
.
call
(
arguments
+
delete
)
result
.
wait
()
if
rename
:
if
rename
!=
[]:
for
parameters
in
rename
:
for
parameters
in
rename
:
print
"Calling lampconfigure with 'rename' arguments"
print
"Calling lampconfigure with 'rename' arguments"
result
=
subprocess
.
Popen
(
arguments
+
parameters
)
subprocess
.
call
(
arguments
+
parameters
)
result
.
wait
()
if
chmod
:
if
chmod
!=
[]:
print
"Calling lampconfigure with 'chmod' arguments"
print
"Calling lampconfigure with 'chmod' arguments"
result
=
subprocess
.
Popen
(
arguments
+
chmod
)
subprocess
.
call
(
arguments
+
chmod
)
result
.
wait
()
if
data
:
if
data
!=
[]:
print
"Calling lampconfigure with 'run' arguments"
print
"Calling lampconfigure with 'run' arguments"
print
arguments
+
data
print
arguments
+
data
result
=
subprocess
.
Popen
(
arguments
+
data
)
subprocess
.
call
(
arguments
+
data
)
result
.
wait
()
return
slapos/recipe/boinc/__init__.py
View file @
dfab94f0
...
@@ -125,11 +125,15 @@ class Recipe(GenericBaseRecipe):
...
@@ -125,11 +125,15 @@ class Recipe(GenericBaseRecipe):
#Generate wrapper for php
#Generate wrapper for php
wrapperphp
=
os
.
path
.
join
(
self
.
home
,
'bin/php'
)
wrapperphp
=
os
.
path
.
join
(
self
.
home
,
'bin/php'
)
php_wrapper
=
self
.
createPythonScript
(
wrapperphp
,
php_wrapper
=
self
.
createPythonScript
(
wrapperphp
,
'slapos.recipe.librecipe.execute.
executee
'
,
'slapos.recipe.librecipe.execute.
generic_exec
'
,
(
[
self
.
phpbin
,
'-c'
,
self
.
phpini
],
os
.
environ
)
(
(
self
.
phpbin
,
'-c'
,
self
.
phpini
),
)
)
)
path_list
.
append
(
php_wrapper
)
path_list
.
append
(
php_wrapper
)
mysql_dict
=
dict
(
db
=
self
.
database
,
host
=
self
.
mysqlhost
,
port
=
self
.
mysqlport
,
user
=
self
.
username
,
passwd
=
self
.
password
)
#Generate python script for MySQL database test (starting)
#Generate python script for MySQL database test (starting)
file_status
=
os
.
path
.
join
(
self
.
home
,
'.boinc_config'
)
file_status
=
os
.
path
.
join
(
self
.
home
,
'.boinc_config'
)
if
os
.
path
.
exists
(
file_status
):
if
os
.
path
.
exists
(
file_status
):
...
@@ -137,11 +141,7 @@ class Recipe(GenericBaseRecipe):
...
@@ -137,11 +141,7 @@ class Recipe(GenericBaseRecipe):
mysql_wrapper
=
self
.
createPythonScript
(
mysql_wrapper
=
self
.
createPythonScript
(
os
.
path
.
join
(
self
.
wrapperdir
,
'start_config'
),
os
.
path
.
join
(
self
.
wrapperdir
,
'start_config'
),
'%s.configure.checkMysql'
%
__name__
,
'%s.configure.checkMysql'
%
__name__
,
dict
(
mysql_port
=
self
.
mysqlport
,
mysql_host
=
self
.
mysqlhost
,
(
environment
,
mysql_dict
,
file_status
)
mysql_user
=
self
.
username
,
mysql_password
=
self
.
password
,
database
=
self
.
database
,
file_status
=
file_status
,
environment
=
environment
)
)
)
# Generate make project wrapper file
# Generate make project wrapper file
...
@@ -164,8 +164,7 @@ class Recipe(GenericBaseRecipe):
...
@@ -164,8 +164,7 @@ class Recipe(GenericBaseRecipe):
install_wrapper
=
self
.
createPythonScript
(
install_wrapper
=
self
.
createPythonScript
(
os
.
path
.
join
(
self
.
wrapperdir
,
'make_project'
),
os
.
path
.
join
(
self
.
wrapperdir
,
'make_project'
),
'%s.configure.makeProject'
%
__name__
,
'%s.configure.makeProject'
%
__name__
,
dict
(
launch_args
=
launch_args
,
request_file
=
request_make_boinc
,
(
file_status
,
launch_args
,
request_make_boinc
,
environment
)
make_sig
=
file_status
,
env
=
environment
)
)
)
path_list
.
append
(
install_wrapper
)
path_list
.
append
(
install_wrapper
)
...
@@ -197,7 +196,7 @@ class Recipe(GenericBaseRecipe):
...
@@ -197,7 +196,7 @@ class Recipe(GenericBaseRecipe):
)
)
start_service
=
self
.
createPythonScript
(
start_service
=
self
.
createPythonScript
(
os
.
path
.
join
(
self
.
wrapperdir
,
'config_project'
),
os
.
path
.
join
(
self
.
wrapperdir
,
'config_project'
),
'%s.configure.services'
%
__name__
,
parameter
'%s.configure.services'
%
__name__
,
(
parameter
,)
)
)
path_list
.
append
(
start_service
)
path_list
.
append
(
start_service
)
...
@@ -208,14 +207,12 @@ class Recipe(GenericBaseRecipe):
...
@@ -208,14 +207,12 @@ class Recipe(GenericBaseRecipe):
os
.
unlink
(
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_dict
=
mysql_dict
,
environment
=
environment
,
mysql_user
=
self
.
username
,
mysql_password
=
self
.
password
,
database
=
self
.
database
,
environment
=
environment
,
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__
,
boinc_parameter
(
boinc_parameter
,)
)
)
path_list
.
append
(
start_wrapper
)
path_list
.
append
(
start_wrapper
)
...
@@ -362,7 +359,7 @@ class App(GenericBaseRecipe):
...
@@ -362,7 +359,7 @@ class App(GenericBaseRecipe):
)
)
deploy_app
=
self
.
createPythonScript
(
deploy_app
=
self
.
createPythonScript
(
os
.
path
.
join
(
wrapperdir
,
'boinc_%s'
%
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
)
...
@@ -404,17 +401,16 @@ class Client(GenericBaseRecipe):
...
@@ -404,17 +401,16 @@ class Client(GenericBaseRecipe):
cc_cmd
=
'--read_cc_config'
cc_cmd
=
'--read_cc_config'
cmd
=
self
.
createPythonScript
(
cmd_wrapper
,
cmd
=
self
.
createPythonScript
(
cmd_wrapper
,
'%s.configure.runCmd'
%
__name__
,
'%s.configure.runCmd'
%
__name__
,
dict
(
base_cmd
=
base_cmd
,
cc_cmd
=
cc_cmd
,
installdir
=
installdir
,
(
base_cmd
,
cc_cmd
,
installdir
,
url
,
key
)
project_url
=
url
,
key
=
key
)
)
)
path_list
.
append
(
cmd
)
path_list
.
append
(
cmd
)
#Generate BOINC client wrapper
#Generate BOINC client wrapper
boinc
=
self
.
createPythonScript
(
boinc_wrapper
,
boinc
=
self
.
createPythonScript
(
boinc_wrapper
,
'slapos.recipe.librecipe.execute.
execute
'
,
'slapos.recipe.librecipe.execute.
generic_exec
'
,
[
boincbin
,
'--allow_multiple_clients'
,
'--gui_rpc_port'
,
((
boincbin
,
'--allow_multiple_clients'
,
'--gui_rpc_port'
,
str
(
self
.
options
[
'rpc-port'
]),
'--allow_remote_gui_rpc'
,
str
(
self
.
options
[
'rpc-port'
]),
'--allow_remote_gui_rpc'
,
'--dir'
,
installdir
,
'--redirectio'
,
'--check_all_logins'
]
'--dir'
,
installdir
,
'--redirectio'
,
'--check_all_logins'
),)
)
)
path_list
.
append
(
boinc
)
path_list
.
append
(
boinc
)
...
...
slapos/recipe/boinc/configure.py
View file @
dfab94f0
...
@@ -35,27 +35,21 @@ import filecmp
...
@@ -35,27 +35,21 @@ import filecmp
from
lock_file
import
LockFile
from
lock_file
import
LockFile
def
checkMysql
(
args
):
def
checkMysql
(
environment
,
connect_kw
,
file_status
=
None
):
sys
.
path
+=
args
[
'environment'
]
[
'PYTHONPATH'
].
split
(
':'
)
sys
.
path
+=
environment
[
'PYTHONPATH'
].
split
(
':'
)
import
MySQLdb
import
MySQLdb
#Sleep until mysql server becomes available
#Sleep until mysql server becomes available
while
True
:
while
True
:
try
:
try
:
conn
=
MySQLdb
.
connect
(
host
=
args
[
'mysql_host'
],
MySQLdb
.
connect
(
**
connect_kw
).
close
()
user
=
args
[
'mysql_user'
],
port
=
int
(
args
[
'mysql_port'
]),
passwd
=
args
[
'mysql_password'
],
db
=
args
[
'database'
])
conn
.
close
()
print
"Successfully connect to MySQL database... "
if
args
.
has_key
(
'file_status'
):
writeFile
(
args
[
'file_status'
],
"starting"
)
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
)
print
"Successfully connect to MySQL database... "
if
file_status
:
writeFile
(
file_status
,
"starting"
)
def
checkFile
(
file
,
stime
):
def
checkFile
(
file
,
stime
):
"""Loop until 'file' is created (exist)"""
"""Loop until 'file' is created (exist)"""
...
@@ -70,18 +64,16 @@ def checkFile(file, stime):
...
@@ -70,18 +64,16 @@ def checkFile(file, stime):
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"""
environment
=
args
[
'environment'
]
if
args
[
'drop_install'
]:
if
args
[
'drop_install'
]:
checkFile
(
args
[
'service_status'
],
3
)
checkFile
(
args
[
'service_status'
],
3
)
else
:
else
:
checkMysql
(
args
)
checkMysql
(
environment
,
args
[
'mysql_dict'
],
args
.
get
(
'file_status'
)
)
print
"Restart Boinc..."
print
"Restart Boinc..."
env
=
os
.
environ
env
=
os
.
environ
.
copy
()
env
[
'PATH'
]
=
args
[
'environment'
][
'PATH'
]
env
.
update
(
environment
)
env
[
'PYTHONPATH'
]
=
args
[
'environment'
][
'PYTHONPATH'
]
subprocess
.
call
((
os
.
path
.
join
(
args
[
'installroot'
],
'bin'
,
'stop'
),),
env
=
env
)
binstart
=
os
.
path
.
join
(
args
[
'installroot'
],
'bin/start'
)
subprocess
.
call
((
os
.
path
.
join
(
args
[
'installroot'
],
'bin'
,
'start'
),),
env
=
env
)
binstop
=
os
.
path
.
join
(
args
[
'installroot'
],
'bin/stop'
)
os
.
system
(
binstop
)
os
.
system
(
binstart
)
writeFile
(
args
[
'start_boinc'
],
"started"
)
writeFile
(
args
[
'start_boinc'
],
"started"
)
print
"Done."
print
"Done."
...
@@ -122,17 +114,16 @@ def startProcess(launch_args, env=None, cwd=None, stdout=subprocess.PIPE):
...
@@ -122,17 +114,16 @@ def startProcess(launch_args, env=None, cwd=None, stdout=subprocess.PIPE):
return
False
return
False
return
True
return
True
def
makeProject
(
args
):
def
makeProject
(
make_sig
,
launch_args
,
request_file
,
extra_environ
):
"""Run BOINC make_project script but once only"""
"""Run BOINC make_project script but once only"""
#Wait for DateBase initialization...
#Wait for DateBase initialization...
checkFile
(
args
[
'make_sig'
]
,
3
)
checkFile
(
make_sig
,
3
)
print
"Cheking if needed to run BOINC make_project..."
print
"Cheking if needed to run BOINC make_project..."
if
os
.
path
.
exists
(
args
[
'request_file'
]):
if
os
.
path
.
exists
(
request_file
):
env
=
os
.
environ
env
=
os
.
environ
.
copy
()
env
[
'PATH'
]
=
args
[
'env'
][
'PATH'
]
env
.
update
(
extra_environ
)
env
[
'PYTHONPATH'
]
=
args
[
'env'
][
'PYTHONPATH'
]
if
startProcess
(
launch_args
,
env
=
env
):
if
startProcess
(
args
[
'launch_args'
],
env
=
env
):
os
.
unlink
(
request_file
)
os
.
unlink
(
args
[
'request_file'
])
print
"Finished running BOINC make_projet...Ending"
print
"Finished running BOINC make_projet...Ending"
else
:
else
:
print
"No new request for make_project. Exiting..."
print
"No new request for make_project. Exiting..."
...
@@ -155,9 +146,8 @@ def services(args):
...
@@ -155,9 +146,8 @@ def services(args):
return
return
print
"execute script xadd..."
print
"execute script xadd..."
env
=
os
.
environ
env
=
os
.
environ
.
copy
()
env
[
'PATH'
]
=
args
[
'environment'
][
'PATH'
]
env
.
update
(
args
[
'environment'
])
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
"Update files and directories permissions..."
print
"Update files and directories permissions..."
...
@@ -212,9 +202,8 @@ def deployManagement(args):
...
@@ -212,9 +202,8 @@ def deployManagement(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
=
os
.
environ
.
copy
()
env
[
'PATH'
]
=
args
[
'environment'
][
'PATH'
]
env
.
update
(
args
[
'environment'
])
env
[
'PYTHONPATH'
]
=
args
[
'environment'
][
'PYTHONPATH'
]
print
"setup directories..."
print
"setup directories..."
numversion
=
args
[
'version'
].
replace
(
'.'
,
''
)
numversion
=
args
[
'version'
].
replace
(
'.'
,
''
)
...
@@ -263,7 +252,7 @@ def deployManagement(args):
...
@@ -263,7 +252,7 @@ def deployManagement(args):
privateKeyFile
=
os
.
path
.
join
(
args
[
'installroot'
],
'keys/code_sign_private'
)
privateKeyFile
=
os
.
path
.
join
(
args
[
'installroot'
],
'keys/code_sign_private'
)
output
=
open
(
binary
+
'.sig'
,
'w'
)
output
=
open
(
binary
+
'.sig'
,
'w'
)
p_sign
=
subprocess
.
Popen
([
sign
,
binary
,
privateKeyFile
],
stdout
=
output
,
p_sign
=
subprocess
.
Popen
([
sign
,
binary
,
privateKeyFile
],
stdout
=
output
,
stderr
=
subprocess
.
STDOUT
)
stderr
=
subprocess
.
STDOUT
,
env
=
env
)
result
=
p_sign
.
communicate
()[
0
]
result
=
p_sign
.
communicate
()[
0
]
if
p_sign
.
returncode
is
None
or
p_sign
.
returncode
!=
0
:
if
p_sign
.
returncode
is
None
or
p_sign
.
returncode
!=
0
:
print
"Failed to execute bin/sign_executable.
\
n
The error was: %s"
%
result
print
"Failed to execute bin/sign_executable.
\
n
The error was: %s"
%
result
...
@@ -290,10 +279,8 @@ def deployManagement(args):
...
@@ -290,10 +279,8 @@ def deployManagement(args):
create_wu
(
args
,
env
)
create_wu
(
args
,
env
)
print
"Restart Boinc..."
print
"Restart Boinc..."
binstart
=
os
.
path
.
join
(
args
[
'installroot'
],
'bin/start'
)
subprocess
.
call
((
os
.
path
.
join
(
args
[
'installroot'
],
'bin'
,
'stop'
),),
env
=
env
)
binstop
=
os
.
path
.
join
(
args
[
'installroot'
],
'bin/stop'
)
subprocess
.
call
((
os
.
path
.
join
(
args
[
'installroot'
],
'bin'
,
'start'
),),
env
=
env
)
os
.
system
(
binstop
)
os
.
system
(
binstart
)
print
"Boinc Application deployment is done... writing end signal file..."
print
"Boinc Application deployment is done... writing end signal file..."
writeFile
(
token
,
str
(
args
[
'wu_number'
]))
writeFile
(
token
,
str
(
args
[
'wu_number'
]))
...
@@ -315,22 +302,21 @@ def create_wu(args, env):
...
@@ -315,22 +302,21 @@ def create_wu(args, env):
startProcess
(
launch_args
,
env
,
args
[
'installroot'
])
startProcess
(
launch_args
,
env
,
args
[
'installroot'
])
def
runCmd
(
args
):
def
runCmd
(
base_cmd
,
cc_cmd
,
installdir
,
url
,
key
):
"""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
(
installdir
,
'client_state.xml'
)
checkFile
(
client_config
,
5
)
checkFile
(
client_config
,
5
)
time
.
sleep
(
10
)
time
.
sleep
(
10
)
#Scan client state xml to find client ipv4 adress
#Scan client state xml to find client ipv4 adress
host
=
re
.
search
(
"<ip_addr>([
\
w
\
d
\
.:]+)</ip_
a
ddr>"
,
host
=
re
.
search
(
"<ip_addr>([
\
w
\
d
\
.:]+)</ip_
a
ddr>"
,
open
(
client_config
,
'r'
).
read
()).
group
(
1
)
open
(
client_config
,
'r'
).
read
()).
group
(
1
)
args
[
'base_cmd'
][
2
]
=
host
+
':'
+
args
[
'base_cmd'
][
2
]
base_cmd
[
2
]
=
host
+
':'
+
base_cmd
[
2
]
print
"Run boinccmd with host at %s "
%
args
[
'base_cmd'
][
2
]
print
"Run boinccmd with host at %s "
%
base_cmd
[
2
]
project_args
=
args
[
'base_cmd'
]
+
[
'--project_attach'
,
args
[
'project_url'
],
project_args
=
base_cmd
+
[
'--project_attach'
,
url
,
key
]
args
[
'key'
]]
startProcess
(
project_args
,
cwd
=
installdir
)
startProcess
(
project_args
,
cwd
=
args
[
'installdir'
])
if
cc_cmd
:
if
args
[
'cc_cmd'
]
!=
''
:
#Load or reload cc_config file
#Load or reload cc_config file
startProcess
(
args
[
'base_cmd'
]
+
[
args
[
'cc_cmd'
]],
cwd
=
args
[
'installdir'
]
)
startProcess
(
base_cmd
+
[
cc_cmd
],
cwd
=
installdir
)
def
writeFile
(
file
,
content
):
def
writeFile
(
file
,
content
):
...
...
slapos/recipe/bonjourgrid/__init__.py
View file @
dfab94f0
...
@@ -62,8 +62,8 @@ class Recipe(GenericBaseRecipe):
...
@@ -62,8 +62,8 @@ class Recipe(GenericBaseRecipe):
condor_wrapper_list
=
condor_wrapper_list
,
condor_wrapper_list
=
condor_wrapper_list
,
boinc_wrapper_list
=
boinc_wrapper_list
)
boinc_wrapper_list
=
boinc_wrapper_list
)
bonjourGrid_wrapper
=
self
.
createPythonScript
(
grid_wrapper
,
bonjourGrid_wrapper
=
self
.
createPythonScript
(
grid_wrapper
,
'%s.configure.launchScript'
%
__name__
,
__name__
+
'.configure.launchScript'
,
parameters
(
parameters
,)
)
)
path_list
.
append
(
bonjourGrid_wrapper
)
path_list
.
append
(
bonjourGrid_wrapper
)
...
@@ -74,15 +74,15 @@ class Recipe(GenericBaseRecipe):
...
@@ -74,15 +74,15 @@ class Recipe(GenericBaseRecipe):
log
=
self
.
options
[
'log_file'
].
strip
()
log
=
self
.
options
[
'log_file'
].
strip
()
pid_file
=
self
.
options
[
'pid_file'
].
strip
()
pid_file
=
self
.
options
[
'pid_file'
].
strip
()
wrapper
=
self
.
createPythonScript
(
bg_wrapper
,
wrapper
=
self
.
createPythonScript
(
bg_wrapper
,
'slapos.recipe.librecipe.execute.
execute
'
,
'slapos.recipe.librecipe.execute.
generic_exec
'
,
(
[
python
,
bonjourgrid_master
,
'--log_file'
,
log
,
(
(
python
,
bonjourgrid_master
,
'--log_file'
,
log
,
'--pid_file'
,
pid_file
,
'--pid_file'
,
pid_file
,
'--master_wrapper'
,
grid_wrapper
,
'--master_wrapper'
,
grid_wrapper
,
'--directory'
,
self
.
options
[
'work_dir'
].
strip
(),
'--directory'
,
self
.
options
[
'work_dir'
].
strip
(),
'--server'
,
self
.
options
[
'redis-url'
].
strip
(),
'--server'
,
self
.
options
[
'redis-url'
].
strip
(),
'--port'
,
self
.
options
[
'redis-port'
].
strip
(),
'--port'
,
self
.
options
[
'redis-port'
].
strip
(),
'--num_workers'
,
self
.
options
[
'nworkers'
].
strip
(),
'--num_workers'
,
self
.
options
[
'nworkers'
].
strip
(),
]
)
),
)
)
)
path_list
.
append
(
wrapper
)
path_list
.
append
(
wrapper
)
...
@@ -114,8 +114,8 @@ class Client(GenericBaseRecipe):
...
@@ -114,8 +114,8 @@ class Client(GenericBaseRecipe):
log
=
self
.
options
[
'log_file'
].
strip
()
log
=
self
.
options
[
'log_file'
].
strip
()
pid_file
=
self
.
options
[
'pid_file'
].
strip
()
pid_file
=
self
.
options
[
'pid_file'
].
strip
()
wrapper
=
self
.
createPythonScript
(
bg_wrapper
,
wrapper
=
self
.
createPythonScript
(
bg_wrapper
,
'slapos.recipe.librecipe.execute.
execute
'
,
'slapos.recipe.librecipe.execute.
generic_exec
'
,
(
[
python
,
bonjourgrid_client
,
'--log_file'
,
log
,
(
(
python
,
bonjourgrid_client
,
'--log_file'
,
log
,
'--pid_file'
,
pid_file
,
'--pid_file'
,
pid_file
,
'--boinc_wrapper'
,
boinc_script
,
'--boinc_wrapper'
,
boinc_script
,
'--condor_wrapper'
,
condor_script
,
'--condor_wrapper'
,
condor_script
,
...
@@ -123,7 +123,7 @@ class Client(GenericBaseRecipe):
...
@@ -123,7 +123,7 @@ class Client(GenericBaseRecipe):
'--install_directory'
,
self
.
options
[
'install_dir'
].
strip
(),
'--install_directory'
,
self
.
options
[
'install_dir'
].
strip
(),
'--server'
,
self
.
options
[
'redis-url'
].
strip
(),
'--server'
,
self
.
options
[
'redis-url'
].
strip
(),
'--port'
,
self
.
options
[
'redis-port'
].
strip
(),
'--port'
,
self
.
options
[
'redis-port'
].
strip
(),
]
)
),
)
)
)
path_list
.
append
(
wrapper
)
path_list
.
append
(
wrapper
)
...
...
slapos/recipe/certificate_authority/__init__.py
View file @
dfab94f0
...
@@ -40,13 +40,10 @@ class Recipe(GenericBaseRecipe):
...
@@ -40,13 +40,10 @@ class Recipe(GenericBaseRecipe):
self
.
ca_private
=
self
.
options
[
'ca-private'
]
self
.
ca_private
=
self
.
options
[
'ca-private'
]
self
.
ca_certs
=
self
.
options
[
'ca-certs'
]
self
.
ca_certs
=
self
.
options
[
'ca-certs'
]
self
.
ca_newcerts
=
self
.
options
[
'ca-newcerts'
]
self
.
ca_newcerts
=
self
.
options
[
'ca-newcerts'
]
self
.
ca_crl
=
self
.
options
[
'ca-crl'
]
self
.
ca_key_ext
=
'.key'
self
.
ca_key_ext
=
'.key'
self
.
ca_crt_ext
=
'.crt'
self
.
ca_crt_ext
=
'.crt'
def
install
(
self
):
def
install
(
self
):
path_list
=
[]
ca_country_code
=
self
.
options
.
get
(
'country-code'
,
'XX'
)
ca_country_code
=
self
.
options
.
get
(
'country-code'
,
'XX'
)
ca_email
=
self
.
options
.
get
(
'email'
,
'xx@example.com'
)
ca_email
=
self
.
options
.
get
(
'email'
,
'xx@example.com'
)
# XXX-BBB: State by mistake has been configured as string "('State',)"
# XXX-BBB: State by mistake has been configured as string "('State',)"
...
@@ -77,21 +74,15 @@ class Recipe(GenericBaseRecipe):
...
@@ -77,21 +74,15 @@ class Recipe(GenericBaseRecipe):
self
.
createFile
(
openssl_configuration
,
self
.
substituteTemplate
(
self
.
createFile
(
openssl_configuration
,
self
.
substituteTemplate
(
self
.
getTemplateFilename
(
'openssl.cnf.ca.in'
),
config
))
self
.
getTemplateFilename
(
'openssl.cnf.ca.in'
),
config
))
ca_wrapper
=
self
.
createPythonScript
(
return
self
.
createPythonScript
(
self
.
options
[
'wrapper'
],
self
.
options
[
'wrapper'
],
'%s.certificate_authority.runCertificateAuthority'
%
__name__
,
__name__
+
'.certificate_authority.runCertificateAuthority'
,
dict
(
(
os
.
path
.
join
(
self
.
ca_private
,
'cakey.pem'
),
openssl_configuration
=
openssl_configuration
,
os
.
path
.
join
(
self
.
ca_dir
,
'cacert.pem'
),
openssl_binary
=
self
.
options
[
'openssl-binary'
],
self
.
options
[
'openssl-binary'
],
certificate
=
os
.
path
.
join
(
self
.
ca_dir
,
'cacert.pem'
),
openssl_configuration
,
key
=
os
.
path
.
join
(
self
.
ca_private
,
'cakey.pem'
),
self
.
request_directory
)
crl
=
self
.
ca_crl
,
request_dir
=
self
.
request_directory
)
)
)
path_list
.
append
(
ca_wrapper
)
return
path_list
class
Request
(
Recipe
):
class
Request
(
Recipe
):
...
@@ -148,9 +139,9 @@ class Request(Recipe):
...
@@ -148,9 +139,9 @@ class Request(Recipe):
if
request_needed
:
if
request_needed
:
wrapper
=
self
.
createPythonScript
(
wrapper
=
self
.
createPythonScript
(
self
.
options
[
'wrapper'
],
self
.
options
[
'wrapper'
],
'slapos.recipe.librecipe.execute.
execute_wait
'
,
'slapos.recipe.librecipe.execute.
generic_exec
'
,
[
[
self
.
options
[
'executable'
]]
,
((
self
.
options
[
'executable'
],),)
,
[
certificate
,
key
]
]
,
{
'wait_list'
:
(
certificate
,
key
)}
,
)
)
path_list
.
append
(
wrapper
)
path_list
.
append
(
wrapper
)
...
...
slapos/recipe/certificate_authority/certificate_authority.py
View file @
dfab94f0
...
@@ -102,10 +102,8 @@ class CertificateAuthority:
...
@@ -102,10 +102,8 @@ class CertificateAuthority:
'certificate_file'
)):
'certificate_file'
)):
print
'Created certificate %r'
%
parser
.
get
(
'certificate'
,
'name'
)
print
'Created certificate %r'
%
parser
.
get
(
'certificate'
,
'name'
)
def
runCertificateAuthority
(
ca_conf
):
def
runCertificateAuthority
(
*
args
):
ca
=
CertificateAuthority
(
ca_conf
[
'key'
],
ca_conf
[
'certificate'
],
ca
=
CertificateAuthority
(
*
args
)
ca_conf
[
'openssl_binary'
],
ca_conf
[
'openssl_configuration'
],
ca_conf
[
'request_dir'
])
while
True
:
while
True
:
ca
.
checkAuthority
()
ca
.
checkAuthority
()
ca
.
checkRequestDir
()
ca
.
checkRequestDir
()
...
...
slapos/recipe/cloud9/__init__.py
View file @
dfab94f0
...
@@ -42,8 +42,6 @@ class Recipe(GenericBaseRecipe):
...
@@ -42,8 +42,6 @@ class Recipe(GenericBaseRecipe):
options
[
'access-url'
]
=
'http://[%s]:%s'
%
(
self
.
ip
,
self
.
port
)
options
[
'access-url'
]
=
'http://[%s]:%s'
%
(
self
.
ip
,
self
.
port
)
def
install
(
self
):
def
install
(
self
):
path_list
=
[]
environment
=
{
environment
=
{
'PATH'
:
os
.
path
.
dirname
(
self
.
git
)
+
':'
+
os
.
environ
[
'PATH'
],
'PATH'
:
os
.
path
.
dirname
(
self
.
git
)
+
':'
+
os
.
environ
[
'PATH'
],
}
}
...
@@ -51,10 +49,7 @@ class Recipe(GenericBaseRecipe):
...
@@ -51,10 +49,7 @@ class Recipe(GenericBaseRecipe):
cloud9_args
=
[
self
.
node_executable
,
self
.
cloud9
,
'-l'
,
self
.
ip
,
'-p'
,
cloud9_args
=
[
self
.
node_executable
,
self
.
cloud9
,
'-l'
,
self
.
ip
,
'-p'
,
self
.
port
,
'-w'
,
self
.
workdir
]
self
.
port
,
'-w'
,
self
.
workdir
]
wrapper
=
self
.
createPythonScript
(
self
.
wrapper
,
return
self
.
createPythonScript
(
self
.
wrapper
,
'slapos.recipe.librecipe.execute.
executee
'
,
'slapos.recipe.librecipe.execute.
generic_exec
'
,
(
cloud9_args
,
environment
)
(
cloud9_args
,
environment
)
)
)
path_list
.
append
(
wrapper
)
return
path_list
slapos/recipe/condor/__init__.py
View file @
dfab94f0
...
@@ -178,12 +178,11 @@ class Recipe(GenericBaseRecipe):
...
@@ -178,12 +178,11 @@ class Recipe(GenericBaseRecipe):
os
.
chmod
(
wrapper_location
,
0744
)
os
.
chmod
(
wrapper_location
,
0744
)
#generate script for start condor
#generate script for start condor
start_condor
=
os
.
path
.
join
(
self
.
wrapperdir
,
'start_condor'
)
wrapper
=
self
.
createPythonScript
(
start_bin
=
os
.
path
.
join
(
self
.
wrapper_sbin
,
'condor_master'
)
os
.
path
.
join
(
self
.
wrapperdir
,
'start_condor'
),
condor_reconfig
=
os
.
path
.
join
(
self
.
wrapper_sbin
,
'condor_reconfig'
)
__name__
+
'.configure.condorStart'
,
wrapper
=
self
.
createPythonScript
(
start_condor
,
(
os
.
path
.
join
(
self
.
wrapper_sbin
,
'condor_reconfig'
),
'%s.configure.condorStart'
%
__name__
,
os
.
path
.
join
(
self
.
wrapper_sbin
,
'condor_master'
))
dict
(
start_bin
=
start_bin
,
condor_reconfig
=
condor_reconfig
)
)
)
path_list
.
append
(
wrapper
)
path_list
.
append
(
wrapper
)
return
path_list
return
path_list
...
@@ -276,13 +275,11 @@ class AppSubmit(GenericBaseRecipe):
...
@@ -276,13 +275,11 @@ class AppSubmit(GenericBaseRecipe):
os
.
unlink
(
destination
)
os
.
unlink
(
destination
)
os
.
symlink
(
app_list
[
appname
][
'files'
][
file
],
destination
)
os
.
symlink
(
app_list
[
appname
][
'files'
][
file
],
destination
)
#generate wrapper for submitting job
#generate wrapper for submitting job
condor_submit
=
os
.
path
.
join
(
self
.
options
[
'bin'
].
strip
(),
'condor_submit'
)
parameter
=
dict
(
submit
=
condor_submit
,
sig_install
=
sig_install
,
submit_file
=
'submit'
,
appname
=
appname
,
appdir
=
appdir
)
submit_job
=
self
.
createPythonScript
(
submit_job
=
self
.
createPythonScript
(
os
.
path
.
join
(
self
.
options
[
'wrapper-dir'
].
strip
(),
appname
),
os
.
path
.
join
(
self
.
options
[
'wrapper-dir'
].
strip
(),
appname
),
'%s.configure.submitJob'
%
__name__
,
parameter
__name__
+
'.configure.submitJob'
,
(
os
.
path
.
join
(
self
.
options
[
'bin'
].
strip
(),
'condor_submit'
),
'submit'
,
appdir
,
appname
,
sig_install
)
)
)
path_list
.
append
(
submit_job
)
path_list
.
append
(
submit_job
)
return
path_list
return
path_list
\ No newline at end of file
slapos/recipe/condor/configure.py
View file @
dfab94f0
...
@@ -29,27 +29,25 @@ import os
...
@@ -29,27 +29,25 @@ import os
import
subprocess
import
subprocess
import
time
import
time
def
submitJob
(
args
):
def
submitJob
(
submit
,
submit_file
,
appdir
,
appname
,
sig_install
):
"""Run condor_submit (if needed) for job deployment"""
"""Run condor_submit (if needed) for job deployment"""
time
.
sleep
(
10
)
time
.
sleep
(
10
)
print
"Check if needed to submit %s job's"
%
a
rgs
[
'appname'
]
print
"Check if needed to submit %s job's"
%
a
ppname
if
not
os
.
path
.
exists
(
args
[
'sig_install'
]
):
if
not
os
.
path
.
exists
(
sig_install
):
print
"Nothing for install or update...Exited"
print
"Nothing for install or update...Exited"
return
return
# '-a', "log = out.log", '-a', "error = error.log",
# '-a', "log = out.log", '-a', "error = error.log",
launch_args
=
[
args
[
'submit'
],
'-verbose'
,
args
[
'submit_file'
]]
launch_args
=
submit
,
'-verbose'
,
submit_file
process
=
subprocess
.
Popen
(
launch_args
,
stdout
=
subprocess
.
PIPE
,
process
=
subprocess
.
Popen
(
launch_args
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
,
cwd
=
a
rgs
[
'appdir'
]
)
stderr
=
subprocess
.
STDOUT
,
cwd
=
a
ppdir
)
result
=
process
.
communicate
()[
0
]
result
=
process
.
communicate
()[
0
]
if
process
.
returncode
is
None
or
process
.
returncode
!=
0
:
if
process
.
returncode
is
None
or
process
.
returncode
!=
0
:
print
"Failed to execute condor_submit.
\
n
The error was: %s"
%
result
print
"Failed to execute condor_submit.
\
n
The error was: %s"
%
result
else
:
else
:
os
.
unlink
(
args
[
'sig_install'
]
)
os
.
unlink
(
sig_install
)
def
condorStart
(
args
):
def
condorStart
(
condor_reconfig
,
start_bin
):
"""Start Condor if deamons is currently stopped"""
"""Start Condor if deamons is currently stopped"""
result
=
os
.
system
(
args
[
'condor_reconfig'
])
if
subprocess
.
call
(
condor_reconfig
):
if
result
!=
0
:
#process failled to reconfig condor that mean that condor deamons is not curently started
#process failled to reconfig condor that mean that condor deamons is not curently started
os
.
system
(
args
[
'start_bin'
])
subprocess
.
call
(
start_bin
)
\ No newline at end of file
slapos/recipe/davstorage/__init__.py
View file @
dfab94f0
...
@@ -99,25 +99,19 @@ class Recipe(GenericBaseRecipe):
...
@@ -99,25 +99,19 @@ class Recipe(GenericBaseRecipe):
path_list
.
append
(
config_file
)
path_list
.
append
(
config_file
)
wrapper
=
self
.
createPythonScript
(
self
.
options
[
'wrapper'
],
wrapper
=
self
.
createPythonScript
(
self
.
options
[
'wrapper'
],
'slapos.recipe.librecipe.execute.
execute
'
,
'slapos.recipe.librecipe.execute.
generic_exec
'
,
[
self
.
options
[
'apache-binary'
],
'-f'
,
config_file
,
'-DFOREGROUND'
]
)
((
self
.
options
[
'apache-binary'
],
'-f'
,
config_file
,
'-DFOREGROUND'
),)
)
path_list
.
append
(
wrapper
)
path_list
.
append
(
wrapper
)
promise
=
self
.
createPythonScript
(
self
.
options
[
'promise'
],
promise
=
self
.
createPythonScript
(
self
.
options
[
'promise'
],
__name__
+
'.promise'
,
__name__
+
'.promise'
,
dict
(
host
=
self
.
options
[
'ip'
],
port
=
int
(
self
.
options
[
'port_webdav'
]),
(
self
.
options
[
'ip'
],
int
(
self
.
options
[
'port_webdav'
]),
user
=
self
.
options
[
'user'
],
password
=
self
.
options
[
'password'
])
self
.
options
[
'user'
],
self
.
options
[
'password'
]))
)
path_list
.
append
(
promise
)
path_list
.
append
(
promise
)
return
path_list
return
path_list
def
promise
(
args
):
def
promise
(
host
,
port
,
user
,
password
):
host
=
args
[
'host'
]
port
=
args
[
'port'
]
user
=
args
[
'user'
]
password
=
args
[
'password'
]
connection
=
httplib
.
HTTPSConnection
(
host
,
port
)
connection
=
httplib
.
HTTPSConnection
(
host
,
port
)
auth
=
base64
.
b64encode
(
'%s:%s'
%
(
user
,
password
))
auth
=
base64
.
b64encode
(
'%s:%s'
%
(
user
,
password
))
connection
.
request
(
'OPTIONS'
,
'/'
,
connection
.
request
(
'OPTIONS'
,
'/'
,
...
...
slapos/recipe/dropbear.py
View file @
dfab94f0
...
@@ -57,8 +57,6 @@ class KnownHostsFile(dict):
...
@@ -57,8 +57,6 @@ class KnownHostsFile(dict):
class
Recipe
(
GenericBaseRecipe
):
class
Recipe
(
GenericBaseRecipe
):
def
install
(
self
):
def
install
(
self
):
path_list
=
[]
dropbear_cmd
=
[
self
.
options
[
'dropbear-binary'
]]
dropbear_cmd
=
[
self
.
options
[
'dropbear-binary'
]]
# Don't fork into background
# Don't fork into background
dropbear_cmd
.
append
(
'-F'
)
dropbear_cmd
.
append
(
'-F'
)
...
@@ -95,19 +93,16 @@ class Recipe(GenericBaseRecipe):
...
@@ -95,19 +93,16 @@ class Recipe(GenericBaseRecipe):
if
'shell'
in
self
.
options
:
if
'shell'
in
self
.
options
:
env
[
'DROPBEAR_OVERRIDE_SHELL'
]
=
self
.
options
[
'shell'
]
env
[
'DROPBEAR_OVERRIDE_SHELL'
]
=
self
.
options
[
'shell'
]
wrapper
=
self
.
createPythonScript
(
return
self
.
createPythonScript
(
self
.
options
[
'wrapper'
],
self
.
options
[
'wrapper'
],
'slapos.recipe.librecipe.execute.
executee
'
,
'slapos.recipe.librecipe.execute.
generic_exec
'
,
(
dropbear_cmd
,
env
,
)
(
dropbear_cmd
,
env
)
)
)
path_list
.
append
(
wrapper
)
return
path_list
class
Client
(
GenericBaseRecipe
):
class
Client
(
GenericBaseRecipe
):
def
install
(
self
):
def
install
(
self
):
env
=
dict
()
env
=
{}
if
'home'
in
self
.
options
:
if
'home'
in
self
.
options
:
env
[
'HOME'
]
=
self
.
options
[
'home'
]
env
[
'HOME'
]
=
self
.
options
[
'home'
]
...
@@ -120,14 +115,12 @@ class Client(GenericBaseRecipe):
...
@@ -120,14 +115,12 @@ class Client(GenericBaseRecipe):
if
'identity-file'
in
self
.
options
:
if
'identity-file'
in
self
.
options
:
dropbear_cmd
.
extend
([
'-i'
,
self
.
options
[
'identity-file'
]])
dropbear_cmd
.
extend
([
'-i'
,
self
.
options
[
'identity-file'
]])
wrapper
=
self
.
createPythonScript
(
return
self
.
createPythonScript
(
self
.
options
[
'wrapper'
],
self
.
options
[
'wrapper'
],
'slapos.recipe.librecipe.execute.
executee
'
,
'slapos.recipe.librecipe.execute.
generic_exec
'
,
(
dropbear_cmd
,
env
,
)
(
dropbear_cmd
,
env
)
)
)
return
[
wrapper
]
class
AddAuthorizedKey
(
GenericBaseRecipe
):
class
AddAuthorizedKey
(
GenericBaseRecipe
):
...
...
slapos/recipe/duplicity.py
View file @
dfab94f0
...
@@ -46,7 +46,5 @@ class Recipe(GenericBaseRecipe):
...
@@ -46,7 +46,5 @@ class Recipe(GenericBaseRecipe):
cmd
.
extend
(
options
)
cmd
.
extend
(
options
)
cmd
.
extend
([
backup_directory
,
remote_url
])
cmd
.
extend
([
backup_directory
,
remote_url
])
wrapper
=
self
.
createPythonScript
(
self
.
options
[
'wrapper'
],
return
self
.
createPythonScript
(
self
.
options
[
'wrapper'
],
'slapos.recipe.librecipe.execute.execute'
,
cmd
)
'slapos.recipe.librecipe.execute.generic_exec'
,
(
cmd
,))
return
[
wrapper
]
slapos/recipe/erp5_test/__init__.py
View file @
dfab94f0
...
@@ -67,7 +67,7 @@ class Recipe(GenericBaseRecipe):
...
@@ -67,7 +67,7 @@ class Recipe(GenericBaseRecipe):
openssl_binary
=
self
.
options
[
'openssl-binary'
],
openssl_binary
=
self
.
options
[
'openssl-binary'
],
test_ca_path
=
self
.
options
[
'certificate-authority-path'
],
test_ca_path
=
self
.
options
[
'certificate-authority-path'
],
)
)
common_list
=
[
common_list
=
(
'--conversion_server_url='
+
cloudooo_url
,
'--conversion_server_url='
+
cloudooo_url
,
# BBB: We still have test suites that only accept the following 2 options.
# BBB: We still have test suites that only accept the following 2 options.
'--conversion_server_hostname=%s'
%
cloudooo_parsed
.
hostname
,
'--conversion_server_hostname=%s'
%
cloudooo_parsed
.
hostname
,
...
@@ -76,19 +76,19 @@ class Recipe(GenericBaseRecipe):
...
@@ -76,19 +76,19 @@ class Recipe(GenericBaseRecipe):
'--volatile_memcached_server_port=%s'
%
memcached_parsed
.
port
,
'--volatile_memcached_server_port=%s'
%
memcached_parsed
.
port
,
'--persistent_memcached_server_hostname=%s'
%
kumofs_parsed
.
hostname
,
'--persistent_memcached_server_hostname=%s'
%
kumofs_parsed
.
hostname
,
'--persistent_memcached_server_port=%s'
%
kumofs_parsed
.
port
,
'--persistent_memcached_server_port=%s'
%
kumofs_parsed
.
port
,
]
)
path_list
.
append
(
self
.
createPythonScript
(
self
.
options
[
'run-unit-test'
],
path_list
.
append
(
self
.
createPythonScript
(
self
.
options
[
'run-unit-test'
],
__name__
+
'.test.runUnitTest'
,
[
dict
(
__name__
+
'.test.runUnitTest'
,
call_list
=
[
self
.
options
[
'run-unit-test-binary'
],
((
self
.
options
[
'run-unit-test-binary'
],
'--erp5_sql_connection_string'
,
mysql_connection_string
,
'--erp5_sql_connection_string'
,
mysql_connection_string
,
'--extra_sql_connection_string_list'
,
','
.
join
(
'--extra_sql_connection_string_list'
,
','
.
join
(
mysql_connection_string_list
),
mysql_connection_string_list
),
]
+
common_list
,
**
common_dict
)]
))
)
+
common_list
,
common_dict
)
))
path_list
.
append
(
self
.
createPythonScript
(
self
.
options
[
'run-test-suite'
],
path_list
.
append
(
self
.
createPythonScript
(
self
.
options
[
'run-test-suite'
],
__name__
+
'.test.runTestSuite'
,
[
dict
(
__name__
+
'.test.runTestSuite'
,
call_list
=
[
self
.
options
[
'run-test-suite-binary'
],
((
self
.
options
[
'run-test-suite-binary'
],
'--db_list'
,
','
.
join
(
mysql_connection_string_list
),
'--db_list'
,
','
.
join
(
mysql_connection_string_list
),
]
+
common_list
,
**
common_dict
)]
))
)
+
common_list
,
common_dict
)
))
return
path_list
return
path_list
...
@@ -98,20 +98,18 @@ class CloudoooRecipe(GenericBaseRecipe):
...
@@ -98,20 +98,18 @@ class CloudoooRecipe(GenericBaseRecipe):
common_dict
=
dict
(
common_dict
=
dict
(
prepend_path
=
self
.
options
[
'prepend-path'
],
prepend_path
=
self
.
options
[
'prepend-path'
],
)
)
common_list
=
[
common_list
=
(
"--paster_path"
,
self
.
options
[
'ooo-paster'
],
"--paster_path"
,
self
.
options
[
'ooo-paster'
],
self
.
options
[
'configuration-file'
]
self
.
options
[
'configuration-file'
]
]
)
run_unit_test_path
=
self
.
createPythonScript
(
self
.
options
[
'run-unit-test'
],
path_list
.
append
(
self
.
createPythonScript
(
self
.
options
[
'run-unit-test'
],
__name__
+
'.test.runUnitTest'
,
[
dict
(
__name__
+
'.test.runUnitTest'
,
call_list
=
[
self
.
options
[
'run-unit-test-binary'
],
((
self
.
options
[
'run-unit-test-binary'
],
]
+
common_list
,
**
common_dict
)])
)
+
common_list
,
common_dict
)))
path_list
.
append
(
run_unit_test_path
)
path_list
.
append
(
self
.
createPythonScript
(
self
.
options
[
'run-test-suite'
],
path_list
.
append
(
self
.
createPythonScript
(
self
.
options
[
'run-test-suite'
],
__name__
+
'.test.runTestSuite'
,
[
dict
(
__name__
+
'.test.runTestSuite'
,
call_list
=
[
self
.
options
[
'run-test-suite-binary'
],
((
self
.
options
[
'run-test-suite-binary'
],
],
**
common_dict
)]
))
),
common_dict
)
))
return
path_list
return
path_list
...
@@ -121,32 +119,20 @@ class EggTestRecipe(GenericBaseRecipe):
...
@@ -121,32 +119,20 @@ class EggTestRecipe(GenericBaseRecipe):
off a list of Python eggs.
off a list of Python eggs.
"""
"""
def
install
(
self
):
def
install
(
self
):
path_list
=
[]
test_list
=
self
.
options
[
'test-list'
].
strip
().
replace
(
'
\
n
'
,
','
)
test_list
=
self
.
options
[
'test-list'
].
strip
().
replace
(
'
\
n
'
,
','
)
common_dict
=
{}
environment
_dict
=
{}
common
_dict
=
{}
if
self
.
options
.
get
(
'environment'
):
if
self
.
options
.
get
(
'environment'
):
environment_part
=
self
.
buildout
.
get
(
self
.
options
[
'environment'
])
environment_part
=
self
.
buildout
.
get
(
self
.
options
[
'environment'
])
if
environment_part
:
if
environment_part
:
for
key
,
value
in
environment_part
.
iteritems
():
common_dict
[
'environment'
]
=
dict
(
environment_part
)
environment_dict
[
key
]
=
value
common_list
=
[
"--source_code_path_list"
,
test_list
]
argument_dict
=
dict
(
call_list
=
[
self
.
options
[
'run-test-suite-binary'
],]
+
common_list
,
environment
=
environment_dict
,
**
common_dict
)
if
'prepend-path'
in
self
.
options
:
if
'prepend-path'
in
self
.
options
:
argument
_dict
[
'prepend_path'
]
=
self
.
options
[
'prepend-path'
]
common
_dict
[
'prepend_path'
]
=
self
.
options
[
'prepend-path'
]
r
un_test_suite_script
=
self
.
createPythonScript
(
r
eturn
self
.
createPythonScript
(
self
.
options
[
'run-test-suite'
],
__name__
+
'.test.runTestSuite'
,
self
.
options
[
'run-test-suite'
],
__name__
+
'.test.runTestSuite'
,
[
argument_dict
]
((
self
.
options
[
'run-test-suite-binary'
],
"--source_code_path_list"
,
test_list
),
common_dict
)
)
)
path_list
.
append
(
run_test_suite_script
)
return
path_list
slapos/recipe/erp5_test/test.py
View file @
dfab94f0
...
@@ -26,9 +26,9 @@
...
@@ -26,9 +26,9 @@
##############################################################################
##############################################################################
import
os
import
os
import
sys
import
sys
def
runTestSuite
(
args
):
def
runTestSuite
(
args
,
d
):
env
=
os
.
environ
.
copy
()
env
=
os
.
environ
.
copy
()
d
=
args
[
0
]
if
'openssl_binary'
in
d
:
if
'openssl_binary'
in
d
:
env
[
'OPENSSL_BINARY'
]
=
d
[
'openssl_binary'
]
env
[
'OPENSSL_BINARY'
]
=
d
[
'openssl_binary'
]
if
'test_ca_path'
in
d
:
if
'test_ca_path'
in
d
:
...
@@ -47,17 +47,15 @@ def runTestSuite(args):
...
@@ -47,17 +47,15 @@ def runTestSuite(args):
env
.
update
(
d
[
'environment'
])
env
.
update
(
d
[
'environment'
])
# Deal with Shebang size limitation
# Deal with Shebang size limitation
executable_filepath
=
d
[
'call_list'
][
0
]
executable_filepath
=
args
[
0
]
file_object
=
open
(
executable_filepath
,
'r'
)
with
open
(
executable_filepath
,
'r'
)
as
f
:
line
=
file_object
.
readline
()
line
=
f
.
readline
()
file_object
.
close
()
argument_list
=
[]
argument_list
=
[]
if
line
[:
2
]
==
'#!'
:
if
line
[:
2
]
==
'#!'
:
executable_filepath
=
line
[
2
:].
strip
()
executable_filepath
=
line
[
2
:].
strip
()
argument_list
.
append
(
executable_filepath
)
argument_list
.
append
(
executable_filepath
)
argument_list
.
extend
(
d
[
'call_list'
])
argument_list
+=
args
argument_list
.
extend
(
sys
.
argv
[
1
:])
argument_list
+=
sys
.
argv
[
1
:]
argument_list
.
append
(
env
)
os
.
execve
(
executable_filepath
,
argument_list
,
env
)
os
.
execle
(
executable_filepath
,
*
argument_list
)
runUnitTest
=
runTestSuite
runUnitTest
=
runTestSuite
slapos/recipe/erp5testnode/__init__.py
View file @
dfab94f0
...
@@ -70,15 +70,15 @@ class Recipe(GenericBaseRecipe):
...
@@ -70,15 +70,15 @@ class Recipe(GenericBaseRecipe):
self
.
path_list
.
append
(
self
.
path_list
.
append
(
self
.
createPythonScript
(
self
.
createPythonScript
(
self
.
options
[
'wrapper'
],
self
.
options
[
'wrapper'
],
'slapos.recipe.librecipe.execute.
executee
'
,
'slapos.recipe.librecipe.execute.
generic_exec
'
,
[
# Executable
(
# Command
[
self
.
options
[
'testnode'
],
'-l'
,
self
.
options
[
'log-file'
],
(
self
.
options
[
'testnode'
],
'-l'
,
self
.
options
[
'log-file'
],
configuration_file
]
,
configuration_file
)
,
# Environment
# Environment
{
{
'GIT_SSL_NO_VERIFY'
:
'1'
,
'GIT_SSL_NO_VERIFY'
:
'1'
,
}
}
]
,
)
,
)
)
)
)
self
.
installApache
()
self
.
installApache
()
...
@@ -107,8 +107,8 @@ class Recipe(GenericBaseRecipe):
...
@@ -107,8 +107,8 @@ class Recipe(GenericBaseRecipe):
)
)
self
.
path_list
.
append
(
config_file
)
self
.
path_list
.
append
(
config_file
)
wrapper
=
self
.
createPythonScript
(
self
.
options
[
'httpd-wrapper'
],
wrapper
=
self
.
createPythonScript
(
self
.
options
[
'httpd-wrapper'
],
'slapos.recipe.librecipe.execute.
execute
'
,
'slapos.recipe.librecipe.execute.
generic_exec
'
,
[
self
.
options
[
'apache-binary'
],
'-f'
,
config_file
,
'-DFOREGROUND'
]
)
((
self
.
options
[
'apache-binary'
],
'-f'
,
config_file
,
'-DFOREGROUND'
),)
)
self
.
path_list
.
append
(
wrapper
)
self
.
path_list
.
append
(
wrapper
)
# create empty html page to not allow listing of /
# create empty html page to not allow listing of /
page
=
open
(
os
.
path
.
join
(
self
.
options
[
'log-directory'
],
"index.html"
),
"w"
)
page
=
open
(
os
.
path
.
join
(
self
.
options
[
'log-directory'
],
"index.html"
),
"w"
)
...
...
slapos/recipe/generic_cloudooo/__init__.py
View file @
dfab94f0
...
@@ -118,5 +118,5 @@ class Recipe(GenericBaseRecipe):
...
@@ -118,5 +118,5 @@ class Recipe(GenericBaseRecipe):
path_list
.
append
(
config_file
)
path_list
.
append
(
config_file
)
path_list
.
append
(
self
.
createPythonScript
(
self
.
options
[
'wrapper'
],
path_list
.
append
(
self
.
createPythonScript
(
self
.
options
[
'wrapper'
],
'slapos.recipe.librecipe.execute.execute_with_signal_translation'
,
'slapos.recipe.librecipe.execute.execute_with_signal_translation'
,
[
self
.
options
[
'ooo-paster'
].
strip
(),
'serve'
,
config_file
]
))
((
self
.
options
[
'ooo-paster'
].
strip
(),
'serve'
,
config_file
),)
))
return
path_list
return
path_list
slapos/recipe/generic_mysql/__init__.py
View file @
dfab94f0
...
@@ -154,7 +154,7 @@ class Recipe(GenericBaseRecipe):
...
@@ -154,7 +154,7 @@ class Recipe(GenericBaseRecipe):
)]
)]
)
)
path_list
.
append
(
mysqld
)
path_list
.
append
(
mysqld
)
environment
=
dict
(
PATH
=
'%s'
%
self
.
options
[
'bin-directory'
])
environment
=
{
'PATH'
:
self
.
options
[
'bin-directory'
]}
# TODO: move to a separate recipe (ack'ed by Cedric)
# TODO: move to a separate recipe (ack'ed by Cedric)
if
'backup-script'
in
self
.
options
:
if
'backup-script'
in
self
.
options
:
# backup configuration
# backup configuration
...
@@ -165,9 +165,15 @@ class Recipe(GenericBaseRecipe):
...
@@ -165,9 +165,15 @@ class Recipe(GenericBaseRecipe):
'--defaults-file=%s'
%
mysql_conf_file
,
'--defaults-file=%s'
%
mysql_conf_file
,
'--socket=%s'
%
socket
.
strip
(),
'--user=root'
,
'--socket=%s'
%
socket
.
strip
(),
'--user=root'
,
'--ibbackup=%s'
%
self
.
options
[
'xtrabackup-binary'
]]
'--ibbackup=%s'
%
self
.
options
[
'xtrabackup-binary'
]]
innobackupex_incremental
=
self
.
createPythonScript
(
self
.
options
[
'innobackupex-incremental'
],
'slapos.recipe.librecipe.execute.executee'
,
[
innobackupex_argument_list
+
[
'--incremental'
],
environment
])
innobackupex_incremental
=
self
.
createPythonScript
(
self
.
options
[
'innobackupex-incremental'
],
'slapos.recipe.librecipe.execute.generic_exec'
,
(
innobackupex_argument_list
+
[
'--incremental'
],
environment
))
path_list
.
append
(
innobackupex_incremental
)
path_list
.
append
(
innobackupex_incremental
)
innobackupex_full
=
self
.
createPythonScript
(
self
.
options
[
'innobackupex-full'
],
'slapos.recipe.librecipe.execute.executee'
,
[
innobackupex_argument_list
,
environment
])
innobackupex_full
=
self
.
createPythonScript
(
self
.
options
[
'innobackupex-full'
],
'slapos.recipe.librecipe.execute.generic_exec'
,
(
innobackupex_argument_list
,
environment
))
path_list
.
append
(
innobackupex_full
)
path_list
.
append
(
innobackupex_full
)
backup_controller
=
self
.
createPythonScript
(
self
.
options
[
'backup-script'
],
__name__
+
'.innobackupex.controller'
,
[
innobackupex_incremental
,
innobackupex_full
,
full_backup
,
incremental_backup
])
backup_controller
=
self
.
createPythonScript
(
self
.
options
[
'backup-script'
],
__name__
+
'.innobackupex.controller'
,
[
innobackupex_incremental
,
innobackupex_full
,
full_backup
,
incremental_backup
])
path_list
.
append
(
backup_controller
)
path_list
.
append
(
backup_controller
)
...
@@ -215,7 +221,10 @@ class Recipe(GenericBaseRecipe):
...
@@ -215,7 +221,10 @@ class Recipe(GenericBaseRecipe):
'--defaults-file=%s'
%
mysql_conf_file
,
'--defaults-file=%s'
%
mysql_conf_file
,
'--socket=%s'
%
socket
.
strip
(),
'--user=root'
,
'--socket=%s'
%
socket
.
strip
(),
'--user=root'
,
]
]
pt_exe
=
self
.
createPythonScript
(
os
.
path
.
join
(
self
.
options
[
'bin-directory'
],
pt_script_name
),
'slapos.recipe.librecipe.execute.executee'
,
[
pt_argument_list
,
environment
])
pt_exe
=
self
.
createPythonScript
(
os
.
path
.
join
(
self
.
options
[
'bin-directory'
],
pt_script_name
),
'slapos.recipe.librecipe.execute.generic_exec'
,
(
pt_argument_list
,
environment
))
path_list
.
append
(
pt_exe
)
path_list
.
append
(
pt_exe
)
return
path_list
return
path_list
...
...
slapos/recipe/generic_mysql/innobackupex.py
View file @
dfab94f0
import
os
import
os
import
glob
import
glob
def
controller
(
args
):
def
controller
(
innobackupex_incremental
,
innobackupex_full
,
full_backup
,
incremental_backup
):
"""Creates full or incremental backup
"""Creates full or incremental backup
If no full backup is done, it is created
If no full backup is done, it is created
...
@@ -9,8 +10,6 @@ def controller(args):
...
@@ -9,8 +10,6 @@ def controller(args):
base is the newest (according to date) full or incremental backup
base is the newest (according to date) full or incremental backup
"""
"""
innobackupex_incremental
,
innobackupex_full
,
full_backup
,
incremental_backup
\
=
args
if
len
(
os
.
listdir
(
full_backup
))
==
0
:
if
len
(
os
.
listdir
(
full_backup
))
==
0
:
print
'Doing full backup in %r'
%
full_backup
print
'Doing full backup in %r'
%
full_backup
os
.
execv
(
innobackupex_full
,
[
innobackupex_full
,
full_backup
])
os
.
execv
(
innobackupex_full
,
[
innobackupex_full
,
full_backup
])
...
...
slapos/recipe/generic_mysql/mysql.py
View file @
dfab94f0
...
@@ -5,9 +5,8 @@ import sys
...
@@ -5,9 +5,8 @@ import sys
import
pytz
import
pytz
def
runMysql
(
args
):
def
runMysql
(
conf
):
sleep
=
60
sleep
=
60
conf
=
args
[
0
]
mysqld_wrapper_list
=
[
conf
[
'mysqld_binary'
],
'--defaults-file=%s'
%
mysqld_wrapper_list
=
[
conf
[
'mysqld_binary'
],
'--defaults-file=%s'
%
conf
[
'configuration_file'
]]
conf
[
'configuration_file'
]]
# we trust mysql_install that if mysql directory is available mysql was
# we trust mysql_install that if mysql directory is available mysql was
...
@@ -54,8 +53,7 @@ def runMysql(args):
...
@@ -54,8 +53,7 @@ def runMysql(args):
os
.
execl
(
mysqld_wrapper_list
[
0
],
*
mysqld_wrapper_list
)
os
.
execl
(
mysqld_wrapper_list
[
0
],
*
mysqld_wrapper_list
)
def
updateMysql
(
args
):
def
updateMysql
(
conf
):
conf
=
args
[
0
]
sleep
=
30
sleep
=
30
is_succeed
=
False
is_succeed
=
False
try
:
try
:
...
...
slapos/recipe/haproxy/__init__.py
View file @
dfab94f0
...
@@ -122,10 +122,10 @@ class Recipe(GenericBaseRecipe):
...
@@ -122,10 +122,10 @@ class Recipe(GenericBaseRecipe):
)
)
wrapper_path
=
self
.
createPythonScript
(
wrapper_path
=
self
.
createPythonScript
(
self
.
options
[
'wrapper-path'
],
self
.
options
[
'wrapper-path'
],
'slapos.recipe.librecipe.execute.
execute
'
,
'slapos.recipe.librecipe.execute.
generic_exec
'
,
arguments
=
[
self
.
options
[
'binary-path'
].
strip
(),
'-f'
,
configuration_path
],
)
((
self
.
options
[
'binary-path'
].
strip
(),
'-f'
,
configuration_path
),)
)
ctl_path
=
self
.
createPythonScript
(
ctl_path
=
self
.
createPythonScript
(
self
.
options
[
'ctl-path'
],
self
.
options
[
'ctl-path'
],
'%s.haproxy.haproxyctl'
%
__name__
,
__name__
+
'.haproxy.haproxyctl'
,
{
'socket_path'
:
self
.
options
[
'socket-path'
]}
)
(
self
.
options
[
'socket-path'
],)
)
return
[
configuration_path
,
wrapper_path
,
ctl_path
]
return
[
configuration_path
,
wrapper_path
,
ctl_path
]
slapos/recipe/haproxy/haproxy.py
View file @
dfab94f0
...
@@ -4,7 +4,7 @@ try:
...
@@ -4,7 +4,7 @@ try:
except
ImportError
:
except
ImportError
:
pass
pass
def
haproxyctl
(
conf
):
def
haproxyctl
(
socket_path
):
while
True
:
while
True
:
try
:
try
:
l
=
raw_input
(
'> '
)
l
=
raw_input
(
'> '
)
...
@@ -14,7 +14,7 @@ def haproxyctl(conf):
...
@@ -14,7 +14,7 @@ def haproxyctl(conf):
if
l
==
'quit'
:
if
l
==
'quit'
:
break
break
s
=
socket
.
socket
(
socket
.
AF_UNIX
,
socket
.
SOCK_STREAM
)
s
=
socket
.
socket
(
socket
.
AF_UNIX
,
socket
.
SOCK_STREAM
)
s
.
connect
(
conf
[
'socket_path'
]
)
s
.
connect
(
socket_path
)
s
.
send
(
'%s
\
n
'
%
l
)
s
.
send
(
'%s
\
n
'
%
l
)
while
True
:
while
True
:
r
=
s
.
recv
(
1024
)
r
=
s
.
recv
(
1024
)
...
...
slapos/recipe/lamp/__init__.py
View file @
dfab94f0
...
@@ -298,9 +298,9 @@ class Request(BaseRecipe):
...
@@ -298,9 +298,9 @@ class Request(BaseRecipe):
'local_host'
:
local_host
,
'local_port'
:
local_port
,
'local_host'
:
local_host
,
'local_port'
:
local_port
,
}))
}))
wrapper
=
zc
.
buildout
.
easy_install
.
scripts
([(
'stunnel'
,
wrapper
=
zc
.
buildout
.
easy_install
.
scripts
([(
'stunnel'
,
'slapos.recipe.librecipe.execute'
,
'
execute
'
)],
self
.
ws
,
'slapos.recipe.librecipe.execute'
,
'
generic_exec
'
)],
self
.
ws
,
sys
.
executable
,
self
.
wrapper_directory
,
arguments
=
[
sys
.
executable
,
self
.
wrapper_directory
,
arguments
=
'%r, %r'
self
.
options
[
'stunnel_binary'
].
strip
(),
stunnel_conf_path
]
%
(
self
.
options
[
'stunnel_binary'
].
strip
(),
stunnel_conf_path
)
)[
0
]
)[
0
]
self
.
path_list
.
append
(
wrapper
)
self
.
path_list
.
append
(
wrapper
)
return
(
local_host
,
local_port
,)
return
(
local_host
,
local_port
,)
slapos/recipe/librecipe/execute.py
View file @
dfab94f0
...
@@ -2,7 +2,6 @@ import sys
...
@@ -2,7 +2,6 @@ import sys
import
os
import
os
import
signal
import
signal
import
subprocess
import
subprocess
import
time
from
collections
import
defaultdict
from
collections
import
defaultdict
from
inotify_simple
import
INotify
,
flags
from
inotify_simple
import
INotify
,
flags
...
@@ -29,65 +28,39 @@ def _wait_files_creation(file_list):
...
@@ -29,65 +28,39 @@ def _wait_files_creation(file_list):
if
event
.
name
in
directory
:
if
event
.
name
in
directory
:
directory
[
event
.
name
]
=
event
.
mask
&
(
flags
.
CREATE
|
flags
.
MOVED_TO
)
directory
[
event
.
name
]
=
event
.
mask
&
(
flags
.
CREATE
|
flags
.
MOVED_TO
)
def
execute
(
args
):
def
generic_exec
(
args
,
extra_environ
=
None
,
wait_list
=
None
):
"""Portable execution with process replacement"""
args
+=
sys
.
argv
[
1
:]
# XXX: Kept for backward compatibility
generic_exec
([
args
,
None
,
None
])
def
execute_wait
(
args
):
if
wait_list
:
"""Execution but after all files in args[1] exists"""
_wait_files_creation
(
wait_list
)
# XXX: Kept for backward compatibility
generic_exec
([
args
[
0
],
args
[
1
],
None
])
if
extra_environ
:
env
=
os
.
environ
.
copy
()
env
.
update
(
extra_environ
)
os
.
execve
(
args
[
0
],
args
,
env
)
else
:
os
.
execv
(
args
[
0
],
args
)
child_pg
=
None
child_pg
=
None
def
executee
(
args
):
"""Portable execution with process replacement and environment manipulation"""
# XXX: Kept for backward compatibility
generic_exec
([
args
[
0
],
None
,
args
[
1
]])
def
executee_wait
(
args
):
"""Portable execution with process replacement and environment manipulation"""
# XXX: Kept for backward compatibility
generic_exec
(
args
)
def
generic_exec
(
args
):
exec_list
=
list
(
args
[
0
])
file_list
=
args
[
1
]
environment_overriding
=
args
[
2
]
exec_env
=
os
.
environ
.
copy
()
if
environment_overriding
is
not
None
:
exec_env
.
update
(
environment_overriding
)
if
file_list
is
not
None
:
_wait_files_creation
(
file_list
)
os
.
execve
(
exec_list
[
0
],
exec_list
+
sys
.
argv
[
1
:],
exec_env
)
def
sig_handler
(
sig
,
frame
):
def
sig_handler
(
sig
,
frame
):
print
'Received signal %r, killing children and exiting'
%
sig
print
'Received signal %r, killing children and exiting'
%
sig
if
child_pg
is
not
None
:
if
child_pg
is
not
None
:
os
.
killpg
(
child_pg
,
signal
.
SIGHUP
)
os
.
killpg
(
child_pg
,
signal
.
SIGHUP
)
os
.
killpg
(
child_pg
,
signal
.
SIGTERM
)
os
.
killpg
(
child_pg
,
signal
.
SIGTERM
)
sys
.
exit
(
0
)
sys
.
exit
()
signal
.
signal
(
signal
.
SIGINT
,
sig_handler
)
signal
.
signal
(
signal
.
SIGQUIT
,
sig_handler
)
signal
.
signal
(
signal
.
SIGTERM
,
sig_handler
)
def
execute_with_signal_translation
(
args
):
def
execute_with_signal_translation
(
args
):
"""Run process as children and translate from SIGTERM to another signal"""
"""Run process as children and translate from SIGTERM to another signal"""
global
child_pg
global
child_pg
signal
.
signal
(
signal
.
SIGINT
,
sig_handler
)
signal
.
signal
(
signal
.
SIGQUIT
,
sig_handler
)
signal
.
signal
(
signal
.
SIGTERM
,
sig_handler
)
child
=
subprocess
.
Popen
(
args
,
close_fds
=
True
,
preexec_fn
=
os
.
setsid
)
child
=
subprocess
.
Popen
(
args
,
close_fds
=
True
,
preexec_fn
=
os
.
setsid
)
child_pg
=
child
.
pid
child_pg
=
child
.
pid
try
:
try
:
print
'Process %r started'
%
args
print
'Process %r started'
%
args
while
True
:
signal
.
pause
()
time
.
sleep
(
10
)
finally
:
finally
:
os
.
killpg
(
child_pg
,
signal
.
SIGHUP
)
os
.
killpg
(
child_pg
,
signal
.
SIGHUP
)
os
.
killpg
(
child_pg
,
signal
.
SIGTERM
)
os
.
killpg
(
child_pg
,
signal
.
SIGTERM
)
slapos/recipe/librecipe/generic.py
View file @
dfab94f0
...
@@ -116,26 +116,28 @@ class GenericBaseRecipe(object):
...
@@ -116,26 +116,28 @@ class GenericBaseRecipe(object):
with
io
.
open
(
filepath
,
'w+'
,
encoding
=
encoding
)
as
f
:
with
io
.
open
(
filepath
,
'w+'
,
encoding
=
encoding
)
as
f
:
f
.
write
(
u'
\
n
'
.
join
(
lines
))
f
.
write
(
u'
\
n
'
.
join
(
lines
))
def
createPythonScript
(
self
,
name
,
absolute_function
,
arg
uments
=
''
):
def
createPythonScript
(
self
,
name
,
absolute_function
,
arg
s
=
(),
kw
=
{}
):
"""Create a python script using zc.buildout.easy_install.scripts
"""Create a python script using zc.buildout.easy_install.scripts
* function should look like 'module.function', or only 'function'
* function should look like 'module.function', or only 'function'
if it is a builtin function."""
if it is a builtin function."""
absolute_function
=
tuple
(
absolute_function
.
rsplit
(
'.'
,
1
))
function
=
absolute_function
.
rsplit
(
'.'
,
1
)
if
len
(
absolute_function
)
==
1
:
if
len
(
function
)
==
1
:
absolute_function
=
(
'__builtin__'
,)
+
absolute_function
module
=
'__builtin__'
if
len
(
absolute_function
)
!=
2
:
function
,
=
function
raise
ValueError
(
"A non valid function was given"
)
else
:
module
,
function
=
function
module
,
function
=
absolute_function
path
,
filename
=
os
.
path
.
split
(
os
.
path
.
abspath
(
name
))
path
,
filename
=
os
.
path
.
split
(
os
.
path
.
abspath
(
name
))
script
=
zc
.
buildout
.
easy_install
.
scripts
(
assert
not
isinstance
(
args
,
(
basestring
,
dict
)),
args
args
=
map
(
repr
,
args
)
args
+=
map
(
'%s=%r'
.
__mod__
,
kw
.
iteritems
())
return
zc
.
buildout
.
easy_install
.
scripts
(
[(
filename
,
module
,
function
)],
self
.
_ws
,
sys
.
executable
,
[(
filename
,
module
,
function
)],
self
.
_ws
,
sys
.
executable
,
path
,
arguments
=
arguments
)[
0
]
path
,
arguments
=
', '
.
join
(
args
))[
0
]
return
script
def
createWrapper
(
self
,
name
,
command
,
parameters
,
comments
=
[]
,
def
createWrapper
(
self
,
name
,
command
,
parameters
,
comments
=
()
,
parameters_extra
=
False
,
environment
=
None
,
parameters_extra
=
False
,
environment
=
None
,
pidfile
=
None
,
reserve_cpu
=
False
pidfile
=
None
,
reserve_cpu
=
False
):
):
...
...
slapos/recipe/logrotate.py
View file @
dfab94f0
...
@@ -48,8 +48,9 @@ class Recipe(GenericBaseRecipe):
...
@@ -48,8 +48,9 @@ class Recipe(GenericBaseRecipe):
logrotate
=
self
.
createPythonScript
(
logrotate
=
self
.
createPythonScript
(
self
.
options
[
'wrapper'
],
self
.
options
[
'wrapper'
],
'slapos.recipe.librecipe.execute.execute'
,
'slapos.recipe.librecipe.execute.generic_exec'
,
[
self
.
options
[
'logrotate-binary'
],
'-s'
,
state_file
,
logrotate_conf_file
,
]
((
self
.
options
[
'logrotate-binary'
],
'-s'
,
state_file
,
logrotate_conf_file
),)
)
)
return
[
logrotate
,
logrotate_conf_file
]
return
[
logrotate
,
logrotate_conf_file
]
...
...
slapos/recipe/mioga/instantiate.py
View file @
dfab94f0
...
@@ -205,9 +205,9 @@ Include conf/extra/httpd-autoindex.conf
...
@@ -205,9 +205,9 @@ Include conf/extra/httpd-autoindex.conf
httpd_wrapper
=
self
.
createPythonScript
(
httpd_wrapper
=
self
.
createPythonScript
(
os
.
path
.
join
(
services_dir
,
'httpd_wrapper'
),
os
.
path
.
join
(
services_dir
,
'httpd_wrapper'
),
'slapos.recipe.librecipe.execute.
execute
'
,
'slapos.recipe.librecipe.execute.
generic_exec
'
,
[
self
.
options
[
'httpd_binary'
],
'-f'
,
self
.
options
[
'httpd_conf
'
],
((
self
.
options
[
'httpd_binary
'
],
'-DFOREGROUND'
]
'-f'
,
self
.
options
[
'httpd_conf'
],
'-DFOREGROUND'
),)
)
)
path_list
.
append
(
httpd_wrapper
)
path_list
.
append
(
httpd_wrapper
)
...
@@ -222,17 +222,17 @@ Include conf/extra/httpd-autoindex.conf
...
@@ -222,17 +222,17 @@ Include conf/extra/httpd-autoindex.conf
mioga_conf_path
=
os
.
path
.
join
(
mioga_base
,
'conf'
,
'Mioga.conf'
)
mioga_conf_path
=
os
.
path
.
join
(
mioga_base
,
'conf'
,
'Mioga.conf'
)
notifier_wrapper
=
self
.
createPythonScript
(
notifier_wrapper
=
self
.
createPythonScript
(
os
.
path
.
join
(
services_dir
,
'notifier'
),
os
.
path
.
join
(
services_dir
,
'notifier'
),
'slapos.recipe.librecipe.execute.
execute
'
,
'slapos.recipe.librecipe.execute.
generic_exec
'
,
[
os
.
path
.
join
(
site_perl_bin
,
'notifier.pl'
),
((
os
.
path
.
join
(
site_perl_bin
,
'notifier.pl'
),
mioga_conf_path
]
mioga_conf_path
),)
)
)
path_list
.
append
(
notifier_wrapper
)
path_list
.
append
(
notifier_wrapper
)
searchengine_wrapper
=
self
.
createPythonScript
(
searchengine_wrapper
=
self
.
createPythonScript
(
os
.
path
.
join
(
services_dir
,
'searchengine'
),
os
.
path
.
join
(
services_dir
,
'searchengine'
),
'slapos.recipe.librecipe.execute.
execute
'
,
'slapos.recipe.librecipe.execute.
generic_exec
'
,
[
os
.
path
.
join
(
site_perl_bin
,
'searchengine.pl'
),
((
os
.
path
.
join
(
site_perl_bin
,
'searchengine.pl'
),
mioga_conf_path
]
mioga_conf_path
),)
)
)
path_list
.
append
(
searchengine_wrapper
)
path_list
.
append
(
searchengine_wrapper
)
...
...
slapos/recipe/mydumper.py
View file @
dfab94f0
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#
##############################################################################
##############################################################################
import
subproces
s
import
o
s
from
slapos.recipe.librecipe
import
GenericBaseRecipe
from
slapos.recipe.librecipe
import
GenericBaseRecipe
...
@@ -58,14 +58,14 @@ def do_export(args):
...
@@ -58,14 +58,14 @@ def do_export(args):
cmd
.
extend
([
'-o'
,
args
[
'directory'
]])
cmd
.
extend
([
'-o'
,
args
[
'directory'
]])
subprocess
.
check_call
(
cmd
)
os
.
execv
(
cmd
[
0
],
cmd
)
def
do_import
(
args
):
def
do_import
(
args
):
cmd
=
_mydumper_base_cmd
(
**
args
)
cmd
=
_mydumper_base_cmd
(
**
args
)
cmd
.
append
(
'--overwrite-tables'
)
cmd
.
append
(
'--overwrite-tables'
)
cmd
.
extend
([
'-d'
,
args
[
'directory'
]])
cmd
.
extend
([
'-d'
,
args
[
'directory'
]])
subprocess
.
check_call
(
cmd
)
os
.
execv
(
cmd
[
0
],
cmd
)
class
Recipe
(
GenericBaseRecipe
):
class
Recipe
(
GenericBaseRecipe
):
...
@@ -95,9 +95,5 @@ class Recipe(GenericBaseRecipe):
...
@@ -95,9 +95,5 @@ class Recipe(GenericBaseRecipe):
config
[
'compression'
]
=
self
.
optionIsTrue
(
'compression'
,
default
=
False
)
config
[
'compression'
]
=
self
.
optionIsTrue
(
'compression'
,
default
=
False
)
config
[
'rows'
]
=
self
.
options
.
get
(
'rows'
)
config
[
'rows'
]
=
self
.
options
.
get
(
'rows'
)
wrapper
=
self
.
createPythonScript
(
name
=
self
.
options
[
'wrapper'
],
return
self
.
createPythonScript
(
self
.
options
[
'wrapper'
],
absolute_function
=
'%s.%s'
%
(
__name__
,
function
.
func_name
),
'%s.%s'
%
(
function
.
__module__
,
function
.
__name__
),
(
config
,))
arguments
=
config
)
return
[
wrapper
]
slapos/recipe/mysql/__init__.py
View file @
dfab94f0
...
@@ -55,9 +55,9 @@ class Recipe(GenericBaseRecipe):
...
@@ -55,9 +55,9 @@ class Recipe(GenericBaseRecipe):
socket
=
self
.
options
[
'socket'
],
socket
=
self
.
options
[
'socket'
],
post_rotate
=
self
.
createPythonScript
(
post_rotate
=
self
.
createPythonScript
(
self
.
options
[
'logrotate-post'
],
self
.
options
[
'logrotate-post'
],
'slapos.recipe.librecipe.execute.
execute
'
,
'slapos.recipe.librecipe.execute.
generic_exec
'
,
[
mysql_binary
,
'--no-defaults'
,
'-B'
,
'-u'
,
'root'
,
'--socket=%s'
%
socket
,
'-e
'
,
((
mysql_binary
,
'--no-defaults'
,
'-B'
,
'-u'
,
'root
'
,
'FLUSH LOGS'
]
'--socket=%s'
%
socket
,
'-e'
,
'FLUSH LOGS'
),)
)
)
path_list
.
append
(
post_rotate
)
path_list
.
append
(
post_rotate
)
...
@@ -85,12 +85,12 @@ class Recipe(GenericBaseRecipe):
...
@@ -85,12 +85,12 @@ class Recipe(GenericBaseRecipe):
mysql_update
=
self
.
createPythonScript
(
mysql_update
=
self
.
createPythonScript
(
self
.
options
[
'update-wrapper'
],
self
.
options
[
'update-wrapper'
],
'%s.mysql.updateMysql'
%
__name__
,
'%s.mysql.updateMysql'
%
__name__
,
dict
(
(
dict
(
mysql_script
=
mysql_script
,
mysql_script
=
mysql_script
,
mysql_binary
=
mysql_binary
,
mysql_binary
=
mysql_binary
,
mysql_upgrade_binary
=
mysql_upgrade_binary
,
mysql_upgrade_binary
=
mysql_upgrade_binary
,
socket
=
socket
,
socket
=
socket
,
)
),
)
)
)
path_list
.
append
(
mysql_update
)
path_list
.
append
(
mysql_update
)
...
@@ -98,7 +98,7 @@ class Recipe(GenericBaseRecipe):
...
@@ -98,7 +98,7 @@ class Recipe(GenericBaseRecipe):
mysqld
=
self
.
createPythonScript
(
mysqld
=
self
.
createPythonScript
(
self
.
options
[
'wrapper'
],
self
.
options
[
'wrapper'
],
'%s.mysql.runMysql'
%
__name__
,
'%s.mysql.runMysql'
%
__name__
,
dict
(
(
dict
(
mysql_install_binary
=
self
.
options
[
'mysql-install-binary'
],
mysql_install_binary
=
self
.
options
[
'mysql-install-binary'
],
mysqld_binary
=
mysqld_binary
,
mysqld_binary
=
mysqld_binary
,
data_directory
=
mysql_conf
[
'data_directory'
],
data_directory
=
mysql_conf
[
'data_directory'
],
...
@@ -106,7 +106,7 @@ class Recipe(GenericBaseRecipe):
...
@@ -106,7 +106,7 @@ class Recipe(GenericBaseRecipe):
socket
=
socket
,
socket
=
socket
,
configuration_file
=
mysql_conf_file
,
configuration_file
=
mysql_conf_file
,
cwd
=
self
.
options
[
'mysql-base-directory'
],
cwd
=
self
.
options
[
'mysql-base-directory'
],
)
)
,)
)
)
path_list
.
append
(
mysqld
)
path_list
.
append
(
mysqld
)
...
@@ -115,12 +115,12 @@ class Recipe(GenericBaseRecipe):
...
@@ -115,12 +115,12 @@ class Recipe(GenericBaseRecipe):
backup_script
=
self
.
createPythonScript
(
backup_script
=
self
.
createPythonScript
(
self
.
options
[
'backup-script'
],
self
.
options
[
'backup-script'
],
'%s.do_backup'
%
__name__
,
'%s.do_backup'
%
__name__
,
dict
(
(
dict
(
mydumper_binary
=
self
.
options
[
'mydumper-binary'
],
mydumper_binary
=
self
.
options
[
'mydumper-binary'
],
database
=
mysql_conf
[
'mysql_database'
],
database
=
mysql_conf
[
'mysql_database'
],
socket
=
mysql_conf
[
'socket'
],
socket
=
mysql_conf
[
'socket'
],
backup_directory
=
self
.
options
[
'backup-directory'
]
backup_directory
=
self
.
options
[
'backup-directory'
]
),
),)
)
)
path_list
.
append
(
backup_script
)
path_list
.
append
(
backup_script
)
...
@@ -129,7 +129,7 @@ class Recipe(GenericBaseRecipe):
...
@@ -129,7 +129,7 @@ class Recipe(GenericBaseRecipe):
recovering_script
=
self
.
createPythonScript
(
recovering_script
=
self
.
createPythonScript
(
self
.
options
[
'recovering-wrapper'
],
self
.
options
[
'recovering-wrapper'
],
'%s.import_dump'
%
__name__
,
'%s.import_dump'
%
__name__
,
{
(
{
'lock_file'
:
os
.
path
.
join
(
self
.
work_directory
,
'lock_file'
:
os
.
path
.
join
(
self
.
work_directory
,
'import_done'
),
'import_done'
),
'database'
:
mysql_conf
[
'mysql_database'
],
'database'
:
mysql_conf
[
'mysql_database'
],
...
@@ -140,7 +140,7 @@ class Recipe(GenericBaseRecipe):
...
@@ -140,7 +140,7 @@ class Recipe(GenericBaseRecipe):
'local_directory'
:
self
.
mysql_backup_directory
,
'local_directory'
:
self
.
mysql_backup_directory
,
'dump_name'
:
dump_filename
,
'dump_name'
:
dump_filename
,
'zcat_binary'
:
self
.
options
[
'zcat-binary'
],
'zcat_binary'
:
self
.
options
[
'zcat-binary'
],
}
}
,)
)
)
path_list
.
append
(
recovering_script
)
path_list
.
append
(
recovering_script
)
...
...
slapos/recipe/novnc/__init__.py
View file @
dfab94f0
...
@@ -35,10 +35,10 @@ class Recipe(GenericBaseRecipe):
...
@@ -35,10 +35,10 @@ class Recipe(GenericBaseRecipe):
"""
"""
def
install
(
self
):
def
install
(
self
):
r
unner_path
=
self
.
createPythonScript
(
r
eturn
self
.
createPythonScript
(
self
.
options
[
'path'
],
self
.
options
[
'path'
],
'slapos.recipe.librecipe.execute.
execute_wait
'
,
'slapos.recipe.librecipe.execute.
generic_exec
'
,
[[
((
self
.
options
[
'websockify-path'
],
self
.
options
[
'websockify-path'
],
'--web'
,
'--web'
,
self
.
options
[
'novnc-location'
],
self
.
options
[
'novnc-location'
],
...
@@ -47,8 +47,7 @@ class Recipe(GenericBaseRecipe):
...
@@ -47,8 +47,7 @@ class Recipe(GenericBaseRecipe):
'--ssl-only'
,
'--ssl-only'
,
'%s:%s'
%
(
self
.
options
[
'ip'
],
self
.
options
[
'port'
]),
'%s:%s'
%
(
self
.
options
[
'ip'
],
self
.
options
[
'port'
]),
'%s:%s'
%
(
self
.
options
[
'vnc-ip'
],
self
.
options
[
'vnc-port'
]),
'%s:%s'
%
(
self
.
options
[
'vnc-ip'
],
self
.
options
[
'vnc-port'
]),
],
),),
[
self
.
options
[
'ssl-key-path'
],
self
.
options
[
'ssl-cert-path'
]]],
{
'wait_list'
:
(
self
.
options
[
'ssl-key-path'
],
self
.
options
[
'ssl-cert-path'
])},
)
)
return
[
runner_path
]
slapos/recipe/pbs.py
View file @
dfab94f0
...
@@ -39,30 +39,18 @@ from slapos.recipe.notifier import Callback
...
@@ -39,30 +39,18 @@ from slapos.recipe.notifier import Callback
from
slapos.recipe.librecipe
import
shlex
from
slapos.recipe.librecipe
import
shlex
def
promise
(
args
):
def
promise
(
ssh_client
,
user
,
host
,
port
):
# Redirect output to /dev/null
# Redirect output to /dev/null
with
open
(
"/dev/null"
)
as
_dev_null
:
with
open
(
os
.
devnull
)
as
_dev_null
:
ssh
=
subprocess
.
Popen
(
ssh
=
subprocess
.
Popen
(
[
args
[
'ssh_client'
],
'%(user)s@%(host)s'
%
args
,
'-p'
,
'%(port)s'
%
args
],
(
ssh_client
,
'%s@%s'
%
(
user
,
host
),
'-p'
,
str
(
port
)),
stdin
=
subprocess
.
PIPE
,
stdout
=
_dev_null
,
stderr
=
None
stdin
=
subprocess
.
PIPE
,
stdout
=
_dev_null
)
)
ssh
.
communicate
(
'q'
+
chr
(
255
)
+
chr
(
0
)
*
7
)
if
ssh
.
returncode
:
# Rdiff Backup protocol quit command
quitcommand
=
'q'
+
chr
(
255
)
+
chr
(
0
)
*
7
ssh
.
stdin
.
write
(
quitcommand
)
ssh
.
stdin
.
flush
()
ssh
.
stdin
.
close
()
ssh
.
wait
()
if
ssh
.
poll
()
is
None
:
return
1
if
ssh
.
returncode
!=
0
:
sys
.
stderr
.
write
(
"SSH Connection failed
\
n
"
)
sys
.
stderr
.
write
(
"SSH Connection failed
\
n
"
)
return
ssh
.
returncode
return
ssh
.
returncode
class
Recipe
(
GenericSlapRecipe
,
Notify
,
Callback
):
class
Recipe
(
GenericSlapRecipe
,
Notify
,
Callback
):
def
_options
(
self
,
options
):
def
_options
(
self
,
options
):
options
[
'rdiff-backup-data-folder'
]
=
""
options
[
'rdiff-backup-data-folder'
]
=
""
...
@@ -244,15 +232,11 @@ class Recipe(GenericSlapRecipe, Notify, Callback):
...
@@ -244,15 +232,11 @@ class Recipe(GenericSlapRecipe, Notify, Callback):
print
'Processing PBS slave %s with type %s'
%
(
slave_id
,
slave_type
)
print
'Processing PBS slave %s with type %s'
%
(
slave_id
,
slave_type
)
promise_path
=
os
.
path
.
join
(
self
.
options
[
'promises-directory'
],
"ssh-to-%s"
%
slave_id
)
path_list
.
append
(
self
.
createPythonScript
(
promise_dict
=
dict
(
ssh_client
=
self
.
options
[
'sshclient-binary'
],
os
.
path
.
join
(
self
.
options
[
'promises-directory'
],
"ssh-to-%s"
%
slave_id
),
user
=
parsed_url
.
username
,
host
=
parsed_url
.
hostname
,
port
=
parsed_url
.
port
)
promise
=
self
.
createPythonScript
(
promise_path
,
__name__
+
'.promise'
,
__name__
+
'.promise'
,
promise_dict
)
(
self
.
options
[
'sshclient-binary'
],
path_list
.
append
(
promise
)
parsed_url
.
username
,
parsed_url
.
hostname
,
parsed_url
.
port
))
)
# Create known_hosts file by default.
# Create known_hosts file by default.
# In some case, we don't want to create it (case where we share IP mong partitions)
# In some case, we don't want to create it (case where we share IP mong partitions)
...
...
slapos/recipe/re6stnet/__init__.py
View file @
dfab94f0
...
@@ -162,7 +162,6 @@ class Recipe(GenericBaseRecipe):
...
@@ -162,7 +162,6 @@ class Recipe(GenericBaseRecipe):
return
hash_string
return
hash_string
def
install
(
self
):
def
install
(
self
):
path_list
=
[]
token_save_path
=
os
.
path
.
join
(
self
.
options
[
'conf-dir'
],
'token.json'
)
token_save_path
=
os
.
path
.
join
(
self
.
options
[
'conf-dir'
],
'token.json'
)
token_list_path
=
self
.
options
[
'token-dir'
]
token_list_path
=
self
.
options
[
'token-dir'
]
...
@@ -190,20 +189,14 @@ class Recipe(GenericBaseRecipe):
...
@@ -190,20 +189,14 @@ class Recipe(GenericBaseRecipe):
self
.
createFile
(
token_save_path
,
json
.
dumps
(
token_dict
))
self
.
createFile
(
token_save_path
,
json
.
dumps
(
token_dict
))
service_dict
=
dict
(
token_base_path
=
token_list_path
,
computer_dict
=
dict
(
partition_id
=
self
.
computer_partition_id
,
token_json
=
token_save_path
,
computer_guid
=
self
.
computer_id
,
partition_id
=
self
.
computer_partition_id
,
master_url
=
self
.
server_url
,
computer_id
=
self
.
computer_id
,
registry_url
=
registry_url
,
server_url
=
self
.
server_url
,
cert_file
=
self
.
cert_file
,
cert_file
=
self
.
cert_file
,
key_file
=
self
.
key_file
)
key_file
=
self
.
key_file
)
re
quest_add
=
self
.
createPythonScript
(
re
turn
self
.
createPythonScript
(
self
.
options
[
'manager-wrapper'
].
strip
(),
self
.
options
[
'manager-wrapper'
].
strip
(),
'%s.re6stnet.manage'
%
__name__
,
service_dict
__name__
+
'.re6stnet.manage'
,
(
registry_url
,
token_list_path
,
token_save_path
,
computer_dict
)
)
)
path_list
.
append
(
request_add
)
return
path_list
slapos/recipe/re6stnet/re6stnet.py
View file @
dfab94f0
...
@@ -17,9 +17,7 @@ logging.trace = logging.debug
...
@@ -17,9 +17,7 @@ logging.trace = logging.debug
def
loadJsonFile
(
path
):
def
loadJsonFile
(
path
):
if
os
.
path
.
exists
(
path
):
if
os
.
path
.
exists
(
path
):
with
open
(
path
,
'r'
)
as
f
:
with
open
(
path
,
'r'
)
as
f
:
content
=
f
.
read
()
return
json
.
load
(
f
)
return
json
.
loads
(
content
)
else
:
return
{}
return
{}
def
writeFile
(
path
,
data
):
def
writeFile
(
path
,
data
):
...
@@ -39,29 +37,25 @@ def updateFile(file_path, value):
...
@@ -39,29 +37,25 @@ def updateFile(file_path, value):
return
True
return
True
return
False
return
False
def
getComputerPartition
(
server_url
,
key_file
,
cert_file
,
computer_guid
,
partition_id
):
def
getComputerPartition
(
master_url
,
key_file
,
cert_file
,
computer_guid
,
partition_id
):
slap
=
slapos
.
slap
.
slap
()
slap
=
slapos
.
slap
.
slap
()
# Redeploy instance to update published information
# Redeploy instance to update published information
slap
.
initializeConnection
(
server_url
,
slap
.
initializeConnection
(
master_url
,
key_file
,
cert_file
)
key_file
,
return
slap
.
registerComputerPartition
(
computer_guid
,
partition_id
)
cert_file
)
return
slap
.
registerComputerPartition
(
computer_guid
=
computer_guid
,
def
requestAddToken
(
client
,
token_base_path
):
partition_id
=
partition_id
)
def
requestAddToken
(
client
,
base_token_path
):
time
.
sleep
(
3
)
time
.
sleep
(
3
)
path_list
=
[
x
for
x
in
os
.
listdir
(
base_token
_path
)
if
x
.
endswith
(
'.add'
)]
path_list
=
[
x
for
x
in
os
.
listdir
(
token_base
_path
)
if
x
.
endswith
(
'.add'
)]
log
.
info
(
"Searching tokens to add at %s and found %s."
%
(
base_token
_path
,
path_list
))
log
.
info
(
"Searching tokens to add at %s and found %s."
%
(
token_base
_path
,
path_list
))
if
not
path_list
:
if
not
path_list
:
log
.
info
(
"No new token to add. Exiting..."
)
log
.
info
(
"No new token to add. Exiting..."
)
return
return
for
reference_key
in
path_list
:
for
reference_key
in
path_list
:
request_file
=
os
.
path
.
join
(
base_token
_path
,
reference_key
)
request_file
=
os
.
path
.
join
(
token_base
_path
,
reference_key
)
token
=
readFile
(
request_file
)
token
=
readFile
(
request_file
)
log
.
info
(
"Including token %s for %s"
%
(
token
,
reference_key
))
log
.
info
(
"Including token %s for %s"
%
(
token
,
reference_key
))
if
token
:
if
token
:
...
@@ -79,21 +73,21 @@ def requestAddToken(client, base_token_path):
...
@@ -79,21 +73,21 @@ def requestAddToken(client, base_token_path):
# update information
# update information
log
.
info
(
"New token added for slave instance %s. Updating file status..."
%
log
.
info
(
"New token added for slave instance %s. Updating file status..."
%
reference
)
reference
)
status_file
=
os
.
path
.
join
(
base_token
_path
,
'%s.status'
%
reference
)
status_file
=
os
.
path
.
join
(
token_base
_path
,
'%s.status'
%
reference
)
updateFile
(
status_file
,
'TOKEN_ADDED'
)
updateFile
(
status_file
,
'TOKEN_ADDED'
)
os
.
unlink
(
request_file
)
os
.
unlink
(
request_file
)
else
:
else
:
log
.
debug
(
'Bad token. Request add token fail for %s...'
%
request_file
)
log
.
debug
(
'Bad token. Request add token fail for %s...'
%
request_file
)
def
requestRemoveToken
(
client
,
base_token
_path
):
def
requestRemoveToken
(
client
,
token_base
_path
):
path_list
=
[
x
for
x
in
os
.
listdir
(
base_token
_path
)
if
x
.
endswith
(
'.remove'
)]
path_list
=
[
x
for
x
in
os
.
listdir
(
token_base
_path
)
if
x
.
endswith
(
'.remove'
)]
if
not
path_list
:
if
not
path_list
:
log
.
info
(
"No token to delete. Exiting..."
)
log
.
info
(
"No token to delete. Exiting..."
)
return
return
for
reference_key
in
path_list
:
for
reference_key
in
path_list
:
request_file
=
os
.
path
.
join
(
base_token
_path
,
reference_key
)
request_file
=
os
.
path
.
join
(
token_base
_path
,
reference_key
)
token
=
readFile
(
request_file
)
token
=
readFile
(
request_file
)
if
token
:
if
token
:
reference
=
reference_key
.
split
(
'.'
)[
0
]
reference
=
reference_key
.
split
(
'.'
)[
0
]
...
@@ -108,7 +102,7 @@ def requestRemoveToken(client, base_token_path):
...
@@ -108,7 +102,7 @@ def requestRemoveToken(client, base_token_path):
continue
continue
else
:
else
:
# certificate is invalidated, it will be revoked
# certificate is invalidated, it will be revoked
writeFile
(
os
.
path
.
join
(
base_token
_path
,
'%s.revoke'
%
reference
),
''
)
writeFile
(
os
.
path
.
join
(
token_base
_path
,
'%s.revoke'
%
reference
),
''
)
if
result
in
(
True
,
'True'
):
if
result
in
(
True
,
'True'
):
# update information
# update information
...
@@ -117,33 +111,17 @@ def requestRemoveToken(client, base_token_path):
...
@@ -117,33 +111,17 @@ def requestRemoveToken(client, base_token_path):
if
result
in
[
'True'
,
'False'
]:
if
result
in
[
'True'
,
'False'
]:
os
.
unlink
(
request_file
)
os
.
unlink
(
request_file
)
status_file
=
os
.
path
.
join
(
base_token
_path
,
'%s.status'
%
reference
)
status_file
=
os
.
path
.
join
(
token_base
_path
,
'%s.status'
%
reference
)
if
os
.
path
.
exists
(
status_file
):
if
os
.
path
.
exists
(
status_file
):
os
.
unlink
(
status_file
)
os
.
unlink
(
status_file
)
ipv6_file
=
os
.
path
.
join
(
base_token
_path
,
'%s.ipv6'
%
reference
)
ipv6_file
=
os
.
path
.
join
(
token_base
_path
,
'%s.ipv6'
%
reference
)
if
os
.
path
.
exists
(
ipv6_file
):
if
os
.
path
.
exists
(
ipv6_file
):
os
.
unlink
(
ipv6_file
)
os
.
unlink
(
ipv6_file
)
else
:
else
:
log
.
debug
(
'Bad token. Request add token fail for %s...'
%
request_file
)
log
.
debug
(
'Bad token. Request add token fail for %s...'
%
request_file
)
def
requestRevoqueCertificate
(
args
):
def
checkService
(
client
,
token_base_path
,
token_json
,
computer_partition
):
base_token_path
=
args
[
'token_base_path'
]
path_list
=
[
x
for
x
in
os
.
listdir
(
base_token_path
)
if
x
.
endswith
(
'.revoke'
)]
for
reference_key
in
path_list
:
reference
=
reference_key
.
split
(
'.'
)[
0
]
if
revokeByMail
(
args
[
'registry_url'
],
'%s@slapos'
%
reference
.
lower
(),
args
[
'db'
]):
os
.
unlink
(
os
.
path
.
join
(
base_token_path
,
reference_key
))
log
.
info
(
"Certificate revoked for slave instance %s."
%
reference
)
return
log
.
info
(
"Failed to revoke email for %s"
%
reference
)
def
checkService
(
client
,
base_token_path
,
token_json
,
computer_partition
):
token_dict
=
loadJsonFile
(
token_json
)
token_dict
=
loadJsonFile
(
token_json
)
updated
=
False
updated
=
False
if
not
token_dict
:
if
not
token_dict
:
...
@@ -152,7 +130,7 @@ def checkService(client, base_token_path, token_json, computer_partition):
...
@@ -152,7 +130,7 @@ def checkService(client, base_token_path, token_json, computer_partition):
# Check token status
# Check token status
for
slave_reference
,
token
in
token_dict
.
iteritems
():
for
slave_reference
,
token
in
token_dict
.
iteritems
():
log
.
info
(
"%s %s"
%
(
slave_reference
,
token
))
log
.
info
(
"%s %s"
%
(
slave_reference
,
token
))
status_file
=
os
.
path
.
join
(
base_token
_path
,
'%s.status'
%
slave_reference
)
status_file
=
os
.
path
.
join
(
token_base
_path
,
'%s.status'
%
slave_reference
)
if
not
os
.
path
.
exists
(
status_file
):
if
not
os
.
path
.
exists
(
status_file
):
# This token is not added yet!
# This token is not added yet!
log
.
info
(
"Token %s dont exist yet."
%
status_file
)
log
.
info
(
"Token %s dont exist yet."
%
status_file
)
...
@@ -206,31 +184,22 @@ def checkService(client, base_token_path, token_json, computer_partition):
...
@@ -206,31 +184,22 @@ def checkService(client, base_token_path, token_json, computer_partition):
slave_reference
,
traceback
.
format_exc
())
slave_reference
,
traceback
.
format_exc
())
def
manage
(
args
,
can_bang
=
True
):
def
manage
(
registry_url
,
token_base_path
,
token_json
,
computer_dict
,
can_bang
=
True
):
computer_guid
=
args
[
'computer_id'
]
partition_id
=
args
[
'partition_id'
]
server_url
=
args
[
'server_url'
]
key_file
=
args
[
'key_file'
]
cert_file
=
args
[
'cert_file'
]
client
=
registry
.
RegistryClient
(
args
[
'registry_url'
])
client
=
registry
.
RegistryClient
(
registry_url
)
base_token_path
=
args
[
'token_base_path'
]
token_json
=
args
[
'token_json'
]
log
.
info
(
"ADD TOKEN"
)
log
.
info
(
"ADD TOKEN"
)
# Request Add new tokens
# Request Add new tokens
requestAddToken
(
client
,
base_token
_path
)
requestAddToken
(
client
,
token_base
_path
)
log
.
info
(
"Remove TOKEN"
)
log
.
info
(
"Remove TOKEN"
)
# Request delete removed token
# Request delete removed token
requestRemoveToken
(
client
,
base_token
_path
)
requestRemoveToken
(
client
,
token_base
_path
)
computer_partition
=
getComputerPartition
(
server_url
,
key_file
,
computer_partition
=
getComputerPartition
(
**
computer_dict
)
cert_file
,
computer_guid
,
partition_id
)
log
.
info
(
"Update Services"
)
log
.
info
(
"Update Services"
)
# check status of all token
# check status of all token
checkService
(
client
,
base_token_path
,
checkService
(
client
,
token_base_path
,
token_json
,
computer_partition
)
token_json
,
computer_partition
)
slapos/recipe/redis/__init__.py
View file @
dfab94f0
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
#
#
##############################################################################
##############################################################################
import
os
import
os
import
sys
from
slapos.recipe.librecipe
import
GenericBaseRecipe
from
slapos.recipe.librecipe
import
GenericBaseRecipe
class
Recipe
(
GenericBaseRecipe
):
class
Recipe
(
GenericBaseRecipe
):
...
@@ -58,8 +58,8 @@ class Recipe(GenericBaseRecipe):
...
@@ -58,8 +58,8 @@ class Recipe(GenericBaseRecipe):
redis
=
self
.
createPythonScript
(
redis
=
self
.
createPythonScript
(
self
.
options
[
'wrapper'
],
self
.
options
[
'wrapper'
],
'slapos.recipe.librecipe.execute.
execute
'
,
'slapos.recipe.librecipe.execute.
generic_exec
'
,
[
self
.
options
[
'server_bin'
],
config_file
]
((
self
.
options
[
'server_bin'
],
config_file
),)
)
)
path_list
.
append
(
redis
)
path_list
.
append
(
redis
)
...
@@ -67,11 +67,20 @@ class Recipe(GenericBaseRecipe):
...
@@ -67,11 +67,20 @@ class Recipe(GenericBaseRecipe):
if
promise_script
:
if
promise_script
:
promise
=
self
.
createPythonScript
(
promise
=
self
.
createPythonScript
(
promise_script
,
promise_script
,
'%s.promise.main'
%
__name__
,
__name__
+
'.promise'
,
dict
(
host
=
self
.
options
[
'ipv6'
],
port
=
self
.
options
[
'port'
]
,
(
self
.
options
[
'ipv6'
],
int
(
self
.
options
[
'port'
])
,
unixsocket
=
self
.
options
.
get
(
'unixsocket'
)
)
self
.
options
.
get
(
'unixsocket'
)
)
)
)
path_list
.
append
(
promise
)
path_list
.
append
(
promise
)
return
path_list
return
path_list
def
promise
(
host
,
port
,
unixsocket
):
from
.MyRedis2410
import
Redis
try
:
r
=
Redis
(
host
=
host
,
port
=
port
,
unix_socket_path
=
unixsocket
,
db
=
0
)
r
.
publish
(
"Promise-Service"
,
"SlapOS Promise"
)
r
.
connection_pool
.
disconnect
()
except
Exception
,
e
:
sys
.
exit
(
e
)
slapos/recipe/redis/promise.py
deleted
100644 → 0
View file @
d55a5d17
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import
slapos.recipe.redis.MyRedis2410
as
redis
import
sys
def
main
(
args
):
host
=
args
[
'host'
]
port
=
int
(
args
[
'port'
])
unixsocket
=
args
[
'unixsocket'
]
try
:
r
=
redis
.
Redis
(
host
=
host
,
port
=
port
,
unix_socket_path
=
unixsocket
,
db
=
0
)
r
.
publish
(
"Promise-Service"
,
"SlapOS Promise"
)
r
.
connection_pool
.
disconnect
()
sys
.
exit
(
0
)
except
Exception
,
e
:
print
str
(
e
)
sys
.
exit
(
1
)
\ No newline at end of file
slapos/recipe/seleniumrunner/__init__.py
View file @
dfab94f0
...
@@ -25,23 +25,15 @@
...
@@ -25,23 +25,15 @@
#
#
#############################################################################
#############################################################################
import
os
import
sys
import
zc.buildout
from
slapos.recipe.librecipe
import
BaseSlapRecipe
from
slapos.recipe.librecipe
import
GenericBaseRecipe
from
slapos.recipe.librecipe
import
GenericBaseRecipe
class
Recipe
(
GenericBaseRecipe
):
class
Recipe
(
GenericBaseRecipe
):
def
install
(
self
):
runner
=
self
.
createPythonScript
(
def
install
(
self
):
return
self
.
createPythonScript
(
self
.
options
[
'runner-path'
],
self
.
options
[
'runner-path'
],
__name__
+
'.testrunner.run'
,
__name__
+
'.testrunner.run'
,
arguments
=
[
self
.
options
[
'suite-url'
],
(
self
.
options
[
'suite-url'
],
self
.
options
[
'report-url'
],
self
.
options
[
'report-url'
],
self
.
options
[
'report-project'
],
self
.
options
[
'report-project'
],
self
.
options
[
'browser'
],
self
.
options
[
'browser'
]))
])
return
[
runner
]
slapos/recipe/seleniumrunner/testrunner.py
View file @
dfab94f0
...
@@ -36,12 +36,7 @@ import urlparse
...
@@ -36,12 +36,7 @@ import urlparse
from
subprocess
import
Popen
,
PIPE
from
subprocess
import
Popen
,
PIPE
import
signal
import
signal
def
run
(
args
):
def
run
(
suite_url
,
report_url
,
project
,
browser_binary
):
suite_url
=
args
[
0
]
report_url
=
args
[
1
]
project
=
args
[
2
]
browser_binary
=
args
[
3
]
suite_parsed
=
urlparse
.
urlparse
(
suite_url
)
suite_parsed
=
urlparse
.
urlparse
(
suite_url
)
config
=
{
config
=
{
...
...
slapos/recipe/shell.py
View file @
dfab94f0
...
@@ -31,27 +31,15 @@ from slapos.recipe.librecipe import GenericBaseRecipe
...
@@ -31,27 +31,15 @@ from slapos.recipe.librecipe import GenericBaseRecipe
class
Recipe
(
GenericBaseRecipe
):
class
Recipe
(
GenericBaseRecipe
):
def
install
(
self
):
def
install
(
self
):
env
=
os
.
environ
.
copy
()
path_list
=
self
.
options
[
'path'
].
split
(
'
\
n
'
)
env
.
update
(
PATH
=
':'
.
join
(
path_list
))
env
.
update
(
SHELL
=
self
.
options
[
'shell'
])
env
.
update
(
HOME
=
self
.
options
[
'home'
])
ps1
=
self
.
options
.
get
(
'ps1'
)
ps1
=
self
.
options
.
get
(
'ps1'
)
if
ps1
is
not
None
:
env
=
{
env
.
update
(
PS1
=
str
(
json
.
loads
(
ps1
)))
'HOME'
:
self
.
options
[
'home'
],
else
:
'PATH'
:
':'
.
join
(
self
.
options
[
'path'
].
split
(
'
\
n
'
)),
env
.
update
(
PS1
=
env
.
get
(
'PS1'
,
'> '
))
'PS1'
:
str
(
json
.
loads
(
ps1
))
if
ps1
else
os
.
getenv
(
'PS1'
,
'> '
),
'SHELL'
:
self
.
options
[
'shell'
],
wrapper
=
self
.
createPythonScript
(
}
return
self
.
createPythonScript
(
self
.
options
[
'wrapper'
],
self
.
options
[
'wrapper'
],
'slapos.recipe.librecipe.execute.executee'
,
'slapos.recipe.librecipe.execute.generic_exec'
,
[
# Executable
((
self
.
options
[
'shell'
],),
env
),
[
self
.
options
[
'shell'
]],
# Environment
env
]
)
)
return
[
wrapper
]
slapos/recipe/shellinabox.py
View file @
dfab94f0
...
@@ -33,24 +33,14 @@ import shlex
...
@@ -33,24 +33,14 @@ import shlex
from
slapos.recipe.librecipe
import
GenericBaseRecipe
from
slapos.recipe.librecipe
import
GenericBaseRecipe
def
login_shell
(
args
):
def
login_shell
(
password_file
,
shell
):
password_file
=
args
[
'password-file'
]
if
password_file
:
if
password_file
:
with
open
(
password_file
,
'r'
)
as
password_file
:
with
open
(
password_file
,
'r'
)
as
password_file
:
password
=
password_file
.
read
()
password
=
password_file
.
read
()
if
(
password
!=
''
):
if
not
password
or
hmac
.
compare_digest
(
getpass
(),
password
):
entered_password
=
getpass
()
commandline
=
shlex
.
split
(
shell
)
else
:
os
.
execv
(
commandline
[
0
],
commandline
)
entered_password
=
''
if
not
hmac
.
compare_digest
(
entered_password
,
password
):
return
1
else
:
commandline
=
shlex
.
split
(
args
[
'shell'
])
path
=
commandline
[
0
]
os
.
execv
(
path
,
commandline
)
else
:
return
1
return
1
def
shellinabox
(
args
):
def
shellinabox
(
args
):
...
@@ -95,22 +85,16 @@ def shellinabox(args):
...
@@ -95,22 +85,16 @@ def shellinabox(args):
class
Recipe
(
GenericBaseRecipe
):
class
Recipe
(
GenericBaseRecipe
):
def
install
(
self
):
def
install
(
self
):
path_list
=
[]
login_shell_wrapper
=
self
.
createPythonScript
(
login_shell
=
self
.
createPythonScript
(
self
.
options
[
'login-shell'
],
self
.
options
[
'login-shell'
],
'%s.login_shell'
%
__name__
,
__name__
+
'.login_shell'
,
{
(
self
.
options
[
'password-file'
],
self
.
options
[
'shell'
])
'password-file'
:
self
.
options
[
'password-file'
],
'shell'
:
self
.
options
[
'shell'
]
}
)
)
path_list
.
append
(
login_shell
)
wrapper
=
self
.
createPythonScript
(
shellinabox_
wrapper
=
self
.
createPythonScript
(
self
.
options
[
'wrapper'
],
self
.
options
[
'wrapper'
],
'%s.shellinabox'
%
__name__
,
__name__
+
'.shellinabox'
,
dict
(
(
dict
(
certificate_dir
=
self
.
options
[
'certificate-directory'
],
certificate_dir
=
self
.
options
[
'certificate-directory'
],
ssl_key
=
self
.
options
[
'key-file'
],
ssl_key
=
self
.
options
[
'key-file'
],
ssl_certificate
=
self
.
options
[
'cert-file'
],
ssl_certificate
=
self
.
options
[
'cert-file'
],
...
@@ -118,9 +102,8 @@ class Recipe(GenericBaseRecipe):
...
@@ -118,9 +102,8 @@ class Recipe(GenericBaseRecipe):
directory
=
self
.
options
[
'directory'
],
directory
=
self
.
options
[
'directory'
],
ipv6
=
self
.
options
[
'ipv6'
],
ipv6
=
self
.
options
[
'ipv6'
],
port
=
self
.
options
[
'port'
],
port
=
self
.
options
[
'port'
],
login_shell
=
login_shell
,
login_shell
=
login_shell
_wrapper
,
)
),
)
)
)
path_list
.
append
(
wrapper
)
return
[
wrapper
]
return
login_shell_wrapper
,
shellinabox_wrapper
slapos/recipe/signal_wrapper.py
View file @
dfab94f0
...
@@ -32,6 +32,6 @@ class Recipe(GenericBaseRecipe):
...
@@ -32,6 +32,6 @@ class Recipe(GenericBaseRecipe):
self
.
createPythonScript
(
self
.
createPythonScript
(
self
.
options
[
'wrapper-path'
],
self
.
options
[
'wrapper-path'
],
'slapos.recipe.librecipe.execute.execute_with_signal_translation'
,
'slapos.recipe.librecipe.execute.execute_with_signal_translation'
,
[
self
.
options
[
'wrapped-path'
]]
((
self
.
options
[
'wrapped-path'
],),)
)
)
]
]
slapos/recipe/simplehttpserver/__init__.py
View file @
dfab94f0
...
@@ -68,9 +68,8 @@ class Recipe(GenericBaseRecipe):
...
@@ -68,9 +68,8 @@ class Recipe(GenericBaseRecipe):
'root-dir'
:
self
.
options
[
'root-dir'
]
'root-dir'
:
self
.
options
[
'root-dir'
]
}
}
server
=
self
.
createPythonScript
(
return
self
.
createPythonScript
(
self
.
options
[
'wrapper'
].
strip
(),
self
.
options
[
'wrapper'
].
strip
(),
'%s.simplehttpserver.run'
%
__name__
,
parameters
__name__
+
'.simplehttpserver.run'
,
(
parameters
,)
)
)
return
[
server
]
slapos/recipe/simplelogger.py
View file @
dfab94f0
...
@@ -29,9 +29,9 @@ import time
...
@@ -29,9 +29,9 @@ import time
from
slapos.recipe.librecipe
import
GenericBaseRecipe
from
slapos.recipe.librecipe
import
GenericBaseRecipe
def
log
(
args
):
def
log
(
filename
):
prefix
=
time
.
strftime
(
'%Y-%m-%d.%H:%M.%s:'
)
prefix
=
time
.
strftime
(
'%Y-%m-%d.%H:%M.%s:'
)
with
open
(
args
[
'filename'
],
'aw
'
)
as
logfile
:
with
open
(
filename
,
'a
'
)
as
logfile
:
for
line
in
sys
.
stdin
:
for
line
in
sys
.
stdin
:
print
>>
logfile
,
prefix
,
line
,
print
>>
logfile
,
prefix
,
line
,
print
>>
logfile
,
prefix
,
'------------------------'
print
>>
logfile
,
prefix
,
'------------------------'
...
@@ -39,10 +39,7 @@ def log(args):
...
@@ -39,10 +39,7 @@ def log(args):
class
Recipe
(
GenericBaseRecipe
):
class
Recipe
(
GenericBaseRecipe
):
def
install
(
self
):
def
install
(
self
):
wrapper
=
self
.
options
[
'wrapper'
]
return
self
.
createPythonScript
(
log
=
self
.
options
[
'log'
]
self
.
options
[
'wrapper'
],
script
=
self
.
createPythonScript
(
wrapper
,
__name__
+
'.log'
,
__name__
+
'.log'
,
arguments
=
dict
(
filename
=
log
))
(
self
.
options
[
'log'
],))
return
[
script
]
slapos/recipe/sphinx/__init__.py
View file @
dfab94f0
...
@@ -50,9 +50,9 @@ class Recipe(GenericBaseRecipe):
...
@@ -50,9 +50,9 @@ class Recipe(GenericBaseRecipe):
# Create init script
# Create init script
wrapper
=
self
.
createPythonScript
(
wrapper
=
self
.
createPythonScript
(
self
.
options
[
'wrapper'
],
self
.
options
[
'wrapper'
],
'slapos.recipe.librecipe.execute.
execute
'
,
'slapos.recipe.librecipe.execute.
generic_exec
'
,
[
self
.
options
[
'sphinx-searchd-binary'
].
strip
(),
'-c'
,
((
self
.
options
[
'sphinx-searchd-binary'
].
strip
(),
'-c'
,
sphinx_conf_path
,
'--nodetach'
]
,
sphinx_conf_path
,
'--nodetach'
),)
,
)
)
return
[
wrapper
,
sphinx_conf_path
]
return
[
wrapper
,
sphinx_conf_path
]
slapos/recipe/squid/__init__.py
View file @
dfab94f0
...
@@ -80,19 +80,15 @@ class Recipe(GenericBaseRecipe):
...
@@ -80,19 +80,15 @@ class Recipe(GenericBaseRecipe):
# Prepare directories
# Prepare directories
prepare_path
=
self
.
createPythonScript
(
prepare_path
=
self
.
createPythonScript
(
self
.
options
[
'prepare-path'
],
self
.
options
[
'prepare-path'
],
'slapos.recipe.librecipe.execute.execute'
,
'slapos.recipe.librecipe.execute.generic_exec'
,
arguments
=
[
self
.
options
[
'binary-path'
].
strip
(),
((
self
.
options
[
'binary-path'
].
strip
(),
'-z'
,
'-z'
,
'-f'
,
configuration_path
),))
'-f'
,
configuration_path
,
],)
# Create running wrapper
# Create running wrapper
wrapper_path
=
self
.
createPythonScript
(
wrapper_path
=
self
.
createPythonScript
(
self
.
options
[
'wrapper-path'
],
self
.
options
[
'wrapper-path'
],
'slapos.recipe.librecipe.execute.execute'
,
'slapos.recipe.librecipe.execute.generic_exec'
,
arguments
=
[
self
.
options
[
'binary-path'
].
strip
(),
((
self
.
options
[
'binary-path'
].
strip
(),
'-N'
,
'-N'
,
'-f'
,
configuration_path
),))
'-f'
,
configuration_path
,
],)
return
[
configuration_path
,
wrapper_path
,
prepare_path
]
return
[
configuration_path
,
wrapper_path
,
prepare_path
]
slapos/recipe/sshkeys_authority.py
View file @
dfab94f0
...
@@ -34,17 +34,14 @@ from slapos.recipe.librecipe import GenericBaseRecipe
...
@@ -34,17 +34,14 @@ from slapos.recipe.librecipe import GenericBaseRecipe
from
slapos.recipe.librecipe.inotify
import
subfiles
from
slapos.recipe.librecipe.inotify
import
subfiles
# This authority only works with dropbear or openssh sshkey generators
# This authority only works with dropbear or openssh sshkey generators
def
sshkeys_authority
(
args
):
def
sshkeys_authority
(
request_directory
,
keygen_binary
):
requests_directory
=
args
[
'requests'
]
keygen_binary
=
args
[
'sshkeygen'
]
if
'openssh'
in
keygen_binary
:
if
'openssh'
in
keygen_binary
:
authority_type
=
'openssh'
authority_type
=
'openssh'
else
:
else
:
# Keep dropbear for compatibility
# Keep dropbear for compatibility
authority_type
=
'dropbear'
authority_type
=
'dropbear'
for
request_filename
in
subfiles
(
request
s
_directory
):
for
request_filename
in
subfiles
(
request_directory
):
with
open
(
request_filename
)
as
request_file
:
with
open
(
request_filename
)
as
request_file
:
request
=
json
.
load
(
request_file
)
request
=
json
.
load
(
request_file
)
...
@@ -98,18 +95,13 @@ def sshkeys_authority(args):
...
@@ -98,18 +95,13 @@ def sshkeys_authority(args):
public_key_file
.
write
(
public_key_value
)
public_key_file
.
write
(
public_key_value
)
class
Recipe
(
GenericBaseRecipe
):
class
Recipe
(
GenericBaseRecipe
):
def
install
(
self
):
def
install
(
self
):
args
=
dict
(
return
self
.
createPythonScript
(
self
.
options
[
'wrapper'
],
requests
=
self
.
options
[
'request-directory'
],
__name__
+
'.sshkeys_authority'
,
sshkeygen
=
self
.
options
[
'keygen-binary'
],
(
self
.
options
[
'request-directory'
],
)
self
.
options
[
'keygen-binary'
]))
wrapper
=
self
.
createPythonScript
(
self
.
options
[
'wrapper'
],
__name__
+
'.sshkeys_authority'
,
args
)
return
[
wrapper
]
class
Request
(
GenericBaseRecipe
):
class
Request
(
GenericBaseRecipe
):
...
@@ -162,9 +154,8 @@ class Request(GenericBaseRecipe):
...
@@ -162,9 +154,8 @@ class Request(GenericBaseRecipe):
wrapper
=
self
.
createPythonScript
(
wrapper
=
self
.
createPythonScript
(
self
.
options
[
'wrapper'
],
self
.
options
[
'wrapper'
],
'slapos.recipe.librecipe.execute.execute_wait'
,
'slapos.recipe.librecipe.execute.generic_exec'
,
[
[
self
.
options
[
'executable'
]],
((
self
.
options
[
'executable'
],),),
[
self
.
private_key
,
self
.
public_key
]
])
{
'wait_list'
:
(
self
.
private_key
,
self
.
public_key
)})
return
[
request_file
,
wrapper
,
public_key_link
,
private_key_link
]
return
[
request_file
,
wrapper
,
public_key_link
,
private_key_link
]
slapos/recipe/stunnel/__init__.py
View file @
dfab94f0
...
@@ -30,13 +30,16 @@ import errno
...
@@ -30,13 +30,16 @@ import errno
from
slapos.recipe.librecipe
import
GenericBaseRecipe
from
slapos.recipe.librecipe
import
GenericBaseRecipe
def
post_rotate
(
args
):
def
kill
(
pid_file
,
sig
=
signal
.
SIGUSR1
):
pid_file
=
args
[
'pid_file'
]
if
os
.
path
.
exists
(
pid_file
):
with
open
(
pid_file
)
as
f
:
if
os
.
path
.
exist
(
pid_file
):
pid
=
int
(
f
.
read
().
strip
())
with
open
(
pid_file
,
'r'
)
as
file_
:
try
:
pid
=
file_
.
read
().
strip
()
os
.
kill
(
pid
,
sig
)
os
.
kill
(
pid
,
signal
.
SIGUSR1
)
except
OSError
,
e
:
if
e
.
errno
!=
errno
.
ESRCH
:
# No such process
raise
e
os
.
unlink
(
pid_file
)
class
Recipe
(
GenericBaseRecipe
):
class
Recipe
(
GenericBaseRecipe
):
...
@@ -78,26 +81,17 @@ class Recipe(GenericBaseRecipe):
...
@@ -78,26 +81,17 @@ class Recipe(GenericBaseRecipe):
wrapper
=
self
.
createPythonScript
(
wrapper
=
self
.
createPythonScript
(
self
.
options
[
'wrapper'
],
self
.
options
[
'wrapper'
],
'slapos.recipe.librecipe.execute.
execute
'
,
'slapos.recipe.librecipe.execute.
generic_exec
'
,
[
self
.
options
[
'stunnel-binary'
],
conf_file
]
((
self
.
options
[
'stunnel-binary'
],
conf_file
),)
)
)
path_list
.
append
(
wrapper
)
path_list
.
append
(
wrapper
)
if
os
.
path
.
exists
(
pid_file
):
with
open
(
pid_file
,
'r'
)
as
file_
:
pid
=
file_
.
read
().
strip
()
# Reload configuration
# Reload configuration
try
:
kill
(
pid_file
,
signal
.
SIGHUP
)
os
.
kill
(
int
(
pid
,
10
),
signal
.
SIGHUP
)
except
OSError
,
e
:
if
e
.
errno
==
errno
.
ESRCH
:
# No such process
os
.
unlink
(
pid_file
)
else
:
raise
e
if
'post-rotate-script'
in
self
.
options
:
if
'post-rotate-script'
in
self
.
options
:
self
.
createPythonScript
(
self
.
options
[
'post-rotate-script'
],
path_list
.
append
(
self
.
createPythonScript
(
__name__
+
'post_rotate'
,
self
.
options
[
'post-rotate-script'
]
,
dict
(
pid_file
=
pid_file
))
__name__
+
'.kill'
,
(
pid_file
,)
))
return
path_list
return
path_list
slapos/recipe/tidstorage/__init__.py
View file @
dfab94f0
...
@@ -37,18 +37,18 @@ class Recipe(GenericBaseRecipe):
...
@@ -37,18 +37,18 @@ class Recipe(GenericBaseRecipe):
wrapper
=
self
.
options
.
get
(
'tidstorage-wrapper'
)
wrapper
=
self
.
options
.
get
(
'tidstorage-wrapper'
)
wrapper
and
r
.
append
(
self
.
createPythonScript
(
wrapper
,
wrapper
and
r
.
append
(
self
.
createPythonScript
(
wrapper
,
'slapos.recipe.librecipe.execute.
execute
'
,
'slapos.recipe.librecipe.execute.
generic_exec
'
,
[
self
.
options
[
'tidstoraged-binary'
],
'--nofork'
,
'--config'
,
((
self
.
options
[
'tidstoraged-binary'
]
,
configuration_file
]
))
'--nofork'
,
'--config'
,
configuration_file
),)
))
r
.
append
(
self
.
createPythonScript
(
r
.
append
(
self
.
createPythonScript
(
self
.
options
[
'repozo-wrapper'
],
self
.
options
[
'repozo-wrapper'
],
'slapos.recipe.librecipe.execute.
execute
'
,
'slapos.recipe.librecipe.execute.
generic_exec
'
,
[
self
.
options
[
'tidstorage-repozo-binary'
],
((
self
.
options
[
'tidstorage-repozo-binary'
],
'--config'
,
configuration_file
,
'--config'
,
configuration_file
,
'--repozo'
,
self
.
options
[
'repozo-binary'
],
'--repozo'
,
self
.
options
[
'repozo-binary'
],
'--gzip'
,
'--gzip'
,
'--quick'
,
'--quick'
,
]
))
),)
))
return
r
return
r
slapos/recipe/wrapper.py
View file @
dfab94f0
...
@@ -63,12 +63,17 @@ class Recipe(GenericBaseRecipe):
...
@@ -63,12 +63,17 @@ class Recipe(GenericBaseRecipe):
# More complex needs: create a Python script as wrapper
# More complex needs: create a Python script as wrapper
if
wait_files
is
not
None
:
extra_environ
=
{}
wait_files
=
[
filename
.
strip
()
for
filename
in
wait_files
.
split
()
if
environment
:
if
filename
.
strip
()]
for
line
in
environment
.
splitlines
():
if
environment
is
not
None
:
line
=
line
.
strip
()
environment
=
dict
((
k
.
strip
(),
v
.
strip
())
for
k
,
v
in
[
if
line
:
line
.
split
(
'='
)
for
line
in
environment
.
splitlines
()
if
line
.
strip
()
])
k
,
v
=
line
.
split
(
'='
)
extra_environ
[
k
.
rstrip
()]
=
v
.
lstrip
()
args
=
[
command_line
,
extra_environ
]
if
wait_files
:
args
.
append
(
wait_files
.
split
())
# We create a python script and a wrapper around the python
# We create a python script and a wrapper around the python
# script because the python script might have a too long #! line
# script because the python script might have a too long #! line
...
@@ -81,7 +86,7 @@ class Recipe(GenericBaseRecipe):
...
@@ -81,7 +86,7 @@ class Recipe(GenericBaseRecipe):
python_script
=
self
.
createPythonScript
(
python_script
=
self
.
createPythonScript
(
base_script_path
+
'.py'
,
base_script_path
+
'.py'
,
'slapos.recipe.librecipe.execute.generic_exec'
,
'slapos.recipe.librecipe.execute.generic_exec'
,
(
command_line
,
wait_files
,
environment
,),
)
args
)
return
[
python_script
,
self
.
createWrapper
(
return
[
python_script
,
self
.
createWrapper
(
name
=
wrapper_path
,
name
=
wrapper_path
,
command
=
python_script
,
command
=
python_script
,
...
...
slapos/recipe/zabbixagent/__init__.py
View file @
dfab94f0
...
@@ -71,10 +71,10 @@ class Recipe(BaseSlapRecipe):
...
@@ -71,10 +71,10 @@ class Recipe(BaseSlapRecipe):
self
.
_createDirectory
(
cron_d
)
self
.
_createDirectory
(
cron_d
)
self
.
_createDirectory
(
crontabs
)
self
.
_createDirectory
(
crontabs
)
wrapper
=
zc
.
buildout
.
easy_install
.
scripts
([(
'crond'
,
wrapper
=
zc
.
buildout
.
easy_install
.
scripts
([(
'crond'
,
'slapos.recipe.librecipe.execute'
,
'
execute'
)],
self
.
ws
,
sys
.
executable
,
'slapos.recipe.librecipe.execute'
,
'
generic_exec'
)],
self
.
ws
,
s
elf
.
wrapper_directory
,
arguments
=
[
s
ys
.
executable
,
self
.
wrapper_directory
,
arguments
=
repr
((
self
.
options
[
'dcrond_binary'
].
strip
(),
'-s'
,
cron_d
,
'-c'
,
crontabs
,
self
.
options
[
'dcrond_binary'
].
strip
(),
'-s'
,
cron_d
,
'-c'
,
crontabs
,
'-t'
,
timestamps
,
'-f'
,
'-l'
,
'5'
,
'-M'
,
catcher
]
'-t'
,
timestamps
,
'-f'
,
'-l'
,
'5'
,
'-M'
,
catcher
))[
1
:
-
1
]
)[
0
]
)[
0
]
self
.
path_list
.
append
(
wrapper
)
self
.
path_list
.
append
(
wrapper
)
return
cron_d
return
cron_d
...
@@ -101,10 +101,10 @@ class Recipe(BaseSlapRecipe):
...
@@ -101,10 +101,10 @@ class Recipe(BaseSlapRecipe):
self
.
path_list
.
append
(
zabbix_agentd_path
)
self
.
path_list
.
append
(
zabbix_agentd_path
)
wrapper
=
zc
.
buildout
.
easy_install
.
scripts
([(
'zabbixagentd'
,
wrapper
=
zc
.
buildout
.
easy_install
.
scripts
([(
'zabbixagentd'
,
'slapos.recipe.librecipe.execute'
,
'
execute'
)],
self
.
ws
,
sys
.
executable
,
'slapos.recipe.librecipe.execute'
,
'
generic_exec'
)],
self
.
ws
,
s
elf
.
bin_directory
,
arguments
=
[
s
ys
.
executable
,
self
.
bin_directory
,
arguments
=
repr
((
self
.
options
[
'zabbix_agentd_binary'
].
strip
(),
'-c'
,
self
.
options
[
'zabbix_agentd_binary'
].
strip
(),
'-c'
,
zabbix_agentd_path
])[
0
]
zabbix_agentd_path
))[
1
:
-
1
])[
0
]
self
.
path_list
.
extend
(
zc
.
buildout
.
easy_install
.
scripts
([
self
.
path_list
.
extend
(
zc
.
buildout
.
easy_install
.
scripts
([
(
'zabbixagentd'
,
__name__
+
'.svcdaemon'
,
'svcdaemon'
)],
(
'zabbixagentd'
,
__name__
+
'.svcdaemon'
,
'svcdaemon'
)],
...
...
slapos/recipe/zeo/__init__.py
View file @
dfab94f0
...
@@ -91,8 +91,8 @@ class Recipe(GenericBaseRecipe):
...
@@ -91,8 +91,8 @@ class Recipe(GenericBaseRecipe):
# Create running wrapper
# Create running wrapper
wrapper_path
=
self
.
createPythonScript
(
wrapper_path
=
self
.
createPythonScript
(
self
.
options
[
'wrapper-path'
],
self
.
options
[
'wrapper-path'
],
'slapos.recipe.librecipe.execute.
execute
'
,
'slapos.recipe.librecipe.execute.
generic_exec
'
,
arguments
=
[
self
.
options
[
'binary-path'
].
strip
(),
'-C'
,
((
self
.
options
[
'binary-path'
].
strip
()
,
self
.
options
[
'conf-path'
]],
)
'-C'
,
self
.
options
[
'conf-path'
]),)
)
return
[
configuration_path
,
wrapper_path
]
return
[
configuration_path
,
wrapper_path
]
slapos/test/recipe/test_re6stnet.py
View file @
dfab94f0
...
@@ -79,15 +79,14 @@ class Re6stnetTest(unittest.TestCase):
...
@@ -79,15 +79,14 @@ class Re6stnetTest(unittest.TestCase):
token_file
=
os
.
path
.
join
(
self
.
options
[
'conf-dir'
],
'token.json'
)
token_file
=
os
.
path
.
join
(
self
.
options
[
'conf-dir'
],
'token.json'
)
with
open
(
path
,
'r'
)
as
f
:
with
open
(
path
,
'r'
)
as
f
:
content
=
f
.
read
()
content
=
f
.
read
()
self
.
assertIn
(
"'token_json': '%s'"
%
token_file
,
content
)
self
.
assertIn
(
"('http://%s:%s/', %r, %r,"
%
(
self
.
options
[
'ipv4'
],
self
.
options
[
'port'
],
self
.
token_dir
,
token_file
),
content
)
self
.
assertIn
(
"'partition_id': 'slappart0'"
,
content
)
self
.
assertIn
(
"'partition_id': 'slappart0'"
,
content
)
self
.
assertIn
(
"'computer_id': 'comp-test'"
,
content
)
self
.
assertIn
(
"'computer_
gu
id': 'comp-test'"
,
content
)
self
.
assertIn
(
"'key_file': '/path/to/key'"
,
content
)
self
.
assertIn
(
"'key_file': '/path/to/key'"
,
content
)
self
.
assertIn
(
"'cert_file': '/path/to/cert'"
,
content
)
self
.
assertIn
(
"'cert_file': '/path/to/cert'"
,
content
)
self
.
assertIn
(
"'server_url': 'http://server.com'"
,
content
)
self
.
assertIn
(
"'master_url': 'http://server.com'"
,
content
)
self
.
assertIn
(
"'token_base_path': '%s'"
%
self
.
token_dir
,
content
)
self
.
assertIn
(
"'registry_url': 'http://%s:%s/'"
%
(
self
.
options
[
'ipv4'
],
self
.
options
[
'port'
]),
content
)
def
fake_generateCertificates
(
self
):
def
fake_generateCertificates
(
self
):
return
return
...
...
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