Commit a5436fe4 authored by Tanner Prestegard's avatar Tanner Prestegard Committed by GraceDB
Browse files

updating robot cert for gstlal-spiir and fixing bug in old migrations

parent 31937dde
......@@ -164,7 +164,7 @@ LOCALUSERS = [
},
{
'username': 'gstlal-spiir-gpu',
'last_name': 'GSTLAL SPIIR GPU Analysis ',
'last_name': 'GSTLAL SPIIR GPU Analysis',
'email': 'qi.chu@ligo.org',
'x509certs': [
'/DC=org/DC=ligo/O=LIGO/OU=Services/CN=gstlal-spiir-gpu/ldas-pcdev1.ligo.caltech.edu'
......@@ -349,7 +349,7 @@ def add_localusers_and_x509certs(apps, schema_editor):
for l_dict in LOCALUSERS:
localuser, created = LocalUser.objects.get_or_create(username=l_dict['username'])
localuser.last_name = l_dict['last_name']
localuser.email = l_dict['last_name']
localuser.email = l_dict['email']
localuser.save()
# Add user to LSC group
......
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2018-03-01 16:12
#
# This migration adds a new certificate to the gstlal-spiir account and
# removes the gstlal-spiir-gpu account. Request from Qi Chu on 27-28 Feb 2018.
from __future__ import unicode_literals
from django.db import migrations
GSTLAL_SPIIR = {
'username': 'gstlal-spiir',
'new_cert': '/DC=org/DC=ligo/O=LIGO/OU=Services/CN=gstlal-spiir/ldas-pcdev11.ligo.caltech.edu',
'old_cert': '/DC=org/DC=ligo/O=LIGO/OU=Services/CN=gstlal-spiir/ldas-pcdev1.ligo.caltech.edu',
}
GSTLAL_SPIIR_GPU = {
'username': 'gstlal-spiir-gpu',
'last_name': 'GSTLAL SPIIR GPU Analysis',
'email': 'qi.chu@ligo.org',
'cert': '/DC=org/DC=ligo/O=LIGO/OU=Services/CN=gstlal-spiir-gpu/ldas-pcdev1.ligo.caltech.edu',
}
def update_accounts(apps, schema_editor):
LocalUser = apps.get_model('ligoauth', 'LocalUser')
X509Cert = apps.get_model('ligoauth', 'X509Cert')
# Delete old gstlal-spiir cert
old_cert = X509Cert.objects.get(subject=GSTLAL_SPIIR['old_cert'])
old_cert.delete()
# Create new gstlal-spiir cert
new_cert = X509Cert.objects.create(subject=GSTLAL_SPIIR['new_cert'])
# Get gstlal-spiir user and add new cert
user = LocalUser.objects.get(username=GSTLAL_SPIIR['username'])
user.x509cert_set.add(new_cert)
# Delete gstlal-spiir-gpu user and associated cert(s)
gpu_user = LocalUser.objects.get(username=GSTLAL_SPIIR_GPU['username'])
for cert in gpu_user.x509cert_set.all():
cert.delete()
gpu_user.delete()
def rollback_accounts(apps, schema_editor):
LocalUser = apps.get_model('ligoauth', 'LocalUser')
X509Cert = apps.get_model('ligoauth', 'X509Cert')
# Create old gstlal-spiir cert
old_cert = X509Cert.objects.create(subject=GSTLAL_SPIIR['old_cert'])
# Delete new gstlal-spiir cert
new_cert = X509Cert.objects.get(subject=GSTLAL_SPIIR['new_cert'])
new_cert.delete()
# Get gstlal-spiir user and add old cert
user = LocalUser.objects.get(username=GSTLAL_SPIIR['username'])
user.x509cert_set.add(old_cert)
# Recreate gstlal-spiir-gpu user and associated cert(s)
gpu_user = LocalUser.objects.create(username=GSTLAL_SPIIR_GPU['username'])
gpu_user.last_name = GSTLAL_SPIIR_GPU['last_name']
gpu_user.email = GSTLAL_SPIIR_GPU['email']
gpu_user.save()
gpu_cert = X509Cert.objects.create(subject=GSTLAL_SPIIR_GPU['cert'])
gpu_user.x509cert_set.add(gpu_cert)
class Migration(migrations.Migration):
dependencies = [
('ligoauth', '0003_initial_localuser_and_x509cert_data'),
]
operations = [
migrations.RunPython(update_accounts, rollback_accounts)
]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment