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

Add new robot cert for dashboard/nagios monitor

parent 4d99a150
No related branches found
No related tags found
No related merge requests found
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2018-12-03 16:43
from __future__ import unicode_literals
from django.db import migrations
ACCOUNT = {
'username': 'nagios',
'new_cert': '/DC=org/DC=cilogon/C=US/O=LIGO/OU=Robots/CN=dashboard.ligo.org/CN=NagiosShibScraper/CN=Thomas Downes/CN=UID:thomas.downes.robot',
}
def add_cert(apps, schema_editor):
RobotUser = apps.get_model('ligoauth', 'RobotUser')
X509Cert = apps.get_model('ligoauth', 'X509Cert')
# Get user
user = RobotUser.objects.get(username=ACCOUNT['username'])
# Create new cert and associate with user
new_cert = X509Cert.objects.create(subject=ACCOUNT['new_cert'])
user.x509cert_set.add(new_cert)
def remove_cert(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 new certificate
new_cert = X509Cert.objects.get(subject=ACCOUNT['new_cert'])
new_cert.delete()
class Migration(migrations.Migration):
dependencies = [
('ligoauth', '0014_x509cert_subject_longer'),
]
operations = [
migrations.RunPython(add_cert, remove_cert),
]
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