Gitlab will migrate to a new storage backend starting 0300 UTC on 2020-04-04. We do not anticipate a maintenance window for this migration. Performance may be impacted over the weekend. Thanks for your patience.

Commit a3486e79 authored by Tanner Prestegard's avatar Tanner Prestegard Committed by GraceDB

Add account and cert for Fermi GBM follow-up

parent 0c815890
Pipeline #55030 passed with stages
in 7 minutes
# -*- coding: utf-8 -*-
# Generated by Django 1.11.18 on 2019-03-27 17:12
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations
ACCOUNT = {
'username': 'fermi-gbm-follow-up',
'email': 'tyson.littenberg@ligo.org',
'first_name': '',
'last_name': 'Fermi-GBM follow-up',
}
CERTS = [
'/DC=org/DC=cilogon/C=US/O=LIGO/OU=Robots/CN=hippo.nsstc.uah.edu/CN=Fermi-GBM-follow-up/CN=Tyson Littenberg/CN=UID:tyson.littenberg.robot',
]
def create_account_and_certs(apps, schema_editor):
RobotUser = apps.get_model('ligoauth', 'RobotUser')
X509Cert = apps.get_model('ligoauth', 'X509Cert')
Group = apps.get_model('auth', 'Group')
# Create user
user = RobotUser.objects.create(**ACCOUNT)
# Add user to LVC group
group = Group.objects.get(name=settings.LVC_GROUP)
group.user_set.add(user)
# 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', '0027_add_olib_cert'),
]
operations = [
migrations.RunPython(create_account_and_certs,
delete_account_and_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