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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Douglas
slapos
Commits
ad032691
Commit
ad032691
authored
Jul 01, 2014
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5: http monitor script get settings from zero knowledge config file
parent
31ab0f18
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
9 deletions
+31
-9
stack/erp5/buildout.cfg
stack/erp5/buildout.cfg
+2
-2
stack/erp5/instance-http-monitor.cfg.in
stack/erp5/instance-http-monitor.cfg.in
+3
-4
stack/erp5/monitor-templates/monitor-check-cache-hit.in
stack/erp5/monitor-templates/monitor-check-cache-hit.in
+26
-3
No files found.
stack/erp5/buildout.cfg
View file @
ad032691
...
...
@@ -180,7 +180,7 @@ context =
recipe = slapos.recipe.template
filename = instance-http-monitor.cfg.in
url = ${:_profile_base_location_}/${:filename}
md5sum =
f1d5fa0e3f0b5f42cc87119c427d20a6
md5sum =
d2ddadaa0459319745b78dc704200755
output = ${buildout:directory}/template-http-monitor.cfg.in
##################e
...
...
@@ -191,7 +191,7 @@ output = ${buildout:directory}/template-http-monitor.cfg.in
< = download-base
url = ${:_profile_base_location_}/monitor-templates/monitor-check-cache-hit.in
download-only = true
md5sum =
b9f3f93bc41287698a44a687e6483f01
md5sum =
8e9ea2bec2fff4bd98c074cb69cf8592
filename = monitor-check-cache-hit.in
mode = 0644
...
...
stack/erp5/instance-http-monitor.cfg.in
View file @
ad032691
...
...
@@ -30,15 +30,14 @@ template = ${template-monitor-check-cache-hit:location}/${template-monitor-check
rendered = $${monitor-directory:monitor-custom-scripts}/check-cache-hit.py
mode = 700
context =
key url_list zero-parameters:url_list
key resolve_list zero-parameters:resolve_list
raw config_cfg $${buildout:directory}/$${public:filename}
raw python_executable ${buildout:bin-directory}/python2.7
[public]
recipe = slapos.cookbook:zero-knowledge.write
filename = knowledge0.cfg
url_list = ['http://www.erp5.com/'
]
resolve_list = ['www.erp5.com:80:5.135.149.226'
]
json_url_list = ["http://www.erp5.com/"
]
json_resolve_list = ["www.erp5.com:80:5.135.149.226"
]
[zero-parameters]
recipe = slapos.cookbook:zero-knowledge.read
...
...
stack/erp5/monitor-templates/monitor-check-cache-hit.in
View file @
ad032691
...
...
@@ -5,11 +5,16 @@
import sys
import pycurl
import ConfigParser
import os
import json
from mimetools import Message
from cStringIO import StringIO
from HTMLParser import HTMLParser
####################
# Init logging tools
def debug(*args):
# sys.stderr.write("DEBUG: " + "\n : ".join(" ".join((str(arg) for arg in args)).split("\n")) + "\n")
pass
...
...
@@ -30,6 +35,27 @@ def error(*args):
last_error_log = "ERROR: " + "\n : ".join(" ".join((str(arg) for arg in args)).split("\n")) + "\n"
sys.stderr.write(last_error_log)
#############################
# Checking configuration file
config_file = "{{ config_cfg }}"
if not os.path.exists(config_file):
error("Your software does *NOT* embed 0-knowledge. This interface is useless in this case")
exit(1)
##################################
# Getting configuration parameters
config_parser = ConfigParser.ConfigParser()
config_parser.read(config_file)
if not config_parser.has_section('public'):
error("Your software does not use 0-knowledge settings.")
exit(1)
url_list = json.loads(config_parser.get("public", "json_url_list"))
resolve_list = json.loads(config_parser.get("public", "json_resolve_list"))
########################
# Prepare & run requests
class MyHTMLParser(HTMLParser):
def __init__(self, base_url):
HTMLParser.__init__(self)
...
...
@@ -61,9 +87,6 @@ headers = {
# "Connection": "keep-alive"
}
url_list = {{ url_list }}
resolve_list = {{ resolve_list }}
parsed_url_dict = {}
info("Start checking for cache hits")
...
...
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