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
Dmitry Blinov
slapos
Commits
e699b010
Commit
e699b010
authored
Apr 23, 2012
by
Mohamadou Mbengue
Browse files
Options
Browse Files
Download
Plain Diff
Merge master in lamp-mohamadou branch
parents
99db12c9
74fbe0f0
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
239 additions
and
2 deletions
+239
-2
CHANGES.txt
CHANGES.txt
+5
-1
setup.py
setup.py
+2
-1
slapos/recipe/agent/__init__.py
slapos/recipe/agent/__init__.py
+119
-0
slapos/recipe/agent/catdatefile.py
slapos/recipe/agent/catdatefile.py
+14
-0
software/agent/instance.cfg
software/agent/instance.cfg
+25
-0
software/agent/software.cfg
software/agent/software.cfg
+74
-0
No files found.
CHANGES.txt
View file @
e699b010
Changes
Changes
=======
=======
0.4
7
(Unreleased)
0.4
8
(Unreleased)
-----------------
-----------------
* No change yet.
* No change yet.
0.47 (2012-04-19)
-----------------
* Slap Test Agent [Yingjie Xu]
0.46 (2012/04/12)
0.46 (2012/04/12)
-----------------
-----------------
...
...
setup.py
View file @
e699b010
...
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
...
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
import
glob
import
glob
import
os
import
os
version
=
'0.4
7
-dev'
version
=
'0.4
8
-dev'
name
=
'slapos.cookbook'
name
=
'slapos.cookbook'
long_description
=
open
(
"README.txt"
).
read
()
+
"
\
n
"
+
\
long_description
=
open
(
"README.txt"
).
read
()
+
"
\
n
"
+
\
open
(
"CHANGES.txt"
).
read
()
+
"
\
n
"
open
(
"CHANGES.txt"
).
read
()
+
"
\
n
"
...
@@ -40,6 +40,7 @@ setup(name=name,
...
@@ -40,6 +40,7 @@ setup(name=name,
zip_safe
=
True
,
zip_safe
=
True
,
entry_points
=
{
entry_points
=
{
'zc.buildout'
:
[
'zc.buildout'
:
[
'agent = slapos.recipe.agent:Recipe'
,
'apache.frontend = slapos.recipe.apache_frontend:Recipe'
,
'apache.frontend = slapos.recipe.apache_frontend:Recipe'
,
'apachephp = slapos.recipe.apachephp:Recipe'
,
'apachephp = slapos.recipe.apachephp:Recipe'
,
'apacheproxy = slapos.recipe.apacheproxy:Recipe'
,
'apacheproxy = slapos.recipe.apacheproxy:Recipe'
,
...
...
slapos/recipe/agent/__init__.py
0 → 100644
View file @
e699b010
##############################################################################
#
# Copyright (c) 2012 Vifib SARL and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#############################################################################
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
class
Recipe
(
BaseSlapRecipe
,
GenericSlapRecipe
):
def
install
(
self
):
self
.
path_list
=
[]
self
.
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
()
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"
])
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
])
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
(
"*/1 * * * * %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
]
def
installCrond
(
self
):
_
,
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'
)],
self
.
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'
)],
self
.
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
slapos/recipe/agent/catdatefile.py
0 → 100644
View file @
e699b010
import
os
import
sys
import
time
def
catdatefile
(
args
):
directory
=
args
[
0
]
try
:
suffix
=
args
[
1
]
except
IndexError
:
suffix
=
'.log'
f
=
open
(
os
.
path
.
join
(
directory
,
time
.
strftime
(
'%Y-%m-%d.%H:%M.%s'
)
+
suffix
),
'aw'
)
for
line
in
sys
.
stdin
.
read
():
f
.
write
(
line
)
f
.
close
()
software/agent/instance.cfg
0 → 100644
View file @
e699b010
[buildout]
parts =
rootdirectory
instance
eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
[instance]
recipe = ${instance-recipe:egg}:${instance-recipe:module}
agent_binary = ${buildout:directory}/bin/agent
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
[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/
software/agent/software.cfg
0 → 100644
View file @
e699b010
[buildout]
# develop =
# /opt/slapdev
# /opt/slapos.toolbox
extends =
../../component/dcron/buildout.cfg
../../component/python-2.7/buildout.cfg
../../component/lxml-python/buildout.cfg
../../stack/slapos.cfg
parts =
template
eggs
instance-recipe-egg
dcron
python2.7
script
[instance-recipe]
egg = slapos.cookbook
module = agent
[instance-recipe-egg]
recipe = zc.recipe.egg
python = python2.7
eggs = ${instance-recipe:egg}
[template]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance.cfg
output = ${buildout:directory}/template.cfg
md5sum = 2e1a7a68b18de68b163e98a5f92cc776
mode = 0644
[eggs]
python = python2.7
recipe = zc.recipe.egg
eggs =
${lxml-python:egg}
slapos.cookbook
slapos.toolbox
[lxml-python]
python = python2.7
[script]
recipe = z3c.recipe.scripts
python = python2.7
eggs =
zc.buildout
${lxml-python:egg}
slapos.core
slapos.cookbook
slapos.toolbox
[networkcache]
# signature certificates of the following uploaders.
# Romain Courteaud
signature-certificate-list =
-----BEGIN CERTIFICATE-----
MIIB4DCCAUkCADANBgkqhkiG9w0BAQsFADA5MQswCQYDVQQGEwJGUjEZMBcGA1UE
CBMQRGVmYXVsdCBQcm92aW5jZTEPMA0GA1UEChMGTmV4ZWRpMB4XDTExMDkxNTA5
MDAwMloXDTEyMDkxNTA5MDAwMlowOTELMAkGA1UEBhMCRlIxGTAXBgNVBAgTEERl
ZmF1bHQgUHJvdmluY2UxDzANBgNVBAoTBk5leGVkaTCBnzANBgkqhkiG9w0BAQEF
AAOBjQAwgYkCgYEApYZv6OstoqNzxG1KI6iE5U4Ts2Xx9lgLeUGAMyfJLyMmRLhw
boKOyJ9Xke4dncoBAyNPokUR6iWOcnPHtMvNOsBFZ2f7VA28em3+E1JRYdeNUEtX
Z0s3HjcouaNAnPfjFTXHYj4um1wOw2cURSPuU5dpzKBbV+/QCb5DLheynisCAwEA
ATANBgkqhkiG9w0BAQsFAAOBgQBCZLbTVdrw3RZlVVMFezSHrhBYKAukTwZrNmJX
mHqi2tN8tNo6FX+wmxUUAf3e8R2Ymbdbn2bfbPpcKQ2fG7PuKGvhwMG3BlF9paEC
q7jdfWO18Zp/BG7tagz0jmmC4y/8akzHsVlruo2+2du2freE8dK746uoMlXlP93g
QUUGLQ==
-----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