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
Tom Niget
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 @@
...
@@ -25,65 +25,42 @@
#
#
#############################################################################
#############################################################################
import
os
import
sys
import
zc.buildout
import
zc.buildout
import
slapos.slap
from
slapos.recipe.librecipe
import
GenericBaseRecipe
from
slapos.recipe.librecipe
import
BaseSlapRecipe
import
sys
from
slapos.recipe.librecipe
import
GenericSlapRecipe
import
json
import
ConfigParser
# XXX: BaseSlapRecipe and GenericSlapRecipe are deprecated, use
class
Recipe
(
GenericBaseRecipe
):
# GenericBaseRecipe and move partition parameter fetching to software release.
class
Recipe
(
BaseSlapRecipe
,
GenericSlapRecipe
):
def
install
(
self
):
def
install
(
self
):
self
.
path_list
=
[]
path_list
=
[]
crond
=
self
.
installCrond
()
configuration_path
=
self
.
options
[
"config"
]
header
=
"""[DEFAULT]
master_url = %s
key = %s
slap
=
slapos
.
slap
.
slap
()
cert = %s
slap
.
initializeConnection
(
self
.
server_url
,
self
.
key_file
,
self
.
cert_file
)
parameter_dict
=
slap
.
registerComputerPartition
(
max_install_duration = %s
self
.
computer_id
,
max_uninstall_duration = %s
self
.
computer_partition_id
,
max_request_duration = %s
).
getInstanceParameterDict
()
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
:
with
open
(
configuration_path
,
"w"
)
as
configuration
:
configuration
.
write
(
parameter_dict
[
"configuration"
])
configuration
.
write
(
header
+
self
.
options
[
"configuration"
])
agent_crond_path
=
os
.
path
.
join
(
crond
,
"agent"
)
with
open
(
agent_crond_path
,
"w"
)
as
agent_crond
:
path_list
.
append
(
self
.
createPythonScript
(
agent_crond
.
write
(
"*/5 * * * * %s -S %s --pidfile=%s --log=%s "
self
.
options
[
'wrapper'
],
"%s 2>&1 > /dev/null
\
n
"
%
(
'slapos.recipe.librecipe.execute.execute'
,
self
.
options
[
"python_binary"
],
[
self
.
options
[
"agent_binary"
],
'--pidfile=%s'
%
self
.
options
[
"pidfile"
],
self
.
options
[
"agent_binary"
],
"--log=%s"
%
self
.
options
[
"log"
],
configuration_path
]))
self
.
options
[
"pidfile"
],
self
.
options
[
"log"
],
configuration_path
,
))
return
self
.
path_list
+
[
configuration_path
,
agent_crond_path
]
path_list
.
append
(
configuration_path
)
def
installCrond
(
self
):
return
path_list
_
,
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
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]
[buildout]
parts =
parts =
instanc
e
switch_softwaretyp
e
eggs-directory = ${buildout:eggs-directory}
eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true
[instance]
[switch_softwaretype]
recipe = ${instance-recipe:egg}:${instance-recipe:module}
recipe = slapos.cookbook:softwaretype
agent_binary = ${buildout:directory}/bin/agent
default = ${template-agent:output}
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
software/agent/software.cfg
View file @
052a390a
[buildout]
[buildout]
extends =
extends =
../../component/dcron/buildout.cfg
../../component/python-2.7/buildout.cfg
../../component/lxml-python/buildout.cfg
../../component/lxml-python/buildout.cfg
../../component/git/buildout.cfg
../../stack/slapos.cfg
../../stack/slapos.cfg
develop =
${:parts-directory}/slapos.cookbook-repository
${:parts-directory}/slapos.toolbox-repository
parts =
parts =
template
template
eggs
template-agent
slapos.cookbook-repository
check-recipe
slapos.toolbox-repository
check-recipe-toolbox
instance-recipe-egg
instance-recipe-egg
dcron
python2.7
script
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]
[instance-recipe]
# XXX-Cedric: it can use newest slapos.cfg to not have duplication
egg = slapos.cookbook
egg = slapos.cookbook
module = agent
module = agent
[instance-recipe-egg]
[instance-recipe-egg]
# XXX-Cedric: it can use newest slapos.cfg to not have duplication
recipe = zc.recipe.egg
recipe = zc.recipe.egg
python = python2.7
eggs =
eggs = ${instance-recipe:egg}
${lxml-python:egg}
${instance-recipe:egg}
[template]
[template]
recipe = slapos.recipe.template
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance.cfg
url = ${:_profile_base_location_}/instance.cfg
output = ${buildout:directory}/template.cfg
output = ${buildout:directory}/template.cfg
md5sum =
c7cb98594f394d05baedabe424643f6f
md5sum =
bcd3b3cb8a305c83bb048d5ac1c583fe
mode = 0644
mode = 0644
[eggs]
[template-agent]
python = python2.7
recipe = slapos.recipe.template
recipe = zc.recipe.egg
url = ${:_profile_base_location_}/instance-agent.cfg
eggs =
output = ${buildout:directory}/template-agent.cfg
${lxml-python:egg}
md5sum = fd9670d8473be402b10990398b553b00
slapos.cookbook
mode = 0644
slapos.toolbox
erp5.util
[lxml-python]
python = python2.7
[script]
[script]
recipe = z3c.recipe.scripts
recipe = z3c.recipe.scripts
python = python2.7
eggs =
eggs =
zc.buildout
zc.buildout
${lxml-python:egg}
slapos.core
slapos.core
slapos.cookbook
slapos.toolbox[agent]
slapos.toolbox[agent]
erp5.util
[networkcache]
[networkcache]
# signature certificates of the following uploaders.
# signature certificates of the following uploaders.
# Romain Courteaud
# Romain Courteaud
# Cedric de Saint Martin
# Rafael Monnerat
signature-certificate-list =
signature-certificate-list =
-----BEGIN CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIB4DCCAUkCADANBgkqhkiG9w0BAQsFADA5MQswCQYDVQQGEwJGUjEZMBcGA1UE
MIIB4DCCAUkCADANBgkqhkiG9w0BAQsFADA5MQswCQYDVQQGEwJGUjEZMBcGA1UE
...
@@ -68,3 +100,29 @@ signature-certificate-list =
...
@@ -68,3 +100,29 @@ signature-certificate-list =
q7jdfWO18Zp/BG7tagz0jmmC4y/8akzHsVlruo2+2du2freE8dK746uoMlXlP93g
q7jdfWO18Zp/BG7tagz0jmmC4y/8akzHsVlruo2+2du2freE8dK746uoMlXlP93g
QUUGLQ==
QUUGLQ==
-----END CERTIFICATE-----
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIB9jCCAV+gAwIBAgIJAO4V/jiMoICoMA0GCSqGSIb3DQEBBQUAMBMxETAPBgNV
BAMMCENPTVAtMjMyMCAXDTEyMDIxNjExMTAyM1oYDzIxMTIwMTIzMTExMDIzWjAT
MREwDwYDVQQDDAhDT01QLTIzMjCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA
wi/3Z8W9pUiegUXIk/AiFDQ0UJ4JFAwjqr+HSRUirlUsHHT+8DzH/hfcTDX1I5BB
D1ADk+ydXjMm3OZrQcXjn29OUfM5C+g+oqeMnYQImN0DDQIOcUyr7AJc4xhvuXQ1
P2pJ5NOd3tbd0kexETa1LVhR6EgBC25LyRBRae76qosCAwEAAaNQME4wHQYDVR0O
BBYEFMDmW9aFy1sKTfCpcRkYnP6zUd1cMB8GA1UdIwQYMBaAFMDmW9aFy1sKTfCp
cRkYnP6zUd1cMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAskbFizHr
b6d3iIyN+wffxz/V9epbKIZVEGJd/6LrTdLiUfJPec7FaxVCWNyKBlCpINBM7cEV
Gn9t8mdVQflNqOlAMkOlUv1ZugCt9rXYQOV7rrEYJBWirn43BOMn9Flp2nibblby
If1a2ZoqHRxoNo2yTmm7TSYRORWVS+vvfjY=
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIB9jCCAV+gAwIBAgIJAOcKrOH/2Da6MA0GCSqGSIb3DQEBBQUAMBMxETAPBgNV
BAMMCENPTVAtMjk3MCAXDTEyMDYyNjAzMDU1MVoYDzIxMTIwNjAyMDMwNTUxWjAT
MREwDwYDVQQDDAhDT01QLTI5NzCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA
xzbOGlcoin2q+Mtp52r26Njliz2aoxIXbnOBUyDc/OGtk9nWA5uBtTc2zwR17um6
KV0bGyvuBA78XcvU+AIV/5s0ohBAX7yjRKmEhAYcFvov3EyWSdjOrqqo4qFSzOrK
sVQBlxIDpjQBH4F3lf6dBv6/M+tCT3iSv3aOZbsG0E8CAwEAAaNQME4wHQYDVR0O
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