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

Add acct and certs for deepclean (ML noise cleaning)

parent c82be66c
No related branches found
No related tags found
No related merge requests found
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2019-01-04 18:39
from __future__ import unicode_literals
from django.db import migrations
ACCOUNT = {
'username': 'deepclean',
'email': 'michael.coughlin@ligo.org',
'first_name': '',
'last_name': 'LIGO/Virgo ML Noise Cleaning',
}
CERTS = [
'/DC=org/DC=cilogon/C=US/O=LIGO/OU=Robots/CN=ldas-pcdev2.ligo-wa.caltech.edu/CN=deepclean_lho/CN=Michael Coughlin/CN=UID:michael.coughlin.robot',
'/DC=org/DC=cilogon/C=US/O=LIGO/OU=Robots/CN=ldas-pcdev2.ligo-la.caltech.edu/CN=deepclean_llo/CN=Michael Coughlin/CN=UID:michael.coughlin.robot',
]
def create_account_and_certs(apps, schema_editor):
RobotUser = apps.get_model('ligoauth', 'RobotUser')
X509Cert = apps.get_model('ligoauth', 'X509Cert')
# Create user
user = RobotUser.objects.create(**ACCOUNT)
# Create X509 certificates
for subject in CERTS:
user.x509cert_set.create(subject=subject)
def delete_account_and_certs(apps, schema_editor):
RobotUser = apps.get_model('ligoauth', 'RobotUser')
X509Cert = apps.get_model('ligoauth', 'X509Cert')
# Get user
user = RobotUser.objects.get(username=ACCOUNT['username'])
# Delete certs
for cert in user.x509cert_set.filter(subject__in=CERTS):
cert.delete()
# Delete full User object
user.user_ptr.delete()
class Migration(migrations.Migration):
dependencies = [
('ligoauth', '0020_remove_old_dashboard_certs'),
]
operations = [
migrations.RunPython(create_account_and_certs,
delete_account_and_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