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
Alain Takoudjou
slapos
Commits
9a6e913d
Commit
9a6e913d
authored
Jun 20, 2014
by
Cédric Le Ninivin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apache-frontend: add slave-control interface and monitor
parent
548d2f09
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
130 additions
and
3 deletions
+130
-3
software/apache-frontend/common.cfg
software/apache-frontend/common.cfg
+9
-0
software/apache-frontend/instance-apache-replicate.cfg.in
software/apache-frontend/instance-apache-replicate.cfg.in
+43
-2
software/apache-frontend/instance.cfg
software/apache-frontend/instance.cfg
+2
-1
software/apache-frontend/templates/monitor/slave-control-interface.cgi.in
...frontend/templates/monitor/slave-control-interface.cgi.in
+76
-0
No files found.
software/apache-frontend/common.cfg
View file @
9a6e913d
...
...
@@ -165,3 +165,12 @@ location = ${buildout:parts-directory}/${:_buildout_section_name_}
filename = records.config.jinja2
download-only = true
mode = 0644
[template-slave-control-interface]
recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/templates/monitor/${:filename}
download-only = true
#md5sum = e43d79bec8824265e22df7960744113a
destination = ${buildout:directory}/parts/template-slave-control-interface
filename = slave-control-interface.cgi.in
mode = 0644
software/apache-frontend/instance-apache-replicate.cfg.in
View file @
9a6e913d
...
...
@@ -354,12 +354,34 @@ cert-content = ${slap-parameter:apache-certificate}
# Put domain name
name = ${slap-parameter:domain}
####################
# Monitor and control
#
[publish-information]
root-monitor-url = ${monitor-parameters:url}
[slave-control-interface]
recipe = slapos.recipe.template:jinja2
template = {{ build_path.get('template-slave-control-interface') }}
rendered = ${monitor-directory:monitoring-cgi}/${:filename}
filename = slave-control-interface.cgi
mode = 0744
context =
raw slave_configuration_json {{ slave_configuration_path }}
raw slave_status_stop {{ slave_stop }}
raw slave_status_deploy {{ slave_deploy }}
raw slave_status_test {{ slave_test }}
raw slave_status_ignore {{ slave_ignore }}
raw timestamp ${buildout:directory}/.timestamp
key pwd monitor-directory:monitoring-cgi
key this_file :filename
raw python_executable ${buildout:executable}
#####################
# Buidout elements
#
[buildout]
parts =
publish-slave-information
...
...
@@ -370,7 +392,26 @@ parts =
{% for part in part_list -%}
{{ ' %s' % part }}
{% endfor -%}
# publish-information
###Parts to add for monitoring
certificate-authority
cron-entry-monitor
cron-entry-rss
deploy-index
deploy-settings-cgi
deploy-status-cgi
deploy-status-history-cgi
setup-static-files
certificate-authority
zero-parameters
public-symlink
cgi-httpd-wrapper
cgi-httpd-graceful-wrapper
monitor-promise
monitor-instance-log-access
## Monitor for apache Root
slave-control-interface
extends = {{ build_path.get('monitor-template') }}
eggs-directory = {{ eggs_directory }}
develop-eggs-directory = {{ develop_eggs_directory }}
...
...
software/apache-frontend/instance.cfg
View file @
9a6e913d
...
...
@@ -68,3 +68,4 @@ template-default-slave-virtualhost = ${template-default-slave-virtualhost:target
template-default-virtualhost = ${template-default-virtualhost:target}
template-empty = ${template-empty:target}
template-slave-configuration = ${template-slave-configuration:target}
template-slave-control-interface = ${template-slave-control-interface:location}/${template-slave-control-interface:filename}
\ No newline at end of file
software/apache-frontend/templates/monitor/slave-control-interface.cgi.in
0 → 100644
View file @
9a6e913d
#!{{ python_executable }}
import cgi
import cgitb
import json
import os
cgitb.enable()
form = cgi.FieldStorage()
print "
<html><head>
"
print "
<link
rel=
\"stylesheet\"
href=
\"static/pure-min.css\"
>
"
print "
<link
rel=
\"stylesheet\"
href=
\"static/style.css\"
>
"
print "
</head><body>
"
slave_configuration_file = "{{ slave_configuration_json }}"
if not os.path.exists(slave_configuration_file):
print "No slave configuration file
</body></html>
"
exit(0)
slave_configuration_json = open(slave_configuration_file, 'r').read()
try:
slave_configuration = json.loads(slave_configuration_json)
except ValueError as e:
print "
<pre>
%s
</pre></body></html>
" % e
exit(0)
slave_status = {
'{{ slave_status_ignore }}': "Ignore",
'{{ slave_status_test }}': "Test",
'{{ slave_status_deploy }}': "Deploy",
'{{ slave_status_stop }}': "Stop",
}
def print_slave_line(slave_reference, current_state):
print """
<div
class=
"pure-control-group"
>
<label
for=
"%(slave_reference)s"
>
%(slave_reference)s:
</label>
<select
name=
"%(slave_reference)s"
>
""" % {'slave_reference': slave_reference}
print '
<option
value=
""
selected
></option>
'
for state, title in slave_status.iteritems():
if current_state == state:
print '
<option
value=
"%s"
selected
>
%s
</option>
' % (state, title)
else:
print '
<option
value=
"%s"
>
%s
</option>
' % (state, title)
print """
</select></div>
"""
###
# Update Status
#
for name in form:
if slave_configuration.has_key(name):
slave_configuration.get(name)['state'] = form[name].value
if len(form) > 0:
json.dump(slave_configuration, open(slave_configuration_file, 'w'), indent=2)
try:
os.remove("{{ timestamp }}")
except OSError:
pass
print "
<h1>
Slave List status :
</h1>
"
print "
<form
action=
\"/index.cgi\"
method=
\"post\"
class=
\"pure-form-aligned\"
>
"
print "
<input
type=
\"hidden\"
name=
\"posting-script\"
value=
\"{{
pwd
}}/{{
this_file
}}\"
>
"
for slave_reference, slave in slave_configuration.iteritems():
print_slave_line(slave_reference, slave.get('state'))
print """
<div
class=
"pure-controls"
>
<button
type=
"submit"
class=
"pure-button pure-button-primary"
>
Update
</button>
</div></form>
"""
print "
</body></html>
"
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