本文整理汇总了Python中pulp.server.db.model.consumer.Consumer.build_resource_tag方法的典型用法代码示例。如果您正苦于以下问题:Python Consumer.build_resource_tag方法的具体用法?Python Consumer.build_resource_tag怎么用?Python Consumer.build_resource_tag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pulp.server.db.model.consumer.Consumer
的用法示例。
在下文中一共展示了Consumer.build_resource_tag方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_with_action
# 需要导入模块: from pulp.server.db.model.consumer import Consumer [as 别名]
# 或者: from pulp.server.db.model.consumer.Consumer import build_resource_tag [as 别名]
def test_with_action(self, mock_get_by_resource):
mock_get_by_resource.return_value = self.calls
result = self.manager.get('consumer1', UNIT_INSTALL_ACTION)
mock_get_by_resource.assert_called_once_with(Consumer.build_resource_tag('consumer1'))
self.assertEqual(list(result), self.calls[:1])
示例2: test_no_action
# 需要导入模块: from pulp.server.db.model.consumer import Consumer [as 别名]
# 或者: from pulp.server.db.model.consumer.Consumer import build_resource_tag [as 别名]
def test_no_action(self, mock_get_by_resource):
mock_get_by_resource.return_value = self.calls
result = self.manager.get('consumer1')
mock_get_by_resource.assert_called_once_with(Consumer.build_resource_tag('consumer1'))
self.assertEqual(result, self.calls)
示例3: create_schedule
# 需要导入模块: from pulp.server.db.model.consumer import Consumer [as 别名]
# 或者: from pulp.server.db.model.consumer.Consumer import build_resource_tag [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: test_save
# 需要导入模块: from pulp.server.db.model.consumer import Consumer [as 别名]
# 或者: from pulp.server.db.model.consumer.Consumer import build_resource_tag [as 别名]
def test_save(self, mock_get_consumer, mock_save):
iso_schedule = 'PT1H'
result = self.manager.create_schedule(UNIT_INSTALL_ACTION, 'consumer1',
self.units, {}, iso_schedule, 4, False)
self.assertEqual(result.iso_schedule, iso_schedule)
self.assertEqual(result.args, ['consumer1'])
self.assertEqual(result.kwargs['units'], self.units)
self.assertEqual(result.kwargs['options'], {})
self.assertEqual(result.resource, Consumer.build_resource_tag('consumer1'))
self.assertTrue(result.enabled is False)
mock_save.assert_called_once_with()
示例5: get
# 需要导入模块: from pulp.server.db.model.consumer import Consumer [as 别名]
# 或者: from pulp.server.db.model.consumer.Consumer import build_resource_tag [as 别名]
def get(consumer_id, action=None):
"""
Get a collection of schedules for the given consumer and action. If no
action is specified, then all actions will be included.
:param consumer_id: a unique ID for a consumer
:type consumer_id: basestring
:param action: a unique identifier for an action, one of
UNIT_INSTALL_ACTION, UNIT_UPDATE_ACTION,
UNIT_UNINSTALL_ACTION
:type action: basestring
:return: iterator of ScheduledCall instances
:rtype: iterator
"""
results = utils.get_by_resource(Consumer.build_resource_tag(consumer_id))
if action:
task = ACTIONS_TO_TASKS[action]
return itertools.ifilter(lambda schedule: schedule.task == task.name, results)
else:
return results