Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
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
Kazuhiko Shiozaki
slapos.toolbox
Commits
572e915d
Commit
572e915d
authored
Dec 12, 2017
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
monitor: import checkpromise method from slapos.core now
parent
8b1572ea
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
176 additions
and
172 deletions
+176
-172
slapos/monitor/globalstate.py
slapos/monitor/globalstate.py
+0
-2
slapos/monitor/monitor.py
slapos/monitor/monitor.py
+15
-2
slapos/monitor/runpromise.py
slapos/monitor/runpromise.py
+64
-91
slapos/test/monitor/testglobalstate.py
slapos/test/monitor/testglobalstate.py
+5
-5
slapos/test/monitor/testrunpromise.py
slapos/test/monitor/testrunpromise.py
+92
-72
No files found.
slapos/monitor/globalstate.py
View file @
572e915d
...
@@ -170,8 +170,6 @@ def run(args_list):
...
@@ -170,8 +170,6 @@ def run(args_list):
instance_dict
=
{}
instance_dict
=
{}
global_state_dict
[
'title'
]
=
config
.
get
(
'instance'
,
'name'
)
global_state_dict
[
'title'
]
=
config
.
get
(
'instance'
,
'name'
)
# XXX - hosting-title should be removed at some point in favour of specialise_title
global_state_dict
[
'hosting-title'
]
=
config
.
get
(
'instance'
,
'root-name'
)
global_state_dict
[
'specialise_title'
]
=
config
.
get
(
'instance'
,
'root-name'
)
global_state_dict
[
'specialise_title'
]
=
config
.
get
(
'instance'
,
'root-name'
)
global_state_dict
[
'aggregate_reference'
]
=
config
.
get
(
'instance'
,
'computer'
)
global_state_dict
[
'aggregate_reference'
]
=
config
.
get
(
'instance'
,
'computer'
)
if
not
global_state_dict
[
'title'
]:
if
not
global_state_dict
[
'title'
]:
...
...
slapos/monitor/monitor.py
View file @
572e915d
...
@@ -104,6 +104,7 @@ class Monitoring(object):
...
@@ -104,6 +104,7 @@ class Monitoring(object):
self
.
config_folder
=
os
.
path
.
join
(
self
.
private_folder
,
'config'
)
self
.
config_folder
=
os
.
path
.
join
(
self
.
private_folder
,
'config'
)
self
.
report_folder
=
self
.
private_folder
self
.
report_folder
=
self
.
private_folder
self
.
data_folder
=
os
.
path
.
join
(
self
.
private_folder
,
'documents'
)
self
.
data_folder
=
os
.
path
.
join
(
self
.
private_folder
,
'documents'
)
self
.
log_folder
=
os
.
path
.
join
(
self
.
private_folder
,
'monitor-log'
)
self
.
promise_output_file
=
config
.
get
(
"monitor"
,
"promise-output-file"
)
self
.
promise_output_file
=
config
.
get
(
"monitor"
,
"promise-output-file"
)
self
.
bootstrap_is_ok
=
True
self
.
bootstrap_is_ok
=
True
...
@@ -387,7 +388,8 @@ class Monitoring(object):
...
@@ -387,7 +388,8 @@ class Monitoring(object):
'--history_folder "%s"'
%
self
.
data_folder
,
'--history_folder "%s"'
%
self
.
data_folder
,
'--instance_name "%s"'
%
self
.
title
,
'--instance_name "%s"'
%
self
.
title
,
'--hosting_name "%s"'
%
self
.
root_title
,
'--hosting_name "%s"'
%
self
.
root_title
,
'--promise_type "report"'
]
'--promise_type "report"'
,
'--log_file "%s.report.log"'
%
os
.
path
.
join
(
self
.
log_folder
,
report_name
)]
cron_line_list
.
append
(
' '
.
join
(
report_cmd_line
))
cron_line_list
.
append
(
' '
.
join
(
report_cmd_line
))
...
@@ -427,7 +429,9 @@ class Monitoring(object):
...
@@ -427,7 +429,9 @@ class Monitoring(object):
'--monitor_url "%s/private/"'
%
self
.
webdav_url
,
# XXX hardcoded,
'--monitor_url "%s/private/"'
%
self
.
webdav_url
,
# XXX hardcoded,
'--history_folder "%s"'
%
self
.
public_folder
,
'--history_folder "%s"'
%
self
.
public_folder
,
'--instance_name "%s"'
%
self
.
title
,
'--instance_name "%s"'
%
self
.
title
,
'--hosting_name "%s"'
%
self
.
root_title
]
'--hosting_name "%s"'
%
self
.
root_title
,
'--log_file "%s.log"'
%
os
.
path
.
join
(
self
.
log_folder
,
self
.
title
.
replace
(
' '
,
'_'
))]
registered_promise_list
=
os
.
listdir
(
self
.
promise_folder
)
registered_promise_list
=
os
.
listdir
(
self
.
promise_folder
)
registered_promise_list
.
extend
(
os
.
listdir
(
self
.
monitor_promise_folder
))
registered_promise_list
.
extend
(
os
.
listdir
(
self
.
monitor_promise_folder
))
...
@@ -501,6 +505,15 @@ class Monitoring(object):
...
@@ -501,6 +505,15 @@ class Monitoring(object):
file_list
=
[
"%s/*.history.json"
%
self
.
public_folder
]
file_list
=
[
"%s/*.history.json"
%
self
.
public_folder
]
self
.
generateLogrotateEntry
(
'monitor.service.status'
,
file_list
,
option_list
)
self
.
generateLogrotateEntry
(
'monitor.service.status'
,
file_list
,
option_list
)
# Rotate monitor log files
option_list
=
[
'daily'
,
'dateext'
,
'create'
,
'rotate 180'
,
'compress'
,
'delaycompress'
,
'notifempty'
,
'missingok'
]
file_list
=
[
"%s/*.log"
%
self
.
log_folder
]
self
.
generateLogrotateEntry
(
'monitor.promise.log'
,
file_list
,
option_list
)
# Add cron entry for SlapOS Collect
# Add cron entry for SlapOS Collect
command
=
"sleep $((1 + RANDOM % 60)) && "
# Random sleep between 1 to 60 seconds
command
=
"sleep $((1 + RANDOM % 60)) && "
# Random sleep between 1 to 60 seconds
if
self
.
nice_command
:
if
self
.
nice_command
:
...
...
slapos/monitor/runpromise.py
View file @
572e915d
This diff is collapsed.
Click to expand it.
slapos/test/monitor/testglobalstate.py
View file @
572e915d
...
@@ -141,7 +141,7 @@ exit %(code)s
...
@@ -141,7 +141,7 @@ exit %(code)s
self
.
writePromise
(
'promise_4'
)
self
.
writePromise
(
'promise_4'
)
parser
=
self
.
getPromiseParser
()
parser
=
self
.
getPromiseParser
()
promise_runner
=
RunPromise
(
parser
)
promise_runner
=
RunPromise
(
parser
)
promise_runner
.
run
p
romise
()
promise_runner
.
run
P
romise
()
self
.
assertTrue
(
os
.
path
.
exists
(
os
.
path
.
join
(
self
.
public_dir
,
'promise_1.status.json'
)))
self
.
assertTrue
(
os
.
path
.
exists
(
os
.
path
.
join
(
self
.
public_dir
,
'promise_1.status.json'
)))
self
.
assertTrue
(
os
.
path
.
exists
(
os
.
path
.
join
(
self
.
public_dir
,
'promise_2.status.json'
)))
self
.
assertTrue
(
os
.
path
.
exists
(
os
.
path
.
join
(
self
.
public_dir
,
'promise_2.status.json'
)))
...
@@ -191,7 +191,7 @@ exit %(code)s
...
@@ -191,7 +191,7 @@ exit %(code)s
"process_resource": "monitor_resource_process.data",
"process_resource": "monitor_resource_process.data",
"monitor_process_state": "monitor_resource.status"
"monitor_process_state": "monitor_resource.status"
},
},
"portal_type": "
instance_stat
e",
"portal_type": "
Software Instanc
e",
"state": {
"state": {
"success": 2,
"success": 2,
"error": 2
"error": 2
...
@@ -207,9 +207,9 @@ exit %(code)s
...
@@ -207,9 +207,9 @@ exit %(code)s
"href": "https://monitor.test.com/share/private/"
"href": "https://monitor.test.com/share/private/"
}
}
},
},
"
computer
_reference": "COMP-1234",
"
aggregate
_reference": "COMP-1234",
"type": "global",
"type": "global",
"
hosting-
title": "Monitor ROOT"
"
specialise_
title": "Monitor ROOT"
}"""
}"""
with
open
(
os
.
path
.
join
(
self
.
private_dir
,
'monitor.global.json'
))
as
r
:
with
open
(
os
.
path
.
join
(
self
.
private_dir
,
'monitor.global.json'
))
as
r
:
...
@@ -221,7 +221,7 @@ exit %(code)s
...
@@ -221,7 +221,7 @@ exit %(code)s
# all promises are OK now
# all promises are OK now
self
.
writePromise
(
'promise_2'
,
success
=
True
)
self
.
writePromise
(
'promise_2'
,
success
=
True
)
self
.
writePromise
(
'promise_3'
,
success
=
True
)
self
.
writePromise
(
'promise_3'
,
success
=
True
)
promise_runner
.
run
p
romise
()
promise_runner
.
run
P
romise
()
globalstate
.
run
([
self
.
monitor_config_file
,
os
.
path
.
join
(
self
.
base_dir
,
'instance.cfg'
)])
globalstate
.
run
([
self
.
monitor_config_file
,
os
.
path
.
join
(
self
.
base_dir
,
'instance.cfg'
)])
expected_result_dict
=
json
.
loads
(
expected_result
)
expected_result_dict
=
json
.
loads
(
expected_result
)
...
...
slapos/test/monitor/testrunpromise.py
View file @
572e915d
This diff is collapsed.
Click to expand it.
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