def delete(self): """ Delete this repository. """ bindings = resources.pulp_bindings() bindings.repo.delete(self.repo_id) log.info('Repository: %s, deleted', self.repo_id)
def delete(self): """ Delete this importer. """ bindings = resources.pulp_bindings() bindings.repo_importer.delete(self.repo_id, self.imp_id) log.info("Importer: %s/%s, deleted", self.repo_id, self.imp_id)
def delete(self): """ Delete this distributor. """ bindings = resources.pulp_bindings() bindings.repo_distributor.delete(self.repo_id, self.dist_id) log.info('Distributor: %s/%s, deleted', self.repo_id, self.dist_id)
def delete(self): """ Delete this distributor. """ bindings = resources.pulp_bindings() bindings.repo_distributor.delete(self.repo_id, self.dist_id) log.info("Distributor: %s/%s, deleted", self.repo_id, self.dist_id)
def _distributors(self): bindings = resources.pulp_bindings() http = bindings.server_info.get_distributors() if http.response_code == httplib.OK: return set([p[TYPE_ID] for p in http.response_body]) else: raise Exception('get distributors failed:%d', http.response_code)
def delete(self): """ Delete this repository. """ bindings = resources.pulp_bindings() bindings.repo.delete(self.repo_id) log.info("Repository: %s, deleted", self.repo_id)
def delete(self): """ Delete this importer. """ bindings = resources.pulp_bindings() bindings.repo_importer.delete(self.repo_id, self.imp_id) log.info('Importer: %s/%s, deleted', self.repo_id, self.imp_id)
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 purge_orphans(): """ Purge orphaned units within the inventory. """ bindings = resources.pulp_bindings() http = bindings.content_orphan.remove_all() if http.response_code != httplib.ACCEPTED: raise PurgeOrphansError(http.response_code)
def purge_orphans(): """ Purge orphaned units within the inventory. """ bindings = resources.pulp_bindings() http = bindings.content_orphan.remove_all() if http.response_code != httplib.ACCEPTED: raise PurgeOrphansError(http.response_code)
def add(self): """ Add this importer to the inventory. """ conf = self.details["config"] bindings = resources.pulp_bindings() bindings.repo_importer.create(self.repo_id, self.imp_id, conf) log.info("Importer %s/%s, added", self.repo_id, self.imp_id)
def add(self): """ Add this importer to the inventory. """ conf = self.details['config'] bindings = resources.pulp_bindings() bindings.repo_importer.create(self.repo_id, self.imp_id, conf) log.info('Importer %s/%s, added', self.repo_id, self.imp_id)
def update(self, configuration): """ Update this importer. :param configuration: The updated configuration. :type configuration: dict """ bindings = resources.pulp_bindings() bindings.repo_importer.update(self.repo_id, self.imp_id, configuration) log.info("Importer: %s/%s, updated", self.repo_id, self.imp_id)
def update(self, delta): """ Update this repository. :param delta: The properties that need to be updated. :type delta: dict """ bindings = resources.pulp_bindings() bindings.repo.update(self.repo_id, delta) log.info("Repository: %s, updated", self.repo_id)
def update(self, configuration): """ Update this repository-distributor in the inventory. :param configuration: The updated configuration. :type configuration: dict """ bindings = resources.pulp_bindings() bindings.repo_distributor.update(self.repo_id, self.dist_id, configuration) log.info('Distributor: %s/%s, updated', self.repo_id, self.dist_id)
def update(self, configuration): """ Update this importer. :param configuration: The updated configuration. :type configuration: dict """ bindings = resources.pulp_bindings() bindings.repo_importer.update(self.repo_id, self.imp_id, configuration) log.info('Importer: %s/%s, updated', self.repo_id, self.imp_id)
def update(self, configuration): """ Update this repository-distributor in the inventory. :param configuration: The updated configuration. :type configuration: dict """ bindings = resources.pulp_bindings() bindings.repo_distributor.update(self.repo_id, self.dist_id, configuration) log.info("Distributor: %s/%s, updated", self.repo_id, self.dist_id)
def update(self, delta): """ Update this repository. :param delta: The properties that need to be updated. :type delta: dict """ bindings = resources.pulp_bindings() bindings.repo.update(self.repo_id, delta) log.info('Repository: %s, updated', self.repo_id)
def purge_orphans(): """ Purge orphaned units within the inventory. """ warnings.warn(TASK_DEPRECATION_WARNING, NodeDeprecationWarning) bindings = resources.pulp_bindings() http = bindings.content_orphan.remove_all() if http.response_code != httplib.ACCEPTED: raise PurgeOrphansError(http.response_code)
def purge_orphans(): """ Purge orphaned units within the inventory. """ warnings.warn(TASK_DEPRECATION_WARNING, NodeDeprecationWarning) bindings = resources.pulp_bindings() http = bindings.content_orphan.remove_all() if http.response_code != httplib.ACCEPTED: raise PurgeOrphansError(http.response_code)
def add(self): """ Add this repository-distributor to the inventory. """ bindings = resources.pulp_bindings() bindings.repo_distributor.create(self.repo_id, self.details['distributor_type_id'], self.details['config'], self.details['auto_publish'], self.dist_id) log.info('Distributor: %s/%s, added', self.repo_id, self.dist_id)
def _cancel_synchronization(self, task): """ Cancel a task associated with a repository synchronization. :param task: A running task. :type task: pulp.bindings.responses.Task """ bindings = resources.pulp_bindings() http = bindings.tasks.cancel_task(task.task_id) if http.response_code == httplib.ACCEPTED: log.info("Task [%s] canceled", task.task_id) else: log.error("Task [%s] cancellation failed http=%s", task.task_id, http.response_code)
def _cancel_synchronization(self, task): """ Cancel a task associated with a repository synchronization. :param task: A running task. :type task: pulp.bindings.responses.Task """ bindings = resources.pulp_bindings() http = bindings.tasks.cancel_task(task.task_id) if http.response_code == httplib.ACCEPTED: log.info('Task [%s] cancelled', task.task_id) else: log.error('Task [%s] cancellation failed http=%s', task.task_id, http.response_code)
def add(self): """ Add this repository-distributor to the inventory. """ bindings = resources.pulp_bindings() bindings.repo_distributor.create( self.repo_id, self.details['distributor_type_id'], self.details['config'], self.details['auto_publish'], self.dist_id) log.info('Distributor: %s/%s, added', self.repo_id, self.dist_id)
def add(self): """ Add this repository-distributor to the inventory. """ bindings = resources.pulp_bindings() bindings.repo_distributor.create( self.repo_id, self.details["distributor_type_id"], self.details["config"], self.details["auto_publish"], self.dist_id, ) log.info("Distributor: %s/%s, added", self.repo_id, self.dist_id)
def fetch(repo_id, imp_id): """ Fetch the repository-importer from the inventory. :return: The fetched importer. :rtype: Importer """ try: bindings = resources.pulp_bindings() http = bindings.repo_importer.importer(repo_id, imp_id) details = http.response_body return Importer(repo_id, imp_id, details) except NotFoundException: return None
def fetch(repo_id, imp_id): """ Fetch the repository-importer from the inventory. :return: The fetched importer. :rtype: Importer """ try: bindings = resources.pulp_bindings() http = bindings.repo_importer.importer(repo_id, imp_id) details = http.response_body return Importer(repo_id, imp_id, details) except NotFoundException: return None
def test_verify_ssl_true(self, read_config): """ Make sure that verify_ssl is passed correctly when it is true. """ ca_path = '/some/path' node_config = {'parent_oauth': {'key': 'some_key', 'secret': 'ssssh!', 'user_id': 'bgates'}, 'main': {'verify_ssl': 'True', 'ca_path': ca_path}} node_config = config.Config(node_config).graph() read_config.return_value = node_config bindings = resources.pulp_bindings() self.assertEqual(bindings.bindings.server.ca_path, ca_path) self.assertEqual(bindings.bindings.server.verify_ssl, True)
def fetch_all(): """ Fetch all repositories from the inventory. :return: A list of: Repository :rtype: list """ repositories = [] bindings = resources.pulp_bindings() for repository in bindings.repo_search.search(): repo_id = repository['id'] details = {'repository': repository, 'distributors': []} r = Repository(repo_id, details) repositories.append(r) return repositories
def fetch_all(): """ Fetch all repositories from the inventory. :return: A list of: Repository :rtype: list """ repositories = [] bindings = resources.pulp_bindings() for repository in bindings.repo_search.search(): repo_id = repository["id"] details = {"repository": repository, "distributors": []} r = Repository(repo_id, details) repositories.append(r) return repositories
def fetch(repo_id, dist_id): """ Fetch the repository-distributor from the inventory. :param repo_id: The repository ID. :type repo_id: str :param dist_id: A distributor ID. :type dist_id: str :return: The fetched distributor. :rtype: Distributor """ try: bindings = resources.pulp_bindings() http = bindings.repo_distributor.distributor(repo_id, dist_id) details = http.response_body return Distributor(repo_id, dist_id, details) except NotFoundException: return None
def fetch(repo_id, dist_id): """ Fetch the repository-distributor from the inventory. :param repo_id: The repository ID. :type repo_id: str :param dist_id: A distributor ID. :type dist_id: str :return: The fetched distributor. :rtype: Distributor """ try: bindings = resources.pulp_bindings() http = bindings.repo_distributor.distributor(repo_id, dist_id) details = http.response_body return Distributor(repo_id, dist_id, details) except NotFoundException: return None
def fetch(repo_id): """ Fetch a specific repository from the inventory. :param repo_id: Repository ID. :type repo_id: str :return: The fetched repository. :rtype: Repository """ details = {} bindings = resources.pulp_bindings() try: http = bindings.repo.repository(repo_id) details['repository'] = http.response_body http = bindings.repo_distributor.distributors(repo_id) details['distributors'] = http.response_body http = bindings.repo_importer.importers(repo_id) details['importers'] = http.response_body return Repository(repo_id, details) except NotFoundException: return None
def fetch(repo_id): """ Fetch a specific repository from the inventory. :param repo_id: Repository ID. :type repo_id: str :return: The fetched repository. :rtype: Repository """ details = {} bindings = resources.pulp_bindings() try: http = bindings.repo.repository(repo_id) details["repository"] = http.response_body http = bindings.repo_distributor.distributors(repo_id) details["distributors"] = http.response_body http = bindings.repo_importer.importers(repo_id) details["importers"] = http.response_body return Repository(repo_id, details) except NotFoundException: return None
def add(self): """ Add the repository and associated plugins. """ # repository bindings = resources.pulp_bindings() bindings.repo.create( self.repo_id, self.basic_properties['display_name'], self.basic_properties['description'], self.basic_properties['notes']) # distributors for details in self.distributors: dist_id = details['id'] dist = Distributor(self.repo_id, dist_id, details) dist.add() # importers for details in self.importers: imp_id = details['id'] importer = Importer(self.repo_id, imp_id, details) importer.add() log.info('Repository: %s, added', self.repo_id)
def add(self): """ Add the repository and associated plugins. """ # repository bindings = resources.pulp_bindings() bindings.repo.create(self.repo_id, self.basic_properties['display_name'], self.basic_properties['description'], self.basic_properties['notes']) bindings.repo.update( self.repo_id, {'scratchpad': self.basic_properties['scratchpad']}) # distributors for details in self.distributors: dist_id = details['id'] dist = Distributor(self.repo_id, dist_id, details) dist.add() # importers for details in self.importers: imp_id = details['id'] importer = Importer(self.repo_id, imp_id, details) importer.add() log.info('Repository: %s, added', self.repo_id)
def add(self): """ Add the repository and associated plugins. """ # repository bindings = resources.pulp_bindings() bindings.repo.create( self.repo_id, self.basic_properties["display_name"], self.basic_properties["description"], self.basic_properties["notes"], ) bindings.repo.update(self.repo_id, {"scratchpad": self.basic_properties["scratchpad"]}) # distributors for details in self.distributors: dist_id = details["id"] dist = Distributor(self.repo_id, dist_id, details) dist.add() # importers for details in self.importers: imp_id = details["id"] importer = Importer(self.repo_id, imp_id, details) importer.add() log.info("Repository: %s, added", self.repo_id)