def delete_by_distributor_id(repo_id, distributor_id): """ Delete all schedules for the specified repo and distributor. :param distributor_id: unique ID for an distributor :type distributor_id: basestring """ utils.delete_by_resource(RepoDistributor.build_resource_tag(repo_id, distributor_id))
def test_calls_delete_resource(self, mock_delete_by): resource = RepoDistributor.build_resource_tag(self.repo, self.distributor) RepoPublishScheduleManager.delete_by_distributor_id( self.repo, self.distributor) mock_delete_by.assert_called_once_with(resource)
def create(cls, repo_id, distributor_id, publish_options, schedule, failure_threshold=None, enabled=True): """ Create a new scheduled publish for the given repository and distributor. :param repo_id: unique ID for a repository :type repo_id: basestring :param distributor_id: unique ID for an distributor :type distributor_id: basestring :param publish_options: dictionary that contains the key 'override_config', whose value should be passed as the 'overrides' parameter to the publish task. This wasn't originally documented, so it isn't clear why overrides value couldn't be passed directly. :type sync_options: dict :param schedule_data: dictionary that contains the key 'schedule', whose value is an ISO8601 string. This wasn't originally documented, so it isn't clear why the string itself couldn't have been passed directly. :type schedule_data: dict :return: new schedule instance :rtype: pulp.server.db.model.dispatch.ScheduledCall """ # validate the input cls.validate_distributor(repo_id, distributor_id) utils.validate_keys(publish_options, _PUBLISH_OPTION_KEYS) utils.validate_initial_schedule_options(schedule, failure_threshold, enabled) task = publish.name args = [repo_id, distributor_id] kwargs = {'overrides': publish_options['override_config']} resource = RepoDistributor.build_resource_tag(repo_id, distributor_id) schedule = ScheduledCall(schedule, task, args=args, kwargs=kwargs, resource=resource, failure_threshold=failure_threshold, enabled=enabled) schedule.save() try: cls.validate_distributor(repo_id, distributor_id) except exceptions.MissingResource: # back out of this whole thing, since the distributor disappeared utils.delete(schedule.id) raise return schedule
def list(cls, repo_id, distributor_id): """ Returns an iterator of ScheduledCall instances that represent schedules for the specified repo and distributor. :param repo_id: unique ID for a repository :type repo_id: basestring :param distributor_id: unique ID for an distributor :type distributor_id: basestring :return: iterator of ScheduledCall instances :rtype: iterator """ cls.validate_distributor(repo_id, distributor_id) return utils.get_by_resource(RepoDistributor.build_resource_tag(repo_id, distributor_id))
def create(cls, repo_id, distributor_id, publish_options, schedule, failure_threshold=None, enabled=True): """ Create a new scheduled publish for the given repository and distributor. :param repo_id: unique ID for a repository :type repo_id: basestring :param distributor_id: unique ID for an distributor :type distributor_id: basestring :param publish_options: dictionary that contains the key 'override_config', whose value should be passed as the 'overrides' parameter to the publish task. This wasn't originally documented, so it isn't clear why overrides value couldn't be passed directly. :type sync_options: dict :param schedule_data: dictionary that contains the key 'schedule', whose value is an ISO8601 string. This wasn't originally documented, so it isn't clear why the string itself couldn't have been passed directly. :type schedule_data: dict :return: new schedule instance :rtype: pulp.server.db.model.dispatch.ScheduledCall """ # validate the input cls.validate_distributor(repo_id, distributor_id) utils.validate_keys(publish_options, _PUBLISH_OPTION_KEYS) utils.validate_initial_schedule_options(schedule, failure_threshold, enabled) task = repo_controller.queue_publish.name args = [repo_id, distributor_id] kwargs = {'overrides': publish_options['override_config']} resource = RepoDistributor.build_resource_tag(repo_id, distributor_id) schedule = ScheduledCall(schedule, task, args=args, kwargs=kwargs, resource=resource, failure_threshold=failure_threshold, enabled=enabled) schedule.save() try: cls.validate_distributor(repo_id, distributor_id) except exceptions.MissingResource: # back out of this whole thing, since the distributor disappeared utils.delete(schedule.id) raise return schedule
def test_list(self, mock_get_by_resource, mock_validate_distributor): ret = RepoPublishScheduleManager.list('repo1', 'distributor1') mock_get_by_resource.assert_called_once_with( RepoDistributor.build_resource_tag('repo1', 'distributor1')) self.assertTrue(ret is mock_get_by_resource.return_value)
def test_calls_delete_resource(self, mock_delete_by): resource = RepoDistributor.build_resource_tag(self.repo, self.distributor) RepoPublishScheduleManager.delete_by_distributor_id(self.repo, self.distributor) mock_delete_by.assert_called_once_with(resource)
def test_list(self, mock_get_by_resource, mock_validate_distributor): ret = RepoPublishScheduleManager.list("repo1", "distributor1") mock_get_by_resource.assert_called_once_with(RepoDistributor.build_resource_tag("repo1", "distributor1")) self.assertTrue(ret is mock_get_by_resource.return_value)