-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow import/export of content not directly tied to repos #819
Conversation
Note this is WIP PR that only handles exporting the mapping so far. Here is an example of how this would be used: class PackageResource(BaseContentResource):
"""
Resource for import/export of rpm_package entities.
"""
content_mapping = {}
def _add_to_mapping(self, repo, uuids):
if not uuids.exists():
return
self.content_mapping[repo.name] = list(map(str, uuids))
def set_up_queryset(self):
"""
:return: Packages specific to a specified repo-version.
"""
packages = Package.objects.filter(pk__in=self.repo_version.content)
self._add_to_mapping(self.repo_version.repository, packages.values_list("pulp_id",
flat=True))
tree = DistributionTree.objects.filter(pk__in=self.repo_version.content).first()
if tree:
for repo in tree.repositories():
version = repo.latest_version()
packages |= Package.objects.filter(pk__in=version.content)
self._add_to_mapping(repo, packages.values_list("pulp_id", flat=True))
return packages
class Meta:
model = Package
import_id_fields = model.natural_key_fields() And here is an example of the content_mapping that gets exported: https://gist.github.com/daviddavis/5d1575c6f89521bb3bff559afb7b5f2b. |
Attached issue: https://pulp.plan.io/issues/7252 |
d49e357
to
14b39d0
Compare
|
||
|
||
def _destination_repo(importer, source_repo_name): | ||
"""Find the destination repository based on source repo's name.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Args are missing in the doc string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since PEP 257 only applies to public methods, I only added a single line docstring to give a general overview of the method since I didn't feel like an entire docstring was necessary.
66ac2d7
to
ff8bd94
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Travis is failing but I don't need to re-review |
fixes #7252
Please be sure you have read our documentation on creating PRs:
https://docs.pulpproject.org/contributing/pull-request-walkthrough.html