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
eb40e5dd
Commit
eb40e5dd
authored
Jan 31, 2019
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix plugin promises
parent
3ded6d7a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
12 deletions
+8
-12
slapos/promise/plugin/check_url_available.py
slapos/promise/plugin/check_url_available.py
+5
-3
slapos/promise/plugin/frontend_config_validate.py
slapos/promise/plugin/frontend_config_validate.py
+3
-9
No files found.
slapos/promise/plugin/check_url_available.py
View file @
eb40e5dd
...
...
@@ -26,6 +26,8 @@ class RunPromise(GenericPromise):
curl
.
setopt
(
pycurl
.
TIMEOUT
,
timeout
)
curl
.
setopt
(
pycurl
.
FOLLOWLOCATION
,
True
)
curl
.
setopt
(
pycurl
.
SSL_VERIFYPEER
,
False
)
curl
.
setopt
(
pycurl
.
SSL_VERIFYHOST
,
False
)
curl
.
setopt
(
pycurl
.
WRITEFUNCTION
,
lambda
x
:
None
)
ca_cert_file
=
self
.
getConfig
(
'ca-cert-file'
)
cert_file
=
self
.
getConfig
(
'cert-file'
)
...
...
@@ -44,18 +46,18 @@ class RunPromise(GenericPromise):
return
http_code
=
curl
.
getinfo
(
pycurl
.
HTTP_CODE
)
check_secure
=
self
.
getConfig
(
'check
_
secure'
)
check_secure
=
self
.
getConfig
(
'check
-
secure'
)
if
http_code
==
0
:
self
.
logger
.
error
(
"%s is not available (server not reachable)."
%
url
)
elif
http_code
==
401
and
check_secure
==
"1"
:
self
.
logger
.
error
(
"%s is protected (returned %s)."
%
(
url
,
http_code
))
self
.
logger
.
info
(
"%s is protected (returned %s)."
%
(
url
,
http_code
))
elif
http_code
!=
expected_http_code
:
self
.
logger
.
error
(
"%s is not available (returned %s, expected %s)."
%
(
url
,
http_code
,
expected_http_code
))
else
:
self
.
logger
.
info
(
"
URL is available"
)
self
.
logger
.
info
(
"
%s: URL is available"
%
http_code
)
def
anomaly
(
self
):
return
self
.
_test
(
result_count
=
3
,
failure_amount
=
3
)
slapos/promise/plugin/frontend_config_validate.py
View file @
eb40e5dd
...
...
@@ -3,6 +3,7 @@ from slapos.grid.promise import interface
from
slapos.grid.promise.generic
import
GenericPromise
import
os
import
subprocess
from
slapos.grid.utils
import
SlapPopen
class
RunPromise
(
GenericPromise
):
...
...
@@ -20,19 +21,12 @@ class RunPromise(GenericPromise):
validate_script
=
self
.
getConfig
(
'verification-script'
)
result
=
float
(
subprocess
.
check_output
([
validate_script
]))
process
=
subprocess
.
Popen
(
[
validate_script
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
,
)
process
=
SlapPopen
([
validate_script
])
stdout
,
stderr
=
process
.
communicate
()
if
process
.
returncode
!=
0
:
self
.
logger
.
info
(
"OK"
)
else
:
if
stderr
:
self
.
logger
.
error
(
stderr
)
else
:
self
.
logger
.
error
(
stdout
)
self
.
logger
.
error
(
"%s
\
n
%s"
%
(
stdout
,
stderr
))
def
anomaly
(
self
):
return
self
.
_test
(
result_count
=
2
,
failure_amount
=
2
)
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