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
5
Merge Requests
5
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
slapos.toolbox
Commits
323c8f13
Commit
323c8f13
authored
Jun 05, 2019
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
promise/plugin: Add check_http_access
parent
76b353fa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
0 deletions
+43
-0
slapos/promise/plugin/check_http_access.py
slapos/promise/plugin/check_http_access.py
+43
-0
No files found.
slapos/promise/plugin/check_http_access.py
0 → 100644
View file @
323c8f13
from
zope
import
interface
as
zope_interface
from
slapos.grid.promise
import
interface
from
slapos.grid.promise.generic
import
GenericPromise
import
requests
class
RunPromise
(
GenericPromise
):
zope_interface
.
implements
(
interface
.
IPromise
)
def
__init__
(
self
,
config
):
GenericPromise
.
__init__
(
self
,
config
)
self
.
setPeriodicity
(
minute
=
2
)
def
sense
(
self
):
"""
Test request to url
ssl-proxy-verify with ssl-proxy-ca-crt-file can be used to validate
the endpoint SSL certificate.
"""
url
=
self
.
getConfig
(
'url'
)
verify
=
self
.
getConfig
(
'ssl-proxy-verify'
).
lower
()
==
'true'
verify_cert
=
self
.
getConfig
(
'ssl-proxy-ca-crt-file'
)
timeout
=
int
(
self
.
getConfig
(
'timeout'
,
'5'
))
if
verify
and
len
(
verify_cert
):
verify
=
verify_cert
try
:
requests
.
get
(
url
,
verify
=
verify
,
timeout
=
timeout
)
except
Exception
as
e
:
self
.
logger
.
error
(
"ERROR {} while accessing url {} with verify {} and verify_cert {} "
"with timeout {}"
.
format
(
e
,
url
,
verify
,
verify_cert
,
timeout
))
else
:
self
.
logger
.
info
(
"url {} OK"
.
format
(
url
))
def
anomaly
(
self
):
"""
There is an anomaly if last 3 senses were bad.
"""
return
self
.
_anomaly
(
result_count
=
3
,
failure_amount
=
3
)
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