Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chenhao Ma
core
Commits
58f3250c
Commit
58f3250c
authored
10 years ago
by
Kevin S. Hahn
Browse files
Options
Downloads
Plain Diff
Merge branch 'new_deploy'
parents
e1216faf
dacd156e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
api.wsgi
+11
-4
11 additions, 4 deletions
api.wsgi
centralclient.py
+2
-2
2 additions, 2 deletions
centralclient.py
core.py
+9
-4
9 additions, 4 deletions
core.py
with
22 additions
and
10 deletions
api.wsgi
+
11
−
4
View file @
58f3250c
# @author: Gunnar Schaefer, Kevin S. Hahn
import os
import re
import time
import logging
import pymongo
...
...
@@ -19,7 +20,7 @@ ap.add_argument('--data_path', help='path to storage area', required=True)
ap.add_argument('--ssl_cert', help='path to SSL certificate file, containing private key and certificate chain', required=True)
ap.add_argument('--api_uri', help='api uri, with https:// prefix')
ap.add_argument('--site_id', help='site ID for Scitran Central [local]', default='local')
ap.add_argument('--site_name', help='site name'
)
ap.add_argument('--site_name', help='site name'
, nargs='*', default=['Local']) # hack for uwsgi --pyargv
ap.add_argument('--oauth2_id_endpoint', help='OAuth2 provider ID endpoint', default='https://www.googleapis.com/plus/v1/people/me/openIdConnect')
ap.add_argument('--demo', help='enable automatic user creation', action='store_true', default=False)
ap.add_argument('--insecure', help='allow user info as urlencoded param', action='store_true', default=False)
...
...
@@ -27,6 +28,9 @@ ap.add_argument('--central_uri', help='scitran central api', default='https://sd
ap.add_argument('--log_level', help='log level [info]', default='info')
args = ap.parse_args()
# HACK to allow setting the --site_name in the same way as api.py
# --site_name 'Example Site' or --site_name "Example Site"
args.site_name = ' '.join(args.site_name).strip('"\'')
args.quarantine_path = os.path.join(args.data_path, 'quarantine')
logging.basicConfig(level=getattr(logging, args.log_level.upper())) #FIXME probably not necessary, because done in api.py
...
...
@@ -56,14 +60,17 @@ for x in range(0, 30):
else:
raise Exception('Could not connect to MongoDB')
# TODO: make api_uri a required arg?
application.db.sites.update({'_id': args.site_id}, {'_id': args.site_id, 'name': args.site_name, 'api_uri': args.api_uri}, upsert=True)
if not args.ssl_cert:
log.warning('SSL certificate not specified, Scitran Central functionality disabled')
elif not args.api_uri:
log.warning('api_uri not configured. scitran central functionality disabled.')
elif not args.site_name:
log.warning('site_name not configured. scitran central functionality disabled.')
elif
not
args.site_id:
log.warning('site_id
not configured
. scitran central functionality disabled.')
elif args.site_id
== 'local'
:
log.warning('site_id
is local
. scitran central functionality disabled.')
elif not args.central_uri:
log.warning('central_uri not configured. scitran central functionality disabled.')
else:
...
...
@@ -79,4 +86,4 @@ else:
if fail_count == 3:
log.debug('scitran central unreachable, purging all remotes info')
centralclient.clean_remotes(application.db)
centralclient.clean_remotes(application.db
, args.site_id
)
This diff is collapsed.
Click to expand it.
centralclient.py
+
2
−
2
View file @
58f3250c
...
...
@@ -75,10 +75,10 @@ def update(db, api_uri, site_name, site_id, ssl_cert, central_url):
return
False
def
clean_remotes
(
db
):
def
clean_remotes
(
db
,
site_id
):
"""
Remove db.sites, and removes remotes field from all db.users.
"""
log
.
debug
(
'
removing remotes from users, and remotes collection
'
)
db
.
sites
.
remove
({})
db
.
sites
.
remove
({
'
_id
'
:
{
'
$ne
'
:
[
site_id
]}
})
db
.
users
.
update
({
'
remotes
'
:
{
'
$exists
'
:
True
}},
{
'
$unset
'
:
{
'
remotes
'
:
''
}},
multi
=
True
)
...
...
This diff is collapsed.
Click to expand it.
core.py
+
9
−
4
View file @
58f3250c
...
...
@@ -185,13 +185,18 @@ class Core(base.RequestHandler):
def
sites
(
self
):
"""
Return local and remote sites.
"""
if
self
.
app
.
config
[
'
site_id
'
]
==
'
local
'
:
return
[{
'
_id
'
:
'
local
'
,
'
name
'
:
'
Local
'
,
'
onload
'
:
T
rue
}]
projection
=
[
'
name
'
,
'
onload
'
]
# TODO onload for local is t
rue
if
self
.
public_request
or
self
.
request
.
get
(
'
all
'
).
lower
()
in
(
'
1
'
,
'
true
'
):
sites
=
list
(
self
.
app
.
db
.
sites
.
find
(
None
,
[
'
name
'
]
))
sites
=
list
(
self
.
app
.
db
.
sites
.
find
(
None
,
projection
))
else
:
# TODO onload based on user prefs
remote_ids
=
(
self
.
app
.
db
.
users
.
find_one
({
'
_id
'
:
self
.
uid
},
[
'
remotes
'
])
or
{}).
get
(
'
remotes
'
,
[])
+
[
self
.
app
.
config
[
'
site_id
'
]]
sites
=
list
(
self
.
app
.
db
.
sites
.
find
({
'
_id
'
:
{
'
$in
'
:
remote_ids
}},
[
'
name
'
]))
sites
=
list
(
self
.
app
.
db
.
sites
.
find
({
'
_id
'
:
{
'
$in
'
:
remote_ids
}},
projection
))
for
s
in
sites
:
# TODO: this for loop will eventually move to public case
if
s
[
'
_id
'
]
==
self
.
app
.
config
[
'
site_id
'
]:
s
[
'
onload
'
]
=
True
break
return
sites
search_schema
=
{
...
...
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