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
d8e5a7dc
Commit
d8e5a7dc
authored
7 years ago
by
Tanner Prestegard
Committed by
gracedb-dev1
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
adding migration for bayestar robot update and fixing migration for old bayeswave robot update
parent
a4cf07f4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ligoauth/migrations/0013_update_bayeswave_robot.py
+12
-11
12 additions, 11 deletions
ligoauth/migrations/0013_update_bayeswave_robot.py
ligoauth/migrations/0015_update_bayestar_robot.py
+69
-0
69 additions, 0 deletions
ligoauth/migrations/0015_update_bayestar_robot.py
with
81 additions
and
11 deletions
ligoauth/migrations/0013_update_bayeswave_robot.py
+
12
−
11
View file @
d8e5a7dc
...
...
@@ -29,12 +29,11 @@ def create_robots(apps, schema_editor):
cert
.
save
()
# Delete old certs.
for
oldcert
in
entry
[
'
oldcert
'
]:
try
:
cert
=
X509Cert
.
objects
.
get
(
subject
=
oldcert
)
cert
.
delete
()
except
:
pass
try
:
cert
=
X509Cert
.
objects
.
get
(
subject
=
entry
[
'
oldcert
'
])
cert
.
delete
()
except
:
pass
def
delete_robots
(
apps
,
schema_editor
):
LocalUser
=
apps
.
get_model
(
'
ligoauth
'
,
'
LocalUser
'
)
...
...
@@ -47,13 +46,15 @@ def delete_robots(apps, schema_editor):
user
.
save
()
# Create oldcerts, add to user
for
oldcert
in
entry
[
'
oldcert
'
]:
cert
,
created
=
X509Cert
.
objects
.
get_or_create
(
subject
=
oldcert
)
cert
.
users
.
add
(
user
)
cert
.
save
()
cert
,
created
=
X509Cert
.
objects
.
get_or_create
(
subject
=
entry
[
'
oldcert
'
])
cert
.
users
.
add
(
user
)
cert
.
save
()
# Delete newcert.
X509Cert
.
objects
.
get
(
subject
=
entry
[
'
newcert
'
]).
delete
()
try
:
X509Cert
.
objects
.
get
(
subject
=
entry
[
'
newcert
'
]).
delete
()
except
:
pass
class
Migration
(
migrations
.
Migration
):
...
...
This diff is collapsed.
Click to expand it.
ligoauth/migrations/0015_update_bayestar_robot.py
0 → 100644
+
69
−
0
View file @
d8e5a7dc
# -*- coding: utf-8 -*-
# Default imports
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
from
django.conf
import
settings
ROBOTS
=
[{
'
username
'
:
'
bayestar-mic
'
,
'
newcert
'
:
'
/DC=org/DC=ligo/O=LIGO/OU=Services/CN=Online_CBC_BAYESTAR_O3_Preview/node746.cluster.ldas.cit
'
,
'
oldcert
'
:
'
/DC=org/DC=ligo/O=LIGO/OU=Services/CN=bayestar-mic/node529.cluster.ldas.cit
'
,
'
newemail
'
:
'
leo.singer@ligo.org
'
,
'
oldemail
'
:
'
lsinger@caltech.edu
'
,
},
]
def
create_robots
(
apps
,
schema_editor
):
LocalUser
=
apps
.
get_model
(
'
ligoauth
'
,
'
LocalUser
'
)
X509Cert
=
apps
.
get_model
(
'
ligoauth
'
,
'
X509Cert
'
)
# Get/create new user, get/create new cert, associate user with cert.
for
entry
in
ROBOTS
:
# get user, update email
user
=
LocalUser
.
objects
.
get
(
username
=
entry
[
'
username
'
])
user
.
email
=
entry
[
'
newemail
'
]
user
.
save
()
# get or create certificate, add user
cert
,
c_created
=
X509Cert
.
objects
.
get_or_create
(
subject
=
entry
[
'
newcert
'
])
cert
.
users
.
add
(
user
)
cert
.
save
()
# Delete old certs.
try
:
cert
=
X509Cert
.
objects
.
get
(
subject
=
entry
[
'
oldcert
'
])
cert
.
delete
()
except
:
pass
def
delete_robots
(
apps
,
schema_editor
):
LocalUser
=
apps
.
get_model
(
'
ligoauth
'
,
'
LocalUser
'
)
X509Cert
=
apps
.
get_model
(
'
ligoauth
'
,
'
X509Cert
'
)
for
entry
in
ROBOTS
:
# revert email
user
=
LocalUser
.
objects
.
get
(
username
=
entry
[
'
username
'
])
user
.
email
=
entry
[
'
oldemail
'
]
user
.
save
()
# Create oldcerts, add to user
cert
,
created
=
X509Cert
.
objects
.
get_or_create
(
subject
=
entry
[
'
oldcert
'
])
cert
.
users
.
add
(
user
)
cert
.
save
()
# Delete newcert.
try
:
X509Cert
.
objects
.
get
(
subject
=
entry
[
'
newcert
'
]).
delete
()
except
:
pass
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'
ligoauth
'
,
'
0014_update_lib_robot
'
),
]
operations
=
[
migrations
.
RunPython
(
create_robots
,
delete_robots
)
]
# 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