Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# -*- coding: utf-8 -*-
# Generated by Django 1.11.18 on 2019-03-26 16:48
from __future__ import unicode_literals
from django.db import migrations
ACCOUNT = {
'name': 'olib',
'new_cert': '/DC=org/DC=cilogon/C=US/O=LIGO/OU=Robots/CN=ldas-pcdev5.ligo.caltech.edu/CN=LIB/CN=Salvatore Vitale/CN=UID:salvatore.vitale.robot/',
}
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', '0026_update_hinj_acct_and_certs'),
]
operations = [
migrations.RunPython(add_cert, delete_cert),
]