示例#1
0
文件: consumer.py 项目: pombreda/pulp
    def create_schedule(cls,
                        action,
                        consumer_id,
                        units,
                        options,
                        schedule,
                        failure_threshold=None,
                        enabled=True):
        """
        Creates a new schedule for a consumer action

        :param action:          a unique identified for an action, one of
                                UNIT_INSTALL_ACTION, UNIT_UPDATE_ACTION,
                                UNIT_UNINSTALL_ACTION
        :type  action:          basestring
        :param consumer_id:     a unique ID for a consumer
        :type  consumer_id:     basestring
        :param units:           A list of content units to be installed, each as
                                a dict in the form:
                                    { type_id:<str>, unit_key:<dict> }
        :type  units:           list
        :param options:         a dictionary that will be passed to the
                                action-appropriate task as the "options"
                                argument
        :type  options:         dict
        :param schedule:        ISO8601 string representation of the schedule
        :type  schedule:        basestring
        :param failure_threshold:   optional positive integer indicating how
                                many times this schedule's execution can fail
                                before being automatically disabled.
        :type  failure_threshold:   int or NoneType
        :param enabled:         boolean indicating if this schedule should
                                be actively loaded and executed by the
                                scheduler. Defaults to True.
        :type  enabled:         bool
        :return:    instance of the new ScheduledCal
        :rtype:     pulp.server.db.models.dispatch.ScheduledCall

        :raise:     pulp.server.exceptions.MissingValue
        """
        cls._validate_consumer(consumer_id)
        utils.validate_initial_schedule_options(schedule, failure_threshold,
                                                enabled)
        if not units:
            raise MissingValue(['units'])

        task = ACTIONS_TO_TASKS[action]
        args = [consumer_id]
        kwargs = {'units': units, 'options': options}
        resource = Consumer.build_resource_tag(consumer_id)

        schedule = ScheduledCall(schedule,
                                 task,
                                 args=args,
                                 kwargs=kwargs,
                                 resource=resource,
                                 failure_threshold=failure_threshold,
                                 enabled=enabled)
        schedule.save()
        return schedule
示例#2
0
文件: repo.py 项目: taftsanders/pulp
    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 a 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
        """
        dist = model.Distributor.objects.get_or_404(
            repo_id=repo_id, distributor_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']}
        schedule = ScheduledCall(schedule,
                                 task,
                                 args=args,
                                 kwargs=kwargs,
                                 resource=dist.resource_tag,
                                 failure_threshold=failure_threshold,
                                 enabled=enabled)
        schedule.save()

        try:
            model.Distributor.objects.get_or_404(repo_id=repo_id,
                                                 distributor_id=distributor_id)
        except exceptions.MissingResource:
            # back out of this whole thing, since the distributor disappeared
            utils.delete(schedule.id)
            raise

        return schedule
示例#3
0
文件: repo.py 项目: taftsanders/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
示例#4
0
文件: consumer.py 项目: credativ/pulp
    def create_schedule(cls, action, consumer_id, units, options, schedule, failure_threshold=None, enabled=True):
        """
        Creates a new schedule for a consumer action

        :param action:          a unique identified for an action, one of
                                UNIT_INSTALL_ACTION, UNIT_UPDATE_ACTION,
                                UNIT_UNINSTALL_ACTION
        :type  action:          basestring
        :param consumer_id:     a unique ID for a consumer
        :type  consumer_id:     basestring
        :param units:           A list of content units to be installed, each as
                                a dict in the form:
                                    { type_id:<str>, unit_key:<dict> }
        :type  units:           list
        :param options:         a dictionary that will be passed to the
                                action-appropriate task as the "options"
                                argument
        :type  options:         dict
        :param schedule:        ISO8601 string representation of the schedule
        :type  schedule:        basestring
        :param failure_threshold:   optional positive integer indicating how
                                many times this schedule's execution can fail
                                before being automatically disabled.
        :type  failure_threshold:   int or NoneType
        :param enabled:         boolean indicating if this schedule should
                                be actively loaded and executed by the
                                scheduler. Defaults to True.
        :type  enabled:         bool
        :return:    instance of the new ScheduledCal
        :rtype:     pulp.server.db.models.dispatch.ScheduledCall

        :raise:     pulp.server.exceptions.MissingValue
        """
        cls._validate_consumer(consumer_id)
        utils.validate_initial_schedule_options(schedule, failure_threshold, enabled)
        if not units:
            raise MissingValue(["units"])

        task = ACTIONS_TO_TASKS[action]
        args = [consumer_id]
        kwargs = {"units": units, "options": options}
        resource = Consumer.build_resource_tag(consumer_id)

        schedule = ScheduledCall(
            schedule,
            task,
            args=args,
            kwargs=kwargs,
            resource=resource,
            failure_threshold=failure_threshold,
            enabled=enabled,
        )
        schedule.save()
        return schedule
示例#5
0
文件: repo.py 项目: 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
示例#6
0
文件: repo.py 项目: pcreech/pulp
    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 a 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
        """
        dist = model.Distributor.objects.get_or_404(repo_id=repo_id, distributor_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"]}
        schedule = ScheduledCall(
            schedule,
            task,
            args=args,
            kwargs=kwargs,
            resource=dist.resource_tag,
            failure_threshold=failure_threshold,
            enabled=enabled,
        )
        schedule.save()

        try:
            model.Distributor.objects.get_or_404(repo_id=repo_id, distributor_id=distributor_id)
        except exceptions.MissingResource:
            # back out of this whole thing, since the distributor disappeared
            utils.delete(schedule.id)
            raise

        return schedule