Skip to content
Snippets Groups Projects
Commit 00c9e379 authored by Tanner Prestegard's avatar Tanner Prestegard Committed by GraceDB
Browse files

Updating robot certificates for waveburst account

parent cc056f41
No related branches found
No related tags found
No related merge requests found
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2018-06-08 15:12
#
# This migration adds new certificates for the waveburst account and removes
# an old one
from __future__ import unicode_literals
from django.db import migrations
ACCOUNT = {
'username': 'waveburst',
'remove_certs': [
'/DC=org/DC=ligo/O=LIGO/OU=Services/CN=waveburst-atlas/atlas9.atlas.aei.uni-hannover.de',
],
'new_certs': [
'/DC=org/DC=ligo/O=LIGO/OU=Services/CN=cwb/atlas9.atlas.aei.uni-hannover.de',
'/DC=org/DC=ligo/O=LIGO/OU=Services/CN=cwb/virgo.infn.it',
],
}
def update_certs(apps, schema_editor):
LocalUser = apps.get_model('ligoauth', 'LocalUser')
X509Cert = apps.get_model('ligoauth', 'X509Cert')
# Get user
user = LocalUser.objects.get(username=ACCOUNT['username'])
# Delete old certificates
for subject in ACCOUNT['remove_certs']:
X509Cert.objects.get(subject=subject).delete()
# Create new certificates and associate with user
for subject in ACCOUNT['new_certs']:
new_cert = X509Cert.objects.create(subject=subject)
user.x509cert_set.add(new_cert)
def revert_certs(apps, schema_editor):
LocalUser = apps.get_model('ligoauth', 'LocalUser')
X509Cert = apps.get_model('ligoauth', 'X509Cert')
# Get user
user = LocalUser.objects.get(username=ACCOUNT['username'])
# Create old certificates and associate with user
for subject in ACCOUNT['remove_certs']:
cert = X509Cert.objects.create(subject=subject)
user.x509cert_set.add(cert)
# Delete new certs
for subject in ACCOUNT['new_certs']:
X509Cert.objects.get(subject=subject).delete()
class Migration(migrations.Migration):
dependencies = [
('ligoauth', '0007_update_gstlalcbctest'),
]
operations = [
migrations.RunPython(update_certs, revert_certs),
]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment