def run_synchronization(self, progress, cancelled, options): """ Run a repo_sync() on this repository. :param progress: A progress report. :type progress: pulp_node.progress.RepositoryProgress :param options: node synchronization options. :type options: dict :return: The task result. """ warnings.warn(TASK_DEPRECATION_WARNING, NodeDeprecationWarning) bindings = resources.pulp_bindings() poller = TaskPoller(bindings) max_download = options.get(constants.MAX_DOWNLOAD_CONCURRENCY_KEYWORD, constants.DEFAULT_DOWNLOAD_CONCURRENCY) node_certificate = options[constants.PARENT_SETTINGS][constants.NODE_CERTIFICATE] key, certificate = Bundle.split(node_certificate) configuration = { importer_constants.KEY_MAX_DOWNLOADS: max_download, importer_constants.KEY_MAX_SPEED: options.get(constants.MAX_DOWNLOAD_BANDWIDTH_KEYWORD), importer_constants.KEY_SSL_CLIENT_KEY: key, importer_constants.KEY_SSL_CLIENT_CERT: certificate, importer_constants.KEY_SSL_VALIDATION: False, } http = bindings.repo_actions.sync(self.repo_id, configuration) if http.response_code != httplib.ACCEPTED: raise RepoSyncRestError(self.repo_id, http.response_code) # The repo sync is returned with a single sync task in the Call Report task = http.response_body.spawned_tasks[0] result = poller.join(task.task_id, progress, cancelled) if cancelled(): self._cancel_synchronization(task) return result
def run_synchronization(self, progress, cancelled, options): """ Run a repo_sync() on this repository. :param progress: A progress report. :type progress: pulp_node.progress.RepositoryProgress :param options: node synchronization options. :type options: dict :return: The task result. """ bindings = resources.pulp_bindings() poller = TaskPoller(bindings) max_download = options.get( constants.MAX_DOWNLOAD_CONCURRENCY_KEYWORD, constants.DEFAULT_DOWNLOAD_CONCURRENCY) node_certificate = options[constants.PARENT_SETTINGS][constants.NODE_CERTIFICATE] key, certificate = Bundle.split(node_certificate) configuration = { importer_constants.KEY_MAX_DOWNLOADS: max_download, importer_constants.KEY_MAX_SPEED: options.get(constants.MAX_DOWNLOAD_BANDWIDTH_KEYWORD), importer_constants.KEY_SSL_CLIENT_KEY: key, importer_constants.KEY_SSL_CLIENT_CERT: certificate, importer_constants.KEY_SSL_VALIDATION: False, } http = bindings.repo_actions.sync(self.repo_id, configuration) if http.response_code != httplib.ACCEPTED: raise RepoSyncRestError(self.repo_id, http.response_code) # The repo sync is returned with a single sync task in the Call Report task = http.response_body.spawned_tasks[0] result = poller.join(task.task_id, progress, cancelled) if cancelled(): self._cancel_synchronization(task) return result
def test_repository(self, *mocks): # Setup repository = Repository(REPO_ID) progress = Mock() cancelled = Mock(return_value=False) # Test options = { constants.MAX_DOWNLOAD_CONCURRENCY_KEYWORD: MAX_CONCURRENCY, constants.MAX_DOWNLOAD_BANDWIDTH_KEYWORD: MAX_BANDWIDTH, constants.PARENT_SETTINGS: PARENT_SETTINGS, } repository.run_synchronization(progress, cancelled, options) binding = mocks[1] key, certificate = Bundle.split(NODE_CERTIFICATE) expected_conf = { importer_constants.KEY_SSL_VALIDATION: False, importer_constants.KEY_MAX_DOWNLOADS: MAX_CONCURRENCY, importer_constants.KEY_MAX_SPEED: MAX_BANDWIDTH, importer_constants.KEY_SSL_CLIENT_KEY: key, importer_constants.KEY_SSL_CLIENT_CERT: certificate, } # Verify binding.assert_called_with(REPO_ID, expected_conf)
def test_repository(self, *mocks): # Setup repository = Repository(REPO_ID) progress = Mock() cancelled = Mock(return_value=False) # Test options = { constants.MAX_DOWNLOAD_CONCURRENCY_KEYWORD: MAX_CONCURRENCY, constants.MAX_DOWNLOAD_BANDWIDTH_KEYWORD: MAX_BANDWIDTH, constants.PARENT_SETTINGS: PARENT_SETTINGS, } repository.run_synchronization(progress, cancelled, options) binding = mocks[1] key, certificate = Bundle.split(NODE_CERTIFICATE) expected_conf = { importer_constants.KEY_SSL_VALIDATION: False, importer_constants.KEY_MAX_DOWNLOADS: MAX_CONCURRENCY, importer_constants.KEY_MAX_SPEED: MAX_BANDWIDTH, importer_constants.KEY_SSL_CLIENT_KEY: key, importer_constants.KEY_SSL_CLIENT_CERT: certificate, } # Verify binding.assert_called_with(REPO_ID, expected_conf)
def testSplit(self): key, crt = Bundle.split(BUNDLE) self.assertEqual(key.strip(), KEY.strip()) self.assertEqual(crt.strip(), CERTIFICATE.strip())
def testSplit(self): key, crt = Bundle.split(BUNDLE) self.assertEqual(key.strip(), KEY.strip()) self.assertEqual(crt.strip(), CERTIFICATE.strip())