Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GraceDB Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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 GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michael Coughlin
GraceDB Server
Commits
473ac13b
Commit
473ac13b
authored
7 years ago
by
Tanner Prestegard
Committed by
GraceDB
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
adding virgo detchar account and x509 certificate
parent
768a8cff
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ligoauth/migrations/0017_add_virgo_detchar.py
+68
-0
68 additions, 0 deletions
ligoauth/migrations/0017_add_virgo_detchar.py
with
68 additions
and
0 deletions
ligoauth/migrations/0017_add_virgo_detchar.py
0 → 100644
+
68
−
0
View file @
473ac13b
# -*- coding: utf-8 -*-
# Default imports
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
from
django.conf
import
settings
ROBOT
=
{
'
username
'
:
'
virgo_detchar
'
,
'
first_name
'
:
''
,
'
last_name
'
:
'
Virgo Detchar
'
,
'
email
'
:
'
leroy@lal.in2p3.fr
'
,
'
is_active
'
:
True
,
'
is_staff
'
:
False
,
'
is_superuser
'
:
False
}
# Certificate for nagios user on gracedb.
CERT_SUBJ
=
'
/DC=org/DC=ligo/O=LIGO/OU=Services/CN=Virgodetchar/lscgw.virgo.infn.it
'
def
create_robot
(
apps
,
schema_editor
):
LocalUser
=
apps
.
get_model
(
'
ligoauth
'
,
'
LocalUser
'
)
X509Cert
=
apps
.
get_model
(
'
ligoauth
'
,
'
X509Cert
'
)
Group
=
apps
.
get_model
(
'
auth
'
,
'
Group
'
)
lvc_group
=
Group
.
objects
.
get
(
name
=
settings
.
LVC_GROUP
)
# get or create user
user
,
created
=
LocalUser
.
objects
.
get_or_create
(
username
=
ROBOT
[
'
username
'
])
if
created
:
for
key
in
ROBOT
.
keys
():
setattr
(
user
,
key
,
ROBOT
[
key
])
# Save user
user
.
save
()
# Add user to LVC group.
if
not
lvc_group
in
user
.
groups
.
all
():
lvc_group
.
user_set
.
add
(
user
)
lvc_group
.
save
()
# get or create certificate, add user
cert
,
c_created
=
X509Cert
.
objects
.
get_or_create
(
subject
=
CERT_SUBJ
)
cert
.
users
.
add
(
user
)
cert
.
save
()
def
delete_robot
(
apps
,
schema_editor
):
LocalUser
=
apps
.
get_model
(
'
ligoauth
'
,
'
LocalUser
'
)
X509Cert
=
apps
.
get_model
(
'
ligoauth
'
,
'
X509Cert
'
)
# Get user
user
=
LocalUser
.
objects
.
get
(
username
=
ROBOT
[
'
username
'
])
# Delete user.
user
.
delete
()
# Delete cert.
X509Cert
.
objects
.
get
(
subject
=
CERT_SUBJ
).
delete
()
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'
ligoauth
'
,
'
0016_add_losc_account
'
),
]
operations
=
[
migrations
.
RunPython
(
create_robot
,
delete_robot
)
]
# End of file
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