Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
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
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
8419ebfb
Commit
8419ebfb
authored
Feb 22, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a service to retrieve Geo node information
parent
b3a4fa88
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
0 deletions
+35
-0
app/models/geo_node.rb
app/models/geo_node.rb
+4
-0
app/services/geo/node_status_service.rb
app/services/geo/node_status_service.rb
+31
-0
No files found.
app/models/geo_node.rb
View file @
8419ebfb
...
...
@@ -77,6 +77,10 @@ class GeoNode < ActiveRecord::Base
geo_api_url
(
"transfers/
#{
file_type
}
/
#{
file_id
}
"
)
end
def
status_url
URI
.
join
(
uri
,
"
#{
uri
.
path
}
/"
,
"api/
#{
API
::
API
.
version
}
/geo/status"
).
to_s
end
def
oauth_callback_url
Gitlab
::
Routing
.
url_helpers
.
oauth_geo_callback_url
(
url_helper_args
)
end
...
...
app/services/geo/node_status_service.rb
0 → 100644
View file @
8419ebfb
module
Geo
class
NodeStatusService
include
HTTParty
# HTTParty timeout
default_timeout
Gitlab
.
config
.
gitlab
.
webhook_timeout
def
call
(
status_url
)
response
=
self
.
class
.
get
(
status_url
,
headers:
{
'Content-Type'
=>
'application/json'
,
'PRIVATE-TOKEN'
=>
private_token
})
keys
=
GeoNode
::
Status
.
members
.
map
(
&
:to_s
)
values
=
response
.
parsed_response
.
values_at
(
*
keys
)
status
=
GeoNode
::
Status
.
new
(
*
values
)
[(
response
.
code
>=
200
&&
response
.
code
<
300
),
status
]
rescue
HTTParty
::
Error
,
Errno
::
ECONNREFUSED
=>
e
[
false
,
GeoNode
::
Status
.
new
(
ActionView
::
Base
.
full_sanitizer
.
sanitize
(
e
.
message
))]
end
private
def
private_token
# TODO: should we ask admin user to be defined as part of configuration?
@private_token
||=
User
.
find_by
(
admin:
true
).
authentication_token
end
end
end
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