Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mock-cheops
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
chephren
mock-cheops
Commits
2856db04
Unverified
Commit
2856db04
authored
1 year ago
by
REIG Julien
Browse files
Options
Downloads
Patches
Plain Diff
implement ping nodes
parent
82e07a03
Branches
Branches containing commit
No related tags found
1 merge request
!11
create ping endpoint
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
controllers/ping_controller.py
+6
-4
6 additions, 4 deletions
controllers/ping_controller.py
main.py
+3
-1
3 additions, 1 deletion
main.py
utils/http_utils.py
+1
-1
1 addition, 1 deletion
utils/http_utils.py
with
10 additions
and
6 deletions
controllers/ping_controller.py
+
6
−
4
View file @
2856db04
import
time
from
flask
import
Blueprint
,
request
from
flask
import
Blueprint
,
jsonify
,
request
from
flask_restful
import
Api
,
Resource
from
consts.status
import
Status
,
response_offline
from
utils.database_utils
import
get_state
from
utils.http_utils
import
normalize_url
,
ping
state
_controller
=
Blueprint
(
'
state
_controller
'
,
__name__
)
api
=
Api
(
state
_controller
)
ping
_controller
=
Blueprint
(
'
ping
_controller
'
,
__name__
)
api
=
Api
(
ping
_controller
)
class
PingController
(
Resource
):
...
...
@@ -22,7 +22,9 @@ class PingController(Resource):
node_addresses
=
list
(
map
(
normalize_url
,
node_addresses
))
results
=
ping
(
node_addresses
)
return
results
,
200
if
(
normalize_url
(
request
.
host_url
)
in
node_addresses
):
results
[
normalize_url
(
request
.
host_url
)]
=
True
return
jsonify
({
"
reachable
"
:
True
,
"
results
"
:
results
})
...
...
This diff is collapsed.
Click to expand it.
main.py
+
3
−
1
View file @
2856db04
...
...
@@ -2,11 +2,12 @@ import flask
from
flask
import
Flask
from
flask_cors
import
CORS
from
controllers.duplicate_controller
import
duplicate_controller
from
controllers.node_controller
import
node_controller
from
controllers.ping_controller
import
ping_controller
from
controllers.resource_controller
import
resource_controller
from
controllers.resources_controller
import
resources_controller
from
controllers.state_controller
import
state_controller
from
controllers.duplicate_controller
import
duplicate_controller
from
utils.init_database
import
init_database
,
init_queue_db
from
utils.MessageAnnouncer
import
announcer
...
...
@@ -18,6 +19,7 @@ app.register_blueprint(resource_controller, url_prefix='/api')
app
.
register_blueprint
(
resources_controller
,
url_prefix
=
'
/api
'
)
app
.
register_blueprint
(
state_controller
,
url_prefix
=
'
/api
'
)
app
.
register_blueprint
(
duplicate_controller
,
url_prefix
=
'
/api
'
)
app
.
register_blueprint
(
ping_controller
,
url_prefix
=
'
/api
'
)
@app.route
(
'
/api/subscribe
'
,
methods
=
[
'
GET
'
])
...
...
This diff is collapsed.
Click to expand it.
utils/http_utils.py
+
1
−
1
View file @
2856db04
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment