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
Lukas Niegsch
slapos
Commits
d66269ec
Commit
d66269ec
authored
Jul 06, 2012
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'agent'
parents
e2c6b0ab
a57f9d57
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
74 deletions
+37
-74
slapos/recipe/agent/__init__.py
slapos/recipe/agent/__init__.py
+26
-57
software/agent/instance.cfg
software/agent/instance.cfg
+8
-10
software/agent/software.cfg
software/agent/software.cfg
+3
-7
No files found.
slapos/recipe/agent/__init__.py
View file @
d66269ec
...
...
@@ -34,76 +34,45 @@ from slapos.recipe.librecipe import GenericSlapRecipe
import
json
import
ConfigParser
# XXX: BaseSlapRecipe and GenericSlapRecipe are deprecated, use
# GenericBaseRecipe and move partition parameter fetching to software release.
class
Recipe
(
BaseSlapRecipe
,
GenericSlapRecipe
):
def
install
(
self
):
self
.
path_list
=
[]
self
.
crond
=
self
.
installCrond
()
crond
=
self
.
installCrond
()
slap
=
slapos
.
slap
.
slap
()
computer_id
=
self
.
computer_id
computer_partition_id
=
self
.
computer_partition_id
server_url
=
self
.
server_url
key_file
=
self
.
key_file
cert_file
=
self
.
cert_file
slap
.
initializeConnection
(
server_url
,
key_file
,
cert_file
)
self
.
computer_partition
=
slap
.
registerComputerPartition
(
computer_id
,
computer_partition_id
)
self
.
parameter_dict
=
self
.
computer_partition
.
getInstanceParameterDict
()
slap
.
initializeConnection
(
self
.
server_url
,
self
.
key_file
,
self
.
cert_file
)
parameter_dict
=
slap
.
registerComputerPartition
(
self
.
computer_id
,
self
.
computer_partition_id
,
).
getInstanceParameterDict
()
# 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"
)
configuration
=
ConfigParser
.
SafeConfigParser
()
configuration
.
add_section
(
"agent"
)
configuration
.
set
(
"agent"
,
"portal_url"
,
self
.
parameter_dict
[
"portal_url"
])
configuration
.
set
(
"agent"
,
"master_url"
,
self
.
parameter_dict
[
"master_url"
])
configuration
.
set
(
"agent"
,
"report_url"
,
self
.
parameter_dict
[
"report_url"
])
key_filepath
=
os
.
path
.
join
(
self
.
work_directory
,
"key"
)
key_file
=
open
(
key_filepath
,
"w"
)
key_file
.
write
(
self
.
parameter_dict
[
"key"
])
key_file
.
close
()
configuration
.
set
(
"agent"
,
"key_file"
,
key_filepath
)
cert_filepath
=
os
.
path
.
join
(
self
.
work_directory
,
"cert"
)
cert_file
=
open
(
cert_filepath
,
"w"
)
cert_file
.
write
(
self
.
parameter_dict
[
"cert"
])
cert_file
.
close
()
configuration
.
set
(
"agent"
,
"cert_file"
,
cert_filepath
)
configuration
.
set
(
"agent"
,
"maximum_software_installation_duration"
,
self
.
parameter_dict
[
"maximum_software_installation_duration"
])
configuration
.
set
(
"agent"
,
"software_live_duration"
,
self
.
parameter_dict
[
"software_live_duration"
])
configuration
.
set
(
"agent"
,
"computer_list"
,
self
.
parameter_dict
[
"computer_list"
])
configuration
.
set
(
"agent"
,
"software_list"
,
self
.
parameter_dict
[
"software_list"
])
configuration
.
set
(
"agent"
,
"log_directory"
,
self
.
options
[
"log_directory"
])
configuration
.
set
(
"agent"
,
"state_file"
,
self
.
options
[
"state_file"
])
state
=
open
(
self
.
options
[
"state_file"
],
"w"
)
state
.
write
(
''
)
state
.
close
()
configuration
.
add_section
(
"software_uri"
)
software_list
=
json
.
loads
(
self
.
parameter_dict
[
"software_list"
])
for
software
in
software_list
:
configuration
.
set
(
"software_uri"
,
software
,
self
.
parameter_dict
[
software
])
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
(
open
(
configuration_path
,
"w"
))
agent_crond_path
=
os
.
path
.
join
(
self
.
crond
,
"agent"
)
agent_crond
=
open
(
agent_crond_path
,
"w"
)
agent_crond
.
write
(
"*/3 * * * * %s -S %s"
%
\
(
self
.
options
[
"python_binary"
],
"%s --pidfile=%s %s"
%
\
(
self
.
options
[
"agent_binary"
],
self
.
options
[
"pidfile"
],
configuration_path
)))
agent_crond
.
close
()
return
self
.
path_list
+
[
configuration_path
,
key_filepath
,
cert_filepath
,
agent_crond_path
]
return
self
.
path_list
+
[
configuration_path
,
agent_crond_path
]
def
installCrond
(
self
):
_
,
self
.
ws
=
self
.
egg
.
working_set
()
_
,
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'
)],
self
.
ws
,
sys
.
executable
,
__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'
)
...
...
@@ -111,7 +80,7 @@ class Recipe(BaseSlapRecipe, GenericSlapRecipe):
self
.
_createDirectory
(
cron_d
)
self
.
_createDirectory
(
crontabs
)
wrapper
=
zc
.
buildout
.
easy_install
.
scripts
([(
'crond'
,
'slapos.recipe.librecipe.execute'
,
'execute'
)],
self
.
ws
,
sys
.
executable
,
'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
]
...
...
software/agent/instance.cfg
View file @
d66269ec
[buildout]
parts =
rootdirectory
instance
eggs-directory = ${buildout:eggs-directory}
...
...
@@ -9,17 +8,16 @@ develop-eggs-directory = ${buildout:develop-eggs-directory}
[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 = $${buildout:directory}/agent.pid
log_directory = $${buildout:directory}/var/log
state_file = $${buildout:directory}/state.cfg
pidfile = $${rootdirectory:run}/agent.pid
log = $${rootdirectory:agentlog}/agent.log
[rootdirectory]
recipe = slapos.cookbook:mkdirectory
etc = $${buildout:directory}/etc/
run = $${rootdirectory:etc}/run/
var = $${buildout:directory}/var/
log = $${rootdirectory:var}/log/
srv = $${buildout:directory}/srv/
bin = $${buildout:directory}/bin/
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 @
d66269ec
[buildout]
# develop =
# /opt/slapdev
# /opt/slapos.toolbox
extends =
../../component/dcron/buildout.cfg
../../component/python-2.7/buildout.cfg
...
...
@@ -31,7 +26,7 @@ eggs = ${instance-recipe:egg}
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance.cfg
output = ${buildout:directory}/template.cfg
md5sum =
2e1a7a68b18de68b163e98a5f92cc776
md5sum =
c7cb98594f394d05baedabe424643f6f
mode = 0644
[eggs]
...
...
@@ -41,6 +36,7 @@ eggs =
${lxml-python:egg}
slapos.cookbook
slapos.toolbox
erp5.util
[lxml-python]
python = python2.7
...
...
@@ -53,7 +49,7 @@ eggs =
${lxml-python:egg}
slapos.core
slapos.cookbook
slapos.toolbox
slapos.toolbox
[agent]
[networkcache]
# signature certificates of the following uploaders.
...
...
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