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

Update robot certificate for virgo_detchar account

parent 4281cb52
No related branches found
No related tags found
No related merge requests found
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2018-10-01 16:50
from __future__ import unicode_literals
from django.db import migrations
ACCOUNT = {
'username': 'virgo_detchar',
'old_cert': '/DC=org/DC=ligo/O=LIGO/OU=Services/CN=Virgodetchar/lscgw.virgo.infn.it',
'new_cert': '/DC=org/DC=ligo/O=LIGO/OU=Services/CN=virgodetchar/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 certificate
old_cert = X509Cert.objects.get(subject=ACCOUNT['old_cert'])
old_cert.delete()
# Create new cert and associate with user
new_cert = X509Cert.objects.create(subject=ACCOUNT['new_cert'])
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'])
# Delete new certificate
new_cert = X509Cert.objects.get(subject=ACCOUNT['new_cert'])
new_cert.delete()
# Create new cert and associate with user
old_cert = X509Cert.objects.create(subject=ACCOUNT['old_cert'])
user.x509cert_set.add(old_cert)
class Migration(migrations.Migration):
dependencies = [
('ligoauth', '0010_update_pycbc_cert'),
]
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