本文整理汇总了Python中pulp.server.db.model.dispatch.ScheduledCall.save方法的典型用法代码示例。如果您正苦于以下问题:Python ScheduledCall.save方法的具体用法?Python ScheduledCall.save怎么用?Python ScheduledCall.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pulp.server.db.model.dispatch.ScheduledCall
的用法示例。
在下文中一共展示了ScheduledCall.save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_new
# 需要导入模块: from pulp.server.db.model.dispatch import ScheduledCall [as 别名]
# 或者: from pulp.server.db.model.dispatch.ScheduledCall import save [as 别名]
def test_new(self, mock_get_collection):
mock_insert = mock_get_collection.return_value.insert
call = ScheduledCall('PT1M', 'pulp.tasks.dosomething')
call.save()
expected = call.as_dict()
expected['_id'] = bson.ObjectId(expected['_id'])
mock_insert.assert_called_once_with(expected, safe=True)
self.assertFalse(call._new)
示例2: test_existing
# 需要导入模块: from pulp.server.db.model.dispatch import ScheduledCall [as 别名]
# 或者: from pulp.server.db.model.dispatch.ScheduledCall import save [as 别名]
def test_existing(self, mock_get_collection):
mock_update = mock_get_collection.return_value.update
fake_id = bson.ObjectId()
call = ScheduledCall('PT1M', 'pulp.tasks.dosomething', id=fake_id)
call.save()
expected = call.as_dict()
del expected['_id']
mock_update.assert_called_once_with({'_id': fake_id}, expected)
示例3: create_schedule
# 需要导入模块: from pulp.server.db.model.dispatch import ScheduledCall [as 别名]
# 或者: from pulp.server.db.model.dispatch.ScheduledCall import save [as 别名]
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
示例4: create
# 需要导入模块: from pulp.server.db.model.dispatch import ScheduledCall [as 别名]
# 或者: from pulp.server.db.model.dispatch.ScheduledCall import save [as 别名]
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