From 2dc244ab209fb72495d19b74b0e6b9aa27adbafb Mon Sep 17 00:00:00 2001
From: Tanner Prestegard <tanner.prestegard@ligo.org>
Date: Mon, 3 Jun 2019 15:14:24 -0500
Subject: [PATCH] Add new certificate for gstlal

---
 .../migrations/0034_add_gstlal_cert.py        | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 gracedb/ligoauth/migrations/0034_add_gstlal_cert.py

diff --git a/gracedb/ligoauth/migrations/0034_add_gstlal_cert.py b/gracedb/ligoauth/migrations/0034_add_gstlal_cert.py
new file mode 100644
index 000000000..663f9712f
--- /dev/null
+++ b/gracedb/ligoauth/migrations/0034_add_gstlal_cert.py
@@ -0,0 +1,42 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.20 on 2019-06-03 20:10
+from __future__ import unicode_literals
+
+from django.db import migrations
+
+ACCOUNT = {
+    'name': 'gstlalcbc',
+    'new_cert': '/DC=org/DC=ligo/O=LIGO/OU=Services/CN=gstlalcbc/submit.nemo.uwm.edu',
+}
+
+
+def add_cert(apps, schema_editor):
+    RobotUser = apps.get_model('ligoauth', 'RobotUser')
+
+    # Get user
+    user = RobotUser.objects.get(username=ACCOUNT['name'])
+
+    # Create new certificate
+    user.x509cert_set.create(subject=ACCOUNT['new_cert'])
+
+
+def delete_cert(apps, schema_editor):
+    RobotUser = apps.get_model('ligoauth', 'RobotUser')
+
+    # Get user
+    user = RobotUser.objects.get(username=ACCOUNT['name'])
+
+    # Delete new certificate
+    cert = user.x509cert_set.get(subject=ACCOUNT['new_cert'])
+    cert.delete()
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('ligoauth', '0033_add_spiir_cert'),
+    ]
+
+    operations = [
+        migrations.RunPython(add_cert, delete_cert),
+    ]
-- 
GitLab