<div dir="ltr"><div>I actually wrote this code[0] in Pulp 2 for the puppet plugin so maybe I can chime in.</div><div><br></div><div>> <span style="font-size:12.800000190734863px">As you pointed out, it requires the REST API client to know all the metadata required to create a piece of Content from an Artifact.</span></div><div><br></div>This not quite true. The pulp_file plugin currently extracts metadata (ie digest) from the artifact when a content unit is created:<div><br></div><div><a href="https://github.com/pulp/pulp_file/blob/master/pulp_file/app/viewsets.py#L78">https://github.com/pulp/pulp_file/blob/master/pulp_file/app/viewsets.py#L78</a></div><div><br></div><div>I think something similar could be done for other content units.</div><div><br></div><div>To handle both upload and sync, one option is to use a django signal that will extract the metadata from the puppet module:</div><div><br></div><div><a href="https://docs.djangoproject.com/en/2.0/topics/signals/">https://docs.djangoproject.com/en/2.0/topics/signals/</a><br></div><div><br></div><div>I’d probably create a model method though on your Content model that both the sync and content unit creation code can call.</div><div><br></div><div>[0] <a href="https://github.com/pulp/pulp_puppet/pull/126">https://github.com/pulp/pulp_puppet/pull/126</a></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><br></div><div>David<br></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Wed, Apr 18, 2018 at 12:03 PM, Dennis Kliban <span dir="ltr"><<a href="mailto:dkliban@redhat.com" target="_blank">dkliban@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">On Wed, Apr 18, 2018 at 11:02 AM, Simon Baatz <span dir="ltr"><<a href="mailto:gmbnomis@gmail.com" target="_blank">gmbnomis@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I am looking at Pulp 3 for the first time and have a question on<br>
creating/importing content units.<br>
<br>
In the file plugin, a file content unit can be created using<br>
POST@.../content/file/ by passing the meta-data ('relative_path') and the<br>
artifact (from which 'digest' is obtained as additional meta-data).  The<br>
POST is synchronous (returning a 201 CREATED if successful).<br>
<br>
However, for other artifact types there is more meta-data in the artifact(s)<br>
themselves and it may be "harder" to obtain.  For example, Puppet modules,<br>
Chef cookbooks, and Helm charts are tarballs with specific meta-data files. <br>
In Pulp 2, this meta-data extraction seems to be part of the<br>
import_uploaded_unit task.  According to the code comments, the puppet<br>
module unpacks the entire module to get the meta-data.<br>
<br>
If I got this correctly, Pulp 3 splits this up into content unit<br>
creation (sync) and "importing" (async, add content units using<br>
POST@...versions/).  Where should the meta-data extraction be done<br>
given this split?  (the first step is synchronous, but perhaps it is<br>
acceptable to do some work there nevertheless. The second step<br>
looks too late)<br>
<br></blockquote><div><br></div></span><div>The REST API provided by pulpcore in Pulp 3 is very generic. As you pointed out, it requires the REST API client to know all the metadata required to create a piece of Content from an Artifact. So I picture this process as a 3 step process in the client: <br><br>1) Inspect the artifact to extract all needed metadata<br></div><div>2) Use Artifact creation REST API to upload Artifact to Pulp<br></div><div>3) Use SomeContent creation REST API to create SomeContent from the uploaded Artifact and the metadata extracted in step 1<br><br></div><div>With all that said, each plugin is also be able to provide additional REST API endpoints. I suspect that some of these endpoints will support "smart upload" that will be aware of the content type that is being uploaded. These endpoints will allow users to upload an Artifact of a specific type and the server will extract all the needed metadata to create the SomeContent in Pulp. <br></div><span class=""><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
- Simon<br>
<br>
______________________________<wbr>_________________<br>
Pulp-dev mailing list<br>
<a href="mailto:Pulp-dev@redhat.com" target="_blank">Pulp-dev@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/pulp-dev" rel="noreferrer" target="_blank">https://www.redhat.com/mailman<wbr>/listinfo/pulp-dev</a><br>
</blockquote></span></div><br></div></div>
<br>______________________________<wbr>_________________<br>
Pulp-dev mailing list<br>
<a href="mailto:Pulp-dev@redhat.com">Pulp-dev@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/pulp-dev" rel="noreferrer" target="_blank">https://www.redhat.com/<wbr>mailman/listinfo/pulp-dev</a><br>
<br></blockquote></div><br></div>