-
Notifications
You must be signed in to change notification settings - Fork 124
/
0032_add_validated_repo.py
54 lines (42 loc) · 1.41 KB
/
0032_add_validated_repo.py
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
43
44
45
46
47
48
49
50
51
52
53
54
# Generated by Django 2.2.19 on 2021-03-24 22:07
from django.db import migrations
def add_validated_repo(apps, schema_editor):
"""Created validated repos"""
AnsibleRepository = apps.get_model('ansible', 'AnsibleRepository')
AnsibleDistribution = apps.get_model('ansible', 'AnsibleDistribution')
RepositoryVersion = apps.get_model('core', 'RepositoryVersion')
repo_data = {
"name": "validated",
"description": "Validated collections",
"pulp_type": "ansible.ansible",
"next_version": 1,
}
repository, _ = AnsibleRepository.objects.get_or_create(
name=repo_data["name"],
defaults=repo_data
)
if not RepositoryVersion.objects.filter(repository__name=repository.name):
RepositoryVersion.objects.create(
repository=repository,
number=0,
complete=True
)
AnsibleDistribution.objects.get_or_create(
base_path=repository.name,
defaults={
"name": repository.name,
"base_path": repository.name,
"repository": repository,
"pulp_type": "ansible.ansible"
}
)
class Migration(migrations.Migration):
dependencies = [
('galaxy', '0031_legacynamespace_legacyrole'),
]
operations = [
migrations.RunPython(
code=add_validated_repo,
reverse_code=migrations.RunPython.noop
)
]