forked from pulp/pulp_rpm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for automatic publishing and distributing
Required PR: pulp/pulpcore#1229 closes: #7622 https://pulp.plan.io/issues/7622
- Loading branch information
Showing
10 changed files
with
363 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add support for automatic publishing and distributing. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# Generated by Django 2.2.19 on 2021-03-19 17:42 | ||
|
||
from django.db import connection, migrations, models, transaction | ||
import django.db.models.deletion | ||
|
||
|
||
pks_to_delete = [] | ||
|
||
|
||
def migrate_data_from_old_master_model_to_new_master_model(apps, schema_editor): | ||
RpmDistribution = apps.get_model('rpm', 'RpmDistribution') | ||
CoreDistribution = apps.get_model('core', 'Distribution') | ||
for old_file_distribution in RpmDistribution.objects.all(): | ||
with transaction.atomic(): | ||
new_master_model_entry = CoreDistribution( | ||
pulp_id=old_file_distribution.pulp_id, | ||
pulp_created=old_file_distribution.pulp_created, | ||
pulp_last_updated=old_file_distribution.pulp_last_updated, | ||
pulp_type=old_file_distribution.pulp_type, | ||
name=old_file_distribution.name, | ||
base_path=old_file_distribution.base_path, | ||
content_guard=old_file_distribution.content_guard, | ||
remote=old_file_distribution.remote, | ||
publication=old_file_distribution.publication, | ||
) | ||
new_master_model_entry.save() | ||
old_file_distribution.distribution_ptr = new_master_model_entry | ||
old_file_distribution.save() | ||
pks_to_delete.append(old_file_distribution.pulp_id) | ||
|
||
|
||
def delete_remaining_old_master_model_entries(apps, schema_editor): | ||
with connection.cursor() as cursor: | ||
for pk in pks_to_delete: | ||
cursor.execute("DELETE from core_basedistribution WHERE pulp_id = %s", [pk]) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('core', '0062_add_new_distribution_mastermodel'), | ||
('rpm', '0031_ulnremote'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='rpmdistribution', | ||
name='distribution_ptr', | ||
field=models.OneToOneField(auto_created=True, null=True, default=None, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
parent_link=True, primary_key=False, | ||
related_name='rpm_rpmdistribution', serialize=False, | ||
to='core.Distribution'), | ||
preserve_default=False, | ||
), | ||
migrations.RunPython(migrate_data_from_old_master_model_to_new_master_model), | ||
migrations.RemoveField( | ||
model_name='rpmdistribution', | ||
name='basedistribution_ptr', | ||
), | ||
migrations.AlterField( | ||
model_name='rpmdistribution', | ||
name='distribution_ptr', | ||
field=models.OneToOneField(auto_created=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
parent_link=True, primary_key=True, | ||
related_name='rpm_rpmdistribution', serialize=False, | ||
to='core.Distribution'), | ||
preserve_default=False, | ||
), | ||
migrations.RemoveField( | ||
model_name='rpmdistribution', | ||
name='publication', | ||
), | ||
migrations.RunPython(delete_remaining_old_master_model_entries), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Generated by Django 2.2.19 on 2021-04-02 21:07 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('rpm', '0032_new_distribution_model'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='rpmrepository', | ||
name='autopublish', | ||
field=models.BooleanField(default=False), | ||
), | ||
migrations.AddField( | ||
model_name='rpmrepository', | ||
name='gpgcheck', | ||
field=models.IntegerField(choices=[(0, 0), (1, 1)], default=0), | ||
), | ||
migrations.AddField( | ||
model_name='rpmrepository', | ||
name='metadata_checksum_type', | ||
field=models.CharField(choices=[('unknown', 'unknown'), ('md5', 'md5'), ('sha1', 'sha1'), ('sha1', 'sha1'), ('sha224', 'sha224'), ('sha256', 'sha256'), ('sha384', 'sha384'), ('sha512', 'sha512')], default='sha256', max_length=10), | ||
), | ||
migrations.AddField( | ||
model_name='rpmrepository', | ||
name='package_checksum_type', | ||
field=models.CharField(choices=[('unknown', 'unknown'), ('md5', 'md5'), ('sha1', 'sha1'), ('sha1', 'sha1'), ('sha224', 'sha224'), ('sha256', 'sha256'), ('sha384', 'sha384'), ('sha512', 'sha512')], default='sha256', max_length=10), | ||
), | ||
migrations.AddField( | ||
model_name='rpmrepository', | ||
name='repo_gpgcheck', | ||
field=models.IntegerField(choices=[(0, 0), (1, 1)], default=0), | ||
), | ||
migrations.AddField( | ||
model_name='rpmrepository', | ||
name='sqlite_metadata', | ||
field=models.BooleanField(default=False), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.