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
693c0dc4
Commit
693c0dc4
authored
Sep 22, 2015
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
monitor: handle relation between promise and configuration
parent
381c6736
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
10 deletions
+34
-10
stack/monitor/buildout.cfg
stack/monitor/buildout.cfg
+1
-1
stack/monitor/monitor.py.in
stack/monitor/monitor.py.in
+33
-9
No files found.
stack/monitor/buildout.cfg
View file @
693c0dc4
...
...
@@ -56,7 +56,7 @@ md5sum = 2db5c08c7e8658981b4b1e3f27fd5967
[monitor-bin]
<= monitor-download-base
filename = monitor.py.in
md5sum =
331e8579c390aba5c5f4a4e7820b4c03
md5sum =
cc2f9c6b138ce11af9999ed58cd46799
[monitor-web-index-html]
<= monitor-download-base
...
...
stack/monitor/monitor.py.in
View file @
693c0dc4
...
...
@@ -22,16 +22,32 @@ def main():
for filename in os.listdir(configuration_folder_location)
if os.path.isfile(os.path.join(configuration_folder_location, filename))
]
# search for promises in promise folder and convert into configuration
# fill dict of service
service_config_dict = {}
for service_config in service_config_list:
service_config_dict[service_config.get("service", "name")] = service_config
# search for promises and make relation between service_config_list
for filename in os.listdir(promise_folder):
path = os.path.join(promise_folder, filename)
if os.path.isfile(path):
c = ConfigParser.ConfigParser()
c.add_section("service")
c.set("service", "name", filename)
c.set("service", "frequency", "* * * * *") # every minutes
c.set("service", "promise-path", os.path.join(path))
service_config_list.append(c)
promise_path = os.path.join(promise_folder, filename)
if os.path.isfile(promise_path) and os.access(promise_path, os.X_OK):
service_name = filename
service_config = service_config_dict.get(service_name)
if service_name not in service_config_dict or softConfigGet(service_config, "service", "promise-path"):
service_name = newServiceName(service_name, service_config_dict)
service_config = ConfigParser.ConfigParser()
service_config_list.append(service_config)
service_config_dict[service_name] = service_config
service_config.add_section("service")
service_config.set("service", "name", service_name)
service_config.set("service", "frequency", "* * * * *") # every minutes
service_config.set("service", "promise-path", promise_path)
# filter services without promise-path
service_config_dict = None
service_config_list = [
service_config
for service_config in service_config_list
if softConfigGet(service_config, "service", "promise-path")
]
# generate monitor.json
monitor_dict = {}
tmp = softConfigGet(config, "monitor", "title")
...
...
@@ -109,6 +125,14 @@ def createSymlinksFromConfig(destination_folder_config_tuple, source_list_config
if e.errno != os.errno.EEXIST:
raise
def newServiceName(name, name_dict):
part = name
count = 1
while name in name_dict:
name = part + "_" + str(count)
count += 1
return name
def mkdirAll(path):
try:
os.makedirs(path)
...
...
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