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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Steven Gueguen
slapos
Commits
052a390a
Commit
052a390a
authored
Dec 13, 2012
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'agent'
parents
6db4a37f
a14ef9a2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
147 additions
and
93 deletions
+147
-93
slapos/recipe/agent/__init__.py
slapos/recipe/agent/__init__.py
+31
-54
software/agent/instance-agent.cfg
software/agent/instance-agent.cfg
+31
-0
software/agent/instance.cfg
software/agent/instance.cfg
+5
-17
software/agent/software.cfg
software/agent/software.cfg
+80
-22
No files found.
slapos/recipe/agent/__init__.py
View file @
052a390a
...
...
@@ -25,65 +25,42 @@
#
#############################################################################
import
os
import
sys
import
zc.buildout
import
slapos.slap
from
slapos.recipe.librecipe
import
BaseSlapRecipe
from
slapos.recipe.librecipe
import
GenericSlapRecipe
import
json
import
ConfigParser
from
slapos.recipe.librecipe
import
GenericBaseRecipe
import
sys
# XXX: BaseSlapRecipe and GenericSlapRecipe are deprecated, use
# GenericBaseRecipe and move partition parameter fetching to software release.
class
Recipe
(
BaseSlapRecipe
,
GenericSlapRecipe
):
class
Recipe
(
GenericBaseRecipe
):
def
install
(
self
):
self
.
path_list
=
[]
crond
=
self
.
installCrond
()
path_list
=
[]
configuration_path
=
self
.
options
[
"config"
]
header
=
"""[DEFAULT]
master_url = %s
key = %s
slap
=
slapos
.
slap
.
slap
()
slap
.
initializeConnection
(
self
.
server_url
,
self
.
key_file
,
self
.
cert_file
)
parameter_dict
=
slap
.
registerComputerPartition
(
self
.
computer_id
,
self
.
computer_partition_id
,
).
getInstanceParameterDict
()
cert = %s
max_install_duration = %s
max_uninstall_duration = %s
max_request_duration = %s
max_destroy_duration = %s
"""
%
(
self
.
options
[
"master-url"
],
"
\
n
"
.
join
(
self
.
options
[
"key"
].
split
(
"
\
n
"
)),
"
\
n
"
.
join
(
self
.
options
[
"cert"
].
split
(
"
\
n
"
)),
self
.
options
[
"default_max_install_duration"
],
self
.
options
[
"default_max_uninstall_duration"
],
self
.
options
[
"default_max_request_duration"
],
self
.
options
[
"default_max_destroy_duration"
])
# XXX: should probably expect one more (SR-originating) parameter instead
# of using self.work_directory .
configuration_path
=
os
.
path
.
join
(
self
.
work_directory
,
"agent.cfg"
)
with
open
(
configuration_path
,
"w"
)
as
configuration
:
configuration
.
write
(
parameter_dict
[
"configuration"
])
agent_crond_path
=
os
.
path
.
join
(
crond
,
"agent"
)
with
open
(
agent_crond_path
,
"w"
)
as
agent_crond
:
agent_crond
.
write
(
"*/5 * * * * %s -S %s --pidfile=%s --log=%s "
"%s 2>&1 > /dev/null
\
n
"
%
(
self
.
options
[
"python_binary"
],
self
.
options
[
"agent_binary"
],
self
.
options
[
"pidfile"
],
self
.
options
[
"log"
],
configuration_path
,
))
configuration
.
write
(
header
+
self
.
options
[
"configuration"
])
path_list
.
append
(
self
.
createPythonScript
(
self
.
options
[
'wrapper'
],
'slapos.recipe.librecipe.execute.execute'
,
[
self
.
options
[
"agent_binary"
],
'--pidfile=%s'
%
self
.
options
[
"pidfile"
],
"--log=%s"
%
self
.
options
[
"log"
],
configuration_path
]))
return
self
.
path_list
+
[
configuration_path
,
agent_crond_path
]
path_list
.
append
(
configuration_path
)
def
installCrond
(
self
):
_
,
ws
=
self
.
egg
.
working_set
()
timestamps
=
self
.
createDataDirectory
(
'cronstamps'
)
cron_output
=
os
.
path
.
join
(
self
.
log_directory
,
'cron-output'
)
self
.
_createDirectory
(
cron_output
)
catcher
=
zc
.
buildout
.
easy_install
.
scripts
([(
'catchcron'
,
__name__
+
'.catdatefile'
,
'catdatefile'
)],
ws
,
sys
.
executable
,
self
.
bin_directory
,
arguments
=
[
cron_output
])[
0
]
self
.
path_list
.
append
(
catcher
)
cron_d
=
os
.
path
.
join
(
self
.
etc_directory
,
'cron.d'
)
crontabs
=
os
.
path
.
join
(
self
.
etc_directory
,
'crontabs'
)
self
.
_createDirectory
(
cron_d
)
self
.
_createDirectory
(
crontabs
)
wrapper
=
zc
.
buildout
.
easy_install
.
scripts
([(
'crond'
,
'slapos.recipe.librecipe.execute'
,
'execute'
)],
ws
,
sys
.
executable
,
self
.
wrapper_directory
,
arguments
=
[
self
.
options
[
'dcrond_binary'
].
strip
(),
'-s'
,
cron_d
,
'-c'
,
crontabs
,
'-t'
,
timestamps
,
'-f'
,
'-l'
,
'5'
,
'-M'
,
catcher
]
)[
0
]
self
.
path_list
.
append
(
wrapper
)
return
cron_d
return
path_list
software/agent/instance-agent.cfg
0 → 100644
View file @
052a390a
[buildout]
parts =
instance
eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true
[instance]
recipe = ${instance-recipe:egg}:${instance-recipe:module}
agent_binary = ${buildout:directory}/bin/agent
pidfile = $${directory:srv}/agent.pid
log = $${directory:agentlog}/agent.log
wrapper = $${directory:run}/agent
config = $${directory:etc}/agent.cfg
master-url = $${slap-parameter:master-url}
key = $${slap-parameter:userkey}
cert = $${slap-parameter:usercertificate}
configuration = $${slap-parameter:configuration}
default_max_install_duration = $${slap-parameter:default_max_install_duration}
default_max_uninstall_duration = $${slap-parameter:default_max_uninstall_duration}
default_max_request_duration = $${slap-parameter:default_max_request_duration}
default_max_destroy_duration = $${slap-parameter:default_max_destroy_duration}
[directory]
recipe = slapos.cookbook:mkdirectory
etc = $${buildout:directory}/etc
run = $${:etc}/run
agentlog = $${buildout:directory}/var/log/agent
srv = $${buildout:directory}/srv
bin = $${buildout:directory}/bin
software/agent/instance.cfg
View file @
052a390a
[buildout]
parts =
instanc
e
switch_softwaretyp
e
eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true
[instance]
recipe = ${instance-recipe:egg}:${instance-recipe:module}
agent_binary = ${buildout:directory}/bin/agent
report_start = ${buildout:directory}/bin/report_start
report_stop = ${buildout:directory}/bin/report_stop
dcrond_binary = ${dcron:location}/sbin/crond
python_binary = ${python2.7:location}/bin/python
pidfile = $${rootdirectory:run}/agent.pid
log = $${rootdirectory:agentlog}/agent.log
[rootdirectory]
recipe = slapos.cookbook:mkdirectory
run = $${buildout:directory}/etc/run
agentlog = $${buildout:directory}/var/log/agent
srv = $${buildout:directory}/srv
bin = $${buildout:directory}/bin
[switch_softwaretype]
recipe = slapos.cookbook:softwaretype
default = ${template-agent:output}
software/agent/software.cfg
View file @
052a390a
[buildout]
extends =
../../component/dcron/buildout.cfg
../../component/python-2.7/buildout.cfg
../../component/lxml-python/buildout.cfg
../../component/git/buildout.cfg
../../stack/slapos.cfg
develop =
${:parts-directory}/slapos.cookbook-repository
${:parts-directory}/slapos.toolbox-repository
parts =
template
eggs
template-agent
slapos.cookbook-repository
check-recipe
slapos.toolbox-repository
check-recipe-toolbox
instance-recipe-egg
dcron
python2.7
script
# Local development
[slapos.cookbook-repository]
recipe = plone.recipe.command
stop-on-error = true
branch = agent
location = ${buildout:parts-directory}/${:_buildout_section_name_}
command = ${git:location}/bin/git clone --branch ${:branch} --quiet http://git.erp5.org/repos/slapos.git ${:location}
update-command = cd ${:location} && ${git:location}/bin/git pull --quiet
[check-recipe]
recipe = plone.recipe.command
stop-on-error = true
update-command = ${:command}
command = grep parts ${buildout:develop-eggs-directory}/slapos.cookbook.egg-link
[slapos.toolbox-repository]
recipe = plone.recipe.command
stop-on-error = true
branch = agent
location = ${buildout:parts-directory}/${:_buildout_section_name_}
command = ${git:location}/bin/git clone --branch ${:branch} --quiet http://git.erp5.org/repos/slapos.toolbox.git ${:location}
update-command = cd ${:location} && ${git:location}/bin/git pull --quiet
[check-recipe-toolbox]
recipe = plone.recipe.command
stop-on-error = true
update-command = ${:command}
command = grep parts ${buildout:develop-eggs-directory}/slapos.toolbox.egg-link
[instance-recipe]
# XXX-Cedric: it can use newest slapos.cfg to not have duplication
egg = slapos.cookbook
module = agent
[instance-recipe-egg]
# XXX-Cedric: it can use newest slapos.cfg to not have duplication
recipe = zc.recipe.egg
python = python2.7
eggs = ${instance-recipe:egg}
eggs =
${lxml-python:egg}
${instance-recipe:egg}
[template]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance.cfg
output = ${buildout:directory}/template.cfg
md5sum =
c7cb98594f394d05baedabe424643f6f
md5sum =
bcd3b3cb8a305c83bb048d5ac1c583fe
mode = 0644
[eggs]
python = python2.7
recipe = zc.recipe.egg
eggs =
${lxml-python:egg}
slapos.cookbook
slapos.toolbox
erp5.util
[lxml-python]
python = python2.7
[template-agent]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-agent.cfg
output = ${buildout:directory}/template-agent.cfg
md5sum = fd9670d8473be402b10990398b553b00
mode = 0644
[script]
recipe = z3c.recipe.scripts
python = python2.7
eggs =
zc.buildout
${lxml-python:egg}
slapos.core
slapos.cookbook
slapos.toolbox[agent]
erp5.util
[networkcache]
# signature certificates of the following uploaders.
# Romain Courteaud
# Cedric de Saint Martin
# Rafael Monnerat
signature-certificate-list =
-----BEGIN CERTIFICATE-----
MIIB4DCCAUkCADANBgkqhkiG9w0BAQsFADA5MQswCQYDVQQGEwJGUjEZMBcGA1UE
...
...
@@ -68,3 +100,29 @@ signature-certificate-list =
q7jdfWO18Zp/BG7tagz0jmmC4y/8akzHsVlruo2+2du2freE8dK746uoMlXlP93g
QUUGLQ==
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIB9jCCAV+gAwIBAgIJAO4V/jiMoICoMA0GCS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QYDVR0O
BBYEFLqtrfTu+BIVt+TFiRUkIoiWIYrxMB8GA1UdIwQYMBaAFLqtrfTu+BIVt+TF
iRUkIoiWIYrxMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAc8N5P5gW
Jrdk9gF/3Cpp6THDiy93+WcuAm7zFwXPFNttJtFKMNObP2YRZvsQkvjezfrZoRBF
j8LgKB3tZCbBj+HDj+AeD+q9V+cqMFLKc6LezvQYUuum6bZdfUNnPv1K1ULYSPjq
/jsRBbabCWSXqxR6gYEM6ooauj3udBMXhHE=
-----END CERTIFICATE-----
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