Commit 546c3d5b authored by Tanner Prestegard's avatar Tanner Prestegard Committed by GraceDB

Update certificates for LHO CDS

parent 8cee4a4c
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2018-12-14 15:55
from __future__ import unicode_literals
from django.db import migrations
ACCOUNT_NAME = 'cds_lho'
NEW_CERT = '/DC=org/DC=cilogon/C=US/O=LIGO/OU=Robots/CN=h1fescript0.cds.ligo-wa.caltech.edu/CN=external_alerts/CN=David Barker/CN=UID:david.barker.robot'
OLD_CERTS = [
'/DC=org/DC=ligo/O=LIGO/OU=Services/CN=h1fescript0/cds.ligo-wa.caltech.edu',
]
def update_certs(apps, schema_editor):
User = apps.get_model('auth', 'User')
# Get user
user = User.objects.get(username=ACCOUNT_NAME)
# Create new certificate
user.x509cert_set.create(subject=NEW_CERT)
# Delete old certificates
for subj in OLD_CERTS:
old_cert = user.x509cert_set.get(subject=subj)
old_cert.delete()
def revert_certs(apps, schema_editor):
User = apps.get_model('auth', 'User')
X509Cert = apps.get_model('ligoauth', 'X509Cert')
# Delete new certificate
new_cert = X509Cert.objects.get(subject=NEW_CERT)
new_cert.delete()
# Get user
user = User.objects.get(username=ACCOUNT_NAME)
# Create old certificates
for subj in OLD_CERTS:
user.x509cert_set.create(subject=subj)
class Migration(migrations.Migration):
dependencies = [
('ligoauth', '0016_update_bayeswave_certs'),
]
operations = [
migrations.RunPython(update_certs, revert_certs),
]
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