[Pulp-list] Content Unit Multiple Uploads, Same Unit Key

Jay Medrano jay.medrano at neulion.com
Fri Aug 5 21:26:14 UTC 2016


Hi,



I’m currently working on developing a plugin to support build artifacts
with custom metadata. I’d like to know if there is a way to update or
replace an existing content unit. There are some use cases we’ve identified
where we want to replace a previous content unit that has the same unit
key. This might be a rare case, and the obvious alternative is to delete
the existing content unit before starting the new upload. I was wondering
if there was a way to handle this during the second upload? In the Importer
upload_unit function, I noticed from other plugin examples that
NotUniqueError exceptions are handled by re-associating the old content
unit. I might be interpreting that incorrectly. If that’s the case, most of
our re-upload attempts would fail silently, and the old data would remain.
Can someone help me find a way to replace, or update an existing content
unit that has an identical unit key, preferably during the upload/import
process?



Here is the relevant plugin code that tries to import/associate a new
content unit.

*        try:*

*            artifact = models.Artifact.from_file(file_path, metadata)*

*            artifact.save_and_import_content(file_path)*

*            repo_controller.associate_single_unit(repo.repo_obj, artifact)*

*        except NotUniqueError:*

*            artifact = artifact.__class__.objects.get(**artifact.unit_key)*

*            repo_controller.associate_single_unit(repo.repo_obj, artifact)*

*        except Exception as e:*

*            return {'success_flag': False, 'summary': e.message,
'details': {}}*

*        return {'success_flag': True, 'summary': '', 'details': {}}*



Jay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/pulp-list/attachments/20160805/b19f750b/attachment.htm>


More information about the Pulp-list mailing list