Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
partial fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dralley committed Feb 5, 2020
1 parent 58e2133 commit f4d293e
Showing 1 changed file with 44 additions and 43 deletions.
87 changes: 44 additions & 43 deletions pulp_2to3_migration/app/pre_migration.py
Expand Up @@ -205,49 +205,50 @@ async def pre_migrate_all_without_content(plan, type_to_repo_ids, repo_id_to_typ

with ProgressReport(message='Processing Pulp 2 repositories, importers, distributors',
code='processing.repositories') as pb:
repos = plan.get_repositories()

# filter by repo type
repos_to_check = []
for repo_type in plan.get_plugins():
repos_to_check += type_to_repo_ids[repo_type]

mongo_repo_q = mongo_Q(repo_id__in=repos_to_check)
mongo_repo_qs = Repository.objects(mongo_repo_q)

pb.total = mongo_repo_qs.count()
pb.save()

importers_repos = plan.get_importers_repos()
distributors_repos = plan.get_distributors_repos()

importer_types = []
distributor_types = []
for plugin in plan.get_plugin_plans():
distributor_types.extend(plugin.migrator.distributor_migrators.keys())
importer_types.extend(plugin.migrator.importer_migrators.keys())

for repo_data in mongo_repo_qs.only('id',
'repo_id',
'last_unit_added',
'last_unit_removed',
'description',
'notes'):
repo = None
repo_id = repo_data.repo_id
with transaction.atomic():
if not repos or repos and repo_id in repos:
repo = await pre_migrate_repo(repo_data, repo_id_to_type)
# do not pre-migrate importers/distributors in case of special repo setup
# and no importers/distributors were specified in the MP
if not repos or repos and importers_repos:
await pre_migrate_importer(repo_id, importers_repos, importer_types, repo)
if not repos or repos and distributors_repos:
await pre_migrate_distributor(repo_id, distributors_repos, distributor_types,
repo)
if repo:
await pre_migrate_repocontent(repo)
pb.increment()

import pydevd_pycharm
pydevd_pycharm.settrace('localhost', port=12735, stdoutToServer=True, stderrToServer=True)

for plugin_plan in plan.get_plugin_plans():
repos = plugin_plan.repositories_to_migrate
# filter by repo type
repos_to_check = type_to_repo_ids[plugin_plan.type]

mongo_repo_q = mongo_Q(repo_id__in=repos_to_check)
mongo_repo_qs = Repository.objects(mongo_repo_q)

if pb.total is None:
pb.total = 0
pb.total += mongo_repo_qs.count()
pb.save()

importers_repos = plugin_plan.repositories_importers_to_migrate
distributors_repos = plugin_plan.repositories_distributors_to_migrate

distributor_types = list(plugin_plan.migrator.distributor_migrators.keys())
importer_types = list(plugin_plan.migrator.importer_migrators.keys())

for repo_data in mongo_repo_qs.only('id',
'repo_id',
'last_unit_added',
'last_unit_removed',
'description',
'notes'):
repo = None
repo_id = repo_data.repo_id
with transaction.atomic():
if not repos or repos and repo_id in repos:
repo = await pre_migrate_repo(repo_data, repo_id_to_type)
# do not pre-migrate importers/distributors in case of special repo setup
# and no importers/distributors were specified in the MP
if not repos or repos and importers_repos:
await pre_migrate_importer(repo_id, importers_repos, importer_types, repo)
if not repos or repos and distributors_repos:
await pre_migrate_distributor(repo_id, distributors_repos, distributor_types,
repo)
if repo:
await pre_migrate_repocontent(repo)
pb.increment()


async def pre_migrate_repo(record, repo_id_to_type):
Expand Down

0 comments on commit f4d293e

Please sign in to comment.