This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stop using mappings for plugin specific items, move everyting to a plugin migrator class. closes #5491 https://pulp.plan.io/issues/5491
- Loading branch information
1 parent
93ff765
commit 57be3e2
Showing
19 changed files
with
115 additions
and
156 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 @@ | ||
Refactor to have plugin discovery via entry_points. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,10 @@ | ||
# temporary hack, to move gradually to one migrator | ||
from pulp_2to3_migration.app.plugin.iso.pulp3.migrator import IsoMigrator | ||
|
||
# for tasking system to ensure only one migration is run at a time | ||
PULP_2TO3_MIGRATION_RESOURCE = 'pulp_2to3_migration' | ||
|
||
# Pulp2 plugins and their content types which can be migrated | ||
# 'pulp2_plugin': 'pulp_2to3_migration pulp2 model class name' | ||
SUPPORTED_PULP2_PLUGINS = { | ||
'iso': ['ISO'], | ||
# 'rpm': [ | ||
# 'Distribution', | ||
# 'Drpm', | ||
# 'Erratum', | ||
# 'Modulemd', | ||
# 'ModulemdDefaults', | ||
# 'PackageCategory', | ||
# 'PackageEnvironment', | ||
# 'PackageGroup', | ||
# 'PackageLangpacks', | ||
# 'Rpm', | ||
# 'Srpm', | ||
# 'YumRepoMetadataFile'], | ||
# 'docker': [ | ||
# 'Blob', | ||
# 'Image', | ||
# 'Manifest', | ||
# 'ManifestList', | ||
# 'Tag'], | ||
} | ||
|
||
# 'pulp2_content_type_id': 'pulp_2to3_migration pulp3 model class name ' | ||
PULP_2TO3_CONTENT_MODEL_MAP = { | ||
'iso': 'Pulp2ISO', | ||
} | ||
|
||
|
||
PULP_2TO3_PLUGIN_MAP = { | ||
'iso': 'pulp_file', | ||
# 'docker' : 'pulp_container', | ||
# 'rpm' : 'pulp_rpm', | ||
} | ||
|
||
PULP2_COLLECTION_MAP = { | ||
'iso': 'units_iso', | ||
# 'docker': 'units_docker_manifest', | ||
# 'rpm': 'units_rpm', | ||
} | ||
|
||
PULP_2TO3_POLICIES = { | ||
'immediate': 'immediate', | ||
'on_demand': 'on_demand', | ||
'background': 'on_demand', | ||
} | ||
|
||
# 'pulp2 plugin': [('pulp2 importer_type_id', 'pulp_2to3 plugin importer migration model'), ... ] | ||
PULP_2TO3_IMPORTER_TYPE_MODEL_MAP = { | ||
'iso': [('iso_importer', 'IsoImporter')] | ||
} | ||
|
||
# 'pulp2 plugin': [('pulp2 distributor_type_id', 'pulp_2to3 plugin distributor migration model'), | ||
# ... ] | ||
# PULP_2TO3_DISTRIBUTOR_TYPE_MODEL_MAP = { | ||
# 'iso': [('iso_distributor', 'IsoDistributor'),] | ||
# } | ||
|
||
PLUGIN_MIGRATORS_MAP = { | ||
'iso': IsoMigrator | ||
} | ||
NOT_USED = 'Not Used' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import pkg_resources | ||
|
||
# { plugin_name: PluginMigratorClass } | ||
PLUGIN_MIGRATORS = {} | ||
|
||
if not PLUGIN_MIGRATORS: | ||
for entry_point in pkg_resources.iter_entry_points(group='migrators'): | ||
PLUGIN_MIGRATORS[entry_point.name] = entry_point.load() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from pulp_2to3_migration.app.plugin.api import ( | ||
ContentMigrationFirstStage, | ||
DeclarativeContentMigration, | ||
Pulp2to3PluginMigrator, | ||
) | ||
|
||
from .pulp2_models import ISO | ||
from .pulp_2to3_models import Pulp2ISO | ||
from .repository import IsoImporter | ||
|
||
|
||
class IsoMigrator(Pulp2to3PluginMigrator): | ||
""" | ||
An entry point for migration the Pulp 2 ISO plugin to Pulp 3. | ||
Attributes: | ||
pulp2_plugin(str): Pulp 2 plugin name | ||
pulp2_content_models(dict): {'pulp2 content_type_id': 'content class to access MongoDB'} | ||
pulp2_collection(str): a pulp2 collection which existence signifies that a plugin | ||
is installed in pulp2 | ||
pulp3_plugin(str): Pulp 3 plugin name | ||
content_models(dict): {'pulp2 content_type_id': 'detail content class to pre-migrate to'} | ||
importer_migrators(dict): {'importer_type_id': 'pulp_2to3 importer interface/migrator'} | ||
""" | ||
pulp2_plugin = 'iso' | ||
pulp2_content_models = { | ||
'iso': ISO, | ||
} | ||
pulp2_collection = 'units_iso' | ||
pulp3_plugin = 'pulp_file' | ||
content_models = { | ||
'iso': Pulp2ISO, | ||
} | ||
importer_migrators = { | ||
'iso_importer': IsoImporter, | ||
} | ||
|
||
@classmethod | ||
async def migrate_content_to_pulp3(cls): | ||
""" | ||
Migrate pre-migrated Pulp 2 ISO content. | ||
""" | ||
first_stage = ContentMigrationFirstStage(cls) | ||
dm = DeclarativeContentMigration(first_stage=first_stage) | ||
await dm.create() |
Empty file.
File renamed without changes.
Empty file.
This file was deleted.
Oops, something went wrong.
3 changes: 2 additions & 1 deletion
3
..._migration/app/plugin/iso/pulp3/models.py → ...ration/app/plugin/iso/pulp_2to3_models.py
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
File renamed without changes.
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.