def POST(self, repo_id): """ Import an uploaded unit into the given repository. :param repo_id: The id of the repository the upload should be imported into :type repo_id: basestring :return: A json serialized dictionary with two keys. 'success_flag' indexes a boolean value that indicates whether the import was successful, and 'summary' will contain the summary as reported by the Importer. :rtype: basestring """ # Collect user input params = self.params() upload_id = params['upload_id'] unit_type_id = params['unit_type_id'] unit_key = params['unit_key'] unit_metadata = params.pop('unit_metadata', None) # Coordinator configuration tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id), action_tag('import_upload')] upload_manager = manager_factory.content_upload_manager() call_request = CallRequest(upload_manager.import_uploaded_unit, [repo_id, unit_type_id, unit_key, unit_metadata, upload_id], tags=tags, archive=True) call_request.updates_resource(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id) report = execution.execute(call_request) return self.ok(report)
def POST(self, repo_id): # Collect user input params = self.params() upload_id = params['upload_id'] unit_type_id = params['unit_type_id'] unit_key = params['unit_key'] unit_metadata = params.pop('unit_metadata', None) # Coordinator configuration tags = [ resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id), action_tag('import_upload') ] upload_manager = manager_factory.content_upload_manager() call_request = CallRequest( upload_manager.import_uploaded_unit, [repo_id, unit_type_id, unit_key, unit_metadata, upload_id], tags=tags, archive=True) call_request.updates_resource( dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id) execution.execute(call_request) return self.ok(None)
def test_syntactic_sugar_methods(self): """ Tests the syntactic sugar methods for retrieving specific managers. """ # Setup factory.initialize() # Test self.assertTrue(isinstance(factory.authentication_manager(), AuthenticationManager)) self.assertTrue(isinstance(factory.cert_generation_manager(), CertGenerationManager)) self.assertTrue(isinstance(factory.certificate_manager(), CertificateManager)) self.assertTrue(isinstance(factory.password_manager(), PasswordManager)) self.assertTrue(isinstance(factory.permission_manager(), PermissionManager)) self.assertTrue(isinstance(factory.permission_query_manager(), PermissionQueryManager)) self.assertTrue(isinstance(factory.role_manager(), RoleManager)) self.assertTrue(isinstance(factory.role_query_manager(), RoleQueryManager)) self.assertTrue(isinstance(factory.user_manager(), UserManager)) self.assertTrue(isinstance(factory.user_query_manager(), UserQueryManager)) self.assertTrue(isinstance(factory.repo_manager(), RepoManager)) self.assertTrue(isinstance(factory.repo_unit_association_manager(), RepoUnitAssociationManager)) self.assertTrue(isinstance(factory.repo_publish_manager(), RepoPublishManager)) self.assertTrue(isinstance(factory.repo_query_manager(), RepoQueryManager)) self.assertTrue(isinstance(factory.repo_sync_manager(), RepoSyncManager)) self.assertTrue(isinstance(factory.content_manager(), ContentManager)) self.assertTrue(isinstance(factory.content_query_manager(), ContentQueryManager)) self.assertTrue(isinstance(factory.content_upload_manager(), ContentUploadManager)) self.assertTrue(isinstance(factory.consumer_manager(), ConsumerManager)) self.assertTrue(isinstance(factory.topic_publish_manager(), TopicPublishManager))
def setUp(self): base.PulpServerTests.setUp(self) mock_plugins.install() self.upload_manager = manager_factory.content_upload_manager() self.repo_manager = manager_factory.repo_manager() self.importer_manager = manager_factory.repo_importer_manager()
def setUp(self): base.PulpServerTests.setUp(self) mock_plugins.install() self.upload_manager = manager_factory.content_upload_manager() self.repo_manager = manager_factory.repo_manager() self.importer_manager = manager_factory.repo_importer_manager()
def POST(self, repo_id): # Collect user input params = self.params() upload_id = params["upload_id"] unit_type_id = params["unit_type_id"] unit_key = params["unit_key"] unit_metadata = params.pop("unit_metadata", None) # Coordinator configuration resources = { dispatch_constants.RESOURCE_REPOSITORY_TYPE: {repo_id: dispatch_constants.RESOURCE_UPDATE_OPERATION} } tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id), action_tag("import_upload")] upload_manager = manager_factory.content_upload_manager() call_request = CallRequest( upload_manager.import_uploaded_unit, [repo_id, unit_type_id, unit_key, unit_metadata, upload_id], resources=resources, tags=tags, archive=True, ) return execution.execute_ok(self, call_request)
def put(self, request, upload_id, offset): """ Upload to a specific file upload. :param request: WSGI request object, body contains bits to upload :type request: django.core.handlers.wsgi.WSGIRequest :param upload_id: id of the initialized upload :type upload_id: str :param offset: place in the uploaded file to start writing :type offset: str of an integer :return: response containing null :rtype: django.http.HttpResponse :raises: pulp.server.exceptions.MissingResource if upload ID does not exist :raises: InvalidValue if offset cannot be converted to an integer """ try: offset = int(offset) except ValueError: raise InvalidValue(['offset']) upload_manager = factory.content_upload_manager() # If the upload ID doesn't exists, either because it was not initialized # or was deleted, the call to the manager will raise missing resource upload_manager.save_data(upload_id, offset, request.body) return generate_json_response(None)
def put(self, request, upload_id, offset): """ Upload to a specific file upload. :param request: WSGI request object, body contains bits to upload :type request: django.core.handlers.wsgi.WSGIRequest :param upload_id: id of the initialized upload :type upload_id: str :param offset: place in the uploaded file to start writing :type offset: str of an integer :return: response containing null :rtype: django.http.HttpResponse :raises: pulp.server.exceptions.MissingResource if upload ID does not exist :raises: InvalidValue if offset cannot be converted to an integer """ try: offset = int(offset) except ValueError: raise InvalidValue(["offset"]) upload_manager = factory.content_upload_manager() # If the upload ID doesn't exists, either because it was not initialized # or was deleted, the call to the manager will raise missing resource upload_manager.save_data(upload_id, offset, request.body) return generate_json_response(None)
def test_syntactic_sugar_methods(self): """ Tests the syntactic sugar methods for retrieving specific managers. """ # Setup factory.initialize() # Test self.assertTrue(isinstance(factory.authentication_manager(), AuthenticationManager)) self.assertTrue(isinstance(factory.cert_generation_manager(), CertGenerationManager)) self.assertTrue(isinstance(factory.certificate_manager(), CertificateManager)) self.assertTrue(isinstance(factory.password_manager(), PasswordManager)) self.assertTrue(isinstance(factory.permission_manager(), PermissionManager)) self.assertTrue(isinstance(factory.permission_query_manager(), PermissionQueryManager)) self.assertTrue(isinstance(factory.role_manager(), RoleManager)) self.assertTrue(isinstance(factory.role_query_manager(), RoleQueryManager)) self.assertTrue(isinstance(factory.user_manager(), UserManager)) self.assertTrue(isinstance(factory.user_query_manager(), UserQueryManager)) self.assertTrue(isinstance(factory.repo_manager(), RepoManager)) self.assertTrue(isinstance(factory.repo_unit_association_manager(), RepoUnitAssociationManager)) self.assertTrue(isinstance(factory.repo_publish_manager(), RepoPublishManager)) self.assertTrue(isinstance(factory.repo_query_manager(), RepoQueryManager)) self.assertTrue(isinstance(factory.repo_sync_manager(), RepoSyncManager)) self.assertTrue(isinstance(factory.content_manager(), ContentManager)) self.assertTrue(isinstance(factory.content_query_manager(), ContentQueryManager)) self.assertTrue(isinstance(factory.content_upload_manager(), ContentUploadManager)) self.assertTrue(isinstance(factory.consumer_manager(), ConsumerManager)) self.assertTrue(isinstance(factory.topic_publish_manager(), TopicPublishManager))
def POST(self): upload_manager = factory.content_upload_manager() upload_id = upload_manager.initialize_upload() location = serialization.link.child_link_obj(upload_id) return self.created(location['_href'], { '_href': location['_href'], 'upload_id': upload_id })
def setUp(self): super(BaseUploadTest, self).setUp() self.upload_manager = manager_factory.content_upload_manager() upload_storage_dir = self.upload_manager._upload_storage_dir() if os.path.exists(upload_storage_dir): shutil.rmtree(upload_storage_dir) os.makedirs(upload_storage_dir) dummy_plugins.install()
def setUp(self): super(BaseUploadTest, self).setUp() self.upload_manager = manager_factory.content_upload_manager() upload_storage_dir = self.upload_manager._upload_storage_dir() if os.path.exists(upload_storage_dir): shutil.rmtree(upload_storage_dir) os.makedirs(upload_storage_dir) dummy_plugins.install()
def get(self, request): """ Return a serialized response containing a dict with a list of upload_ids. :param request: WSGI request object :type request: django.core.handlers.wsgi.WSGIRequest :return: Serialized response containing a list of upload ids :rtype: django.http.HttpResponse """ upload_manager = factory.content_upload_manager() upload_ids = upload_manager.list_upload_ids() return generate_json_response({'upload_ids': upload_ids})
def setUp(self): base.PulpServerTests.setUp(self) mock_plugins.install() self.upload_manager = manager_factory.content_upload_manager() self.repo_manager = manager_factory.repo_manager() self.importer_manager = manager_factory.repo_importer_manager() upload_storage_dir = self.upload_manager._upload_storage_dir() if os.path.exists(upload_storage_dir): shutil.rmtree(upload_storage_dir) os.makedirs(upload_storage_dir)
def get(self, request): """ Return a serialized response containing a dict with a list of upload_ids. :param request: WSGI request object :type request: django.core.handlers.wsgi.WSGIRequest :return: Serialized response containing a list of upload ids :rtype: django.http.HttpResponse """ upload_manager = factory.content_upload_manager() upload_ids = upload_manager.list_upload_ids() return generate_json_response({"upload_ids": upload_ids})
def delete(self, request, upload_id): """ Delete a single upload. :param request: WSGI request object :type request: django.core.handlers.wsgi.WSGIRequest :param upload_id: id of the upload to be deleted :type upload_id: str :return: response with None :rtype: django.http.HttpResponse """ upload_manager = factory.content_upload_manager() upload_manager.delete_upload(upload_id) return generate_json_response(None)
def delete(self, request, upload_id): """ Delete a single upload. :param request: WSGI request object :type request: django.core.handlers.wsgi.WSGIRequest :param upload_id: id of the upload to be deleted :type upload_id: str :return: response with None :rtype: django.http.HttpResponse """ upload_manager = factory.content_upload_manager() upload_manager.delete_upload(upload_id) return generate_json_response(None)
def PUT(self, upload_id, offset): # If the upload ID doesn't exists, either because it was not initialized # or was deleted, the call to the manager will raise missing resource try: offset = int(offset) except ValueError: raise InvalidValue(['offset']) upload_manager = factory.content_upload_manager() data = self.data() upload_manager.save_data(upload_id, offset, data) return self.ok(None)
def test_syntactic_sugar_methods(self): """ Tests the syntactic sugar methods for retrieving specific managers. """ # Test self.assertTrue(isinstance(factory.repo_manager(), RepoManager)) self.assertTrue(isinstance(factory.repo_unit_association_manager(), RepoUnitAssociationManager)) self.assertTrue(isinstance(factory.repo_publish_manager(), RepoPublishManager)) self.assertTrue(isinstance(factory.repo_query_manager(), RepoQueryManager)) self.assertTrue(isinstance(factory.repo_sync_manager(), RepoSyncManager)) self.assertTrue(isinstance(factory.content_manager(), ContentManager)) self.assertTrue(isinstance(factory.content_query_manager(), ContentQueryManager)) self.assertTrue(isinstance(factory.content_upload_manager(), ContentUploadManager)) self.assertTrue(isinstance(factory.consumer_manager(), ConsumerManager))
def PUT(self, upload_id, offset): # If the upload ID doesn't exists, either because it was not initialized # or was deleted, the call to the manager will raise missing resource try: offset = int(offset) except ValueError: raise InvalidValue(['offset']) upload_manager = factory.content_upload_manager() data = self.data() upload_manager.save_data(upload_id, offset, data) return self.ok(None)
def post(self, request, *args, **kwargs): """ Initialize an upload and return a serialized dict containing the upload data. :param request: WSGI request object :type request: django.core.handlers.wsgi.WSGIRequest :return : Serialized response containing a url to delete an upload and a unique id. :rtype : django.http.HttpResponse """ upload_manager = factory.content_upload_manager() upload_id = upload_manager.initialize_upload() href = reverse("content_upload_resource", kwargs={"upload_id": upload_id}) response = generate_json_response({"_href": href, "upload_id": upload_id}) response_redirect = generate_redirect_response(response, href) return response_redirect
def post(self, request, *args, **kwargs): """ Initialize an upload and return a serialized dict containing the upload data. :param request: WSGI request object :type request: django.core.handlers.wsgi.WSGIRequest :return : Serialized response containing a url to delete an upload and a unique id. :rtype : django.http.HttpResponse """ upload_manager = factory.content_upload_manager() upload_id = upload_manager.initialize_upload() href = reverse('content_upload_resource', kwargs={'upload_id': upload_id}) response = generate_json_response({ '_href': href, 'upload_id': upload_id }) response_redirect = generate_redirect_response(response, href) return response_redirect
def POST(self, repo_id): # Collect user input params = self.params() upload_id = params['upload_id'] unit_type_id = params['unit_type_id'] unit_key = params['unit_key'] unit_metadata = params.pop('unit_metadata', None) # Coordinator configuration tags = [resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id), action_tag('import_upload')] upload_manager = manager_factory.content_upload_manager() call_request = CallRequest(upload_manager.import_uploaded_unit, [repo_id, unit_type_id, unit_key, unit_metadata, upload_id], tags=tags, archive=True) call_request.updates_resource(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id) execution.execute(call_request) return self.ok(None)
def GET(self): upload_manager = factory.content_upload_manager() upload_ids = upload_manager.list_upload_ids() return self.ok({'upload_ids': upload_ids})
def DELETE(self, upload_id): upload_manager = factory.content_upload_manager() upload_manager.delete_upload(upload_id) return self.ok(None)
def DELETE(self, upload_id): upload_manager = factory.content_upload_manager() upload_manager.delete_upload(upload_id) return self.ok(None)
def POST(self): upload_manager = factory.content_upload_manager() upload_id = upload_manager.initialize_upload() location = serialization.link.child_link_obj(upload_id) return self.created(location['_href'], {'_href' : location['_href'], 'upload_id' : upload_id})
def GET(self): upload_manager = factory.content_upload_manager() upload_ids = upload_manager.list_upload_ids() return self.ok({'upload_ids' : upload_ids})