Project

Profile

Help

Story #4716

Updated by dalley over 5 years ago

Simple content copy means that content units can be copied from one repository into another repository without    considering content-type-specific invariants, such as making sure dependencies are satisfied. 

 The most straightforwards current design is to model this after one-shot upload.    A new URL endpoint will be defined at /api/v3/rpm/copy/.    POSTing to that endpoint with valid parameters will yield an asynchronous task, which will result in a new repository version in the target repository. 

 The user workflow should look like this: 

 <pre> 
 http --form POST http://localhost:24817/pulp/api/v3/rpm/copy/ source_repository=${S_REPO_HREF} destination_repository=${D_REPO_HREF} 
 </pre> 

 Both the repository parameters are required.    When called, all content will be copied.   

 The additions to Django boilerplate will look something like this (see also: copy.py for an example of the function that does the work, and OneShotUploadSerializer in serializers.py) 

 urls.py 
 <pre><code class="python"> 
 urlpatterns = [ 
     url(r'rpm/upload/$', OneShotUploadView.as_view()), 
     url(r'rpm/copy/$', CopyView.as_view()) 
 ] 
 </code></pre> 

 viewsets.py 
 <pre><code class="python"> 
 class CopyView(views.APIView): 
     def post(self, request): 

         serializer = CopySerializer(data=request.data, context={'request': request}) 
         serializer.is_valid(raise_exception=True) 

         # ..... 
         async_result = enqueue_with_reservation( 
             copy_content, [source_repo, dest_repo],    [...],       # lock both repositories function to perform the copying, and arguments to provide it 
             args=[source_repo, dest_repo], kwargs={ 
                 'source_repo': ..., 
                 'dest_repo': ...., 
                 # .... 
             kwargs={} } 
         ) 
         return OperationPostponedResponse(async_result, request) 
 </code></pre>

Back