Ejemplo n.º 1
0
Archivo: repo.py Proyecto: pcreech/pulp
    def delete_by_importer_id(repo_id, importer_id):
        """
        Delete all schedules for the specified repo and importer.

        :param importer_id:     unique ID for an importer
        :type  importer_id:     basestring
        """
        utils.delete_by_resource(importer_controller.build_resource_tag(repo_id, importer_id))
Ejemplo n.º 2
0
    def delete_by_importer_id(repo_id, importer_id):
        """
        Delete all schedules for the specified repo and importer.

        :param importer_id:     unique ID for an importer
        :type  importer_id:     basestring
        """
        utils.delete_by_resource(
            importer_controller.build_resource_tag(repo_id, importer_id))
Ejemplo n.º 3
0
    def create(cls,
               repo_id,
               importer_id,
               sync_options,
               schedule,
               failure_threshold=None,
               enabled=True):
        """
        Create a new sync schedule for a given repository using the given importer.

        :param repo_id:         unique ID for a repository
        :type  repo_id:         basestring
        :param importer_id:     unique ID for an importer
        :type  importer_id:     basestring
        :param sync_options:    dictionary that contains the key 'override_config',
                                whose value should be passed as the 'overrides'
                                parameter to the sync 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
        importer_controller.get_valid_importer(repo_id, importer_id)
        utils.validate_keys(sync_options, _SYNC_OPTION_KEYS)
        utils.validate_initial_schedule_options(schedule, failure_threshold,
                                                enabled)

        task = repo_controller.queue_sync_with_auto_publish.name
        args = [repo_id]
        kwargs = {'overrides': sync_options['override_config']}
        resource = importer_controller.build_resource_tag(repo_id, importer_id)
        schedule = ScheduledCall(schedule,
                                 task,
                                 args=args,
                                 kwargs=kwargs,
                                 resource=resource,
                                 failure_threshold=failure_threshold,
                                 enabled=enabled)
        schedule.save()
        try:
            importer_controller.get_valid_importer(repo_id, importer_id)
        except exceptions.MissingResource:
            # back out of this whole thing, since the importer disappeared
            utils.delete(schedule.id)
            raise

        return schedule
Ejemplo n.º 4
0
Archivo: repo.py Proyecto: pcreech/pulp
    def create(cls, repo_id, importer_id, sync_options, schedule, failure_threshold=None, enabled=True):
        """
        Create a new sync schedule for a given repository using the given importer.

        :param repo_id:         unique ID for a repository
        :type  repo_id:         basestring
        :param importer_id:     unique ID for an importer
        :type  importer_id:     basestring
        :param sync_options:    dictionary that contains the key 'override_config',
                                whose value should be passed as the 'overrides'
                                parameter to the sync 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
        importer_controller.get_valid_importer(repo_id, importer_id)
        utils.validate_keys(sync_options, _SYNC_OPTION_KEYS)
        utils.validate_initial_schedule_options(schedule, failure_threshold, enabled)

        task = repo_controller.queue_sync_with_auto_publish.name
        args = [repo_id]
        kwargs = {"overrides": sync_options["override_config"]}
        resource = importer_controller.build_resource_tag(repo_id, importer_id)
        schedule = ScheduledCall(
            schedule,
            task,
            args=args,
            kwargs=kwargs,
            resource=resource,
            failure_threshold=failure_threshold,
            enabled=enabled,
        )
        schedule.save()
        try:
            importer_controller.get_valid_importer(repo_id, importer_id)
        except exceptions.MissingResource:
            # back out of this whole thing, since the importer disappeared
            utils.delete(schedule.id)
            raise

        return schedule
Ejemplo n.º 5
0
Archivo: repo.py Proyecto: pcreech/pulp
    def list(cls, repo_id, importer_id):
        """
        Returns an iterator of ScheduledCall instances that represent schedules
        for the specified repo and importer.

        :param repo_id:     unique ID for a repository
        :type  repo_id:     basestring
        :param importer_id: unique ID for an importer
        :type  importer_id: basestring

        :return:    iterator of ScheduledCall instances
        :rtype:     iterator
        """
        importer_controller.get_valid_importer(repo_id, importer_id)
        return utils.get_by_resource(importer_controller.build_resource_tag(repo_id, importer_id))
Ejemplo n.º 6
0
    def list(cls, repo_id, importer_id):
        """
        Returns an iterator of ScheduledCall instances that represent schedules
        for the specified repo and importer.

        :param repo_id:     unique ID for a repository
        :type  repo_id:     basestring
        :param importer_id: unique ID for an importer
        :type  importer_id: basestring

        :return:    iterator of ScheduledCall instances
        :rtype:     iterator
        """
        importer_controller.get_valid_importer(repo_id, importer_id)
        return utils.get_by_resource(
            importer_controller.build_resource_tag(repo_id, importer_id))
Ejemplo n.º 7
0
 def test_resource_tag(self):
     """
     Build an example resource tag.
     """
     tag = importer.build_resource_tag('repo_id', 'importer_id')
     self.assertEqual(tag, 'pulp:importer:repo_id:importer_id')
Ejemplo n.º 8
0
 def test_resource_tag(self):
     """
     Build an example resource tag.
     """
     tag = importer.build_resource_tag('repo_id', 'importer_id')
     self.assertEqual(tag, 'pulp:importer:repo_id:importer_id')
Ejemplo n.º 9
0
 def test_resource_tag(self):
     """
     Build an example resource tag.
     """
     tag = importer.build_resource_tag("repo_id", "importer_id")
     self.assertEqual(tag, "pulp:importer:repo_id:importer_id")