本文整理汇总了Python中bkr.server.model.RecipeTask.by_id方法的典型用法代码示例。如果您正苦于以下问题:Python RecipeTask.by_id方法的具体用法?Python RecipeTask.by_id怎么用?Python RecipeTask.by_id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bkr.server.model.RecipeTask
的用法示例。
在下文中一共展示了RecipeTask.by_id方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_recipe_task_by_id
# 需要导入模块: from bkr.server.model import RecipeTask [as 别名]
# 或者: from bkr.server.model.RecipeTask import by_id [as 别名]
def _get_recipe_task_by_id(recipeid, taskid):
try:
task = RecipeTask.by_id(taskid)
except NoResultFound:
raise NotFound404('Recipe task not found')
if recipeid != '_' and str(task.recipe.id) != recipeid:
raise NotFound404('Recipe task not found')
return task
示例2: watchdog
# 需要导入模块: from bkr.server.model import RecipeTask [as 别名]
# 或者: from bkr.server.model.RecipeTask import by_id [as 别名]
def watchdog(self, task_id):
"""
Returns number of seconds left on task_id watchdog, or False if it doesn't exist.
"""
try:
task = RecipeTask.by_id(task_id)
except InvalidRequestError:
raise BX(_('Invalid task ID: %s' % task_id))
return task.status_watchdog()
示例3: extend
# 需要导入模块: from bkr.server.model import RecipeTask [as 别名]
# 或者: from bkr.server.model.RecipeTask import by_id [as 别名]
def extend(self, task_id, kill_time):
"""
Extend tasks watchdog by kill_time seconds
"""
try:
task = RecipeTask.by_id(task_id)
except InvalidRequestError:
raise BX(_('Invalid task ID: %s' % task_id))
return task.extend(kill_time)
示例4: start
# 需要导入模块: from bkr.server.model import RecipeTask [as 别名]
# 或者: from bkr.server.model.RecipeTask import by_id [as 别名]
def start(self, task_id, watchdog_override=None):
"""
Set task status to Running
"""
try:
task = RecipeTask.by_id(task_id)
except InvalidRequestError:
raise BX(_('Invalid task ID: %s' % task_id))
return task.start(watchdog_override)
示例5: result
# 需要导入模块: from bkr.server.model import RecipeTask [as 别名]
# 或者: from bkr.server.model.RecipeTask import by_id [as 别名]
def result(self, task_id, result_type, path=None, score=None, summary=None):
"""
Record a Result
"""
try:
task = RecipeTask.by_id(task_id)
except InvalidRequestError:
raise BX(_('Invalid task ID: %s' % task_id))
if result_type not in task.result_types:
raise BX(_('Invalid result_type: %s, must be one of %s' %
(result_type, task.result_types)))
kwargs = dict(path=path, score=score, summary=summary)
return getattr(task,result_type)(**kwargs)
示例6: stop
# 需要导入模块: from bkr.server.model import RecipeTask [as 别名]
# 或者: from bkr.server.model.RecipeTask import by_id [as 别名]
def stop(self, task_id, stop_type, msg=None):
"""
Set task status to Completed
"""
try:
task = RecipeTask.by_id(task_id)
except InvalidRequestError:
raise BX(_('Invalid task ID: %s' % task_id))
if stop_type not in task.stop_types:
raise BX(_('Invalid stop_type: %s, must be one of %s' %
(stop_type, task.stop_types)))
kwargs = dict(msg = msg)
return getattr(task,stop_type)(**kwargs)
示例7: update
# 需要导入模块: from bkr.server.model import RecipeTask [as 别名]
# 或者: from bkr.server.model.RecipeTask import by_id [as 别名]
def update(self, task_id, data):
"""
XML-RPC method used by the lab controller harness API to update
a recipe-task's attributes.
"""
try:
task = RecipeTask.by_id(task_id)
except InvalidRequestError:
raise BX(_('Invalid task ID: %s' % task_id))
if 'name' in data:
task.name = data['name']
if 'version' in data:
task.version = data['version']
return task.__json__()
示例8: register_result_file
# 需要导入模块: from bkr.server.model import RecipeTask [as 别名]
# 或者: from bkr.server.model.RecipeTask import by_id [as 别名]
def register_result_file(self, server, result_id, path, filename, basepath):
"""
register file and return path to store
"""
try:
result = RecipeTaskResult.by_id(result_id, lockmode='update')
except NoResultFound:
raise BX(_('Invalid result ID: %s' % result_id))
RecipeTask.by_id(result.recipe_task_id, lockmode='update')
Recipe.by_id(result.recipetask.recipe_id, lockmode='update')
if result.recipetask.is_finished():
raise BX('Cannot register file for finished task %s'
% result.recipetask.t_id)
self._check_log_limit(result.recipetask)
log_recipe = LogRecipeTaskResult.lazy_create(recipe_task_result_id=result.id,
path=path,
filename=filename,
)
log_recipe.server = server
log_recipe.basepath = basepath
result.recipetask.recipe.log_server = urlparse.urlparse(server)[1]
return '%s' % result.filepath
示例9: register_file
# 需要导入模块: from bkr.server.model import RecipeTask [as 别名]
# 或者: from bkr.server.model.RecipeTask import by_id [as 别名]
def register_file(self, server, task_id, path, filename, basepath):
"""
register file and return path to store
"""
try:
recipetask = RecipeTask.by_id(task_id)
except InvalidRequestError:
raise BX(_('Invalid task ID: %s' % task_id))
if recipetask.is_finished():
raise BX('Cannot register file for finished task %s'
% recipetask.t_id)
# Add the log to the DB if it hasn't been recorded yet.
log_recipe = LogRecipeTask.lazy_create(recipe_task_id=recipetask.id,
path=path,
filename=filename,
)
log_recipe.server = server
log_recipe.basepath = basepath
recipetask.recipe.log_server = urlparse.urlparse(server)[1]
return '%s' % recipetask.filepath
示例10: peer_roles
# 需要导入模块: from bkr.server.model import RecipeTask [as 别名]
# 或者: from bkr.server.model.RecipeTask import by_id [as 别名]
def peer_roles(self, task_id):
try:
task = RecipeTask.by_id(task_id)
except NoResultFound:
raise BX(_('Invalid task ID: %s') % task_id)
# don't use set, we want to preserve ordering
roles = {}
for role, recipes in task.recipe.peer_roles().iteritems():
fqdns = roles.setdefault(unicode(role), [])
for recipe in recipes:
if not recipe.resource or not recipe.resource.fqdn:
continue
fqdn = unicode(recipe.resource.fqdn)
if fqdn not in fqdns:
fqdns.append(fqdn)
for role, tasks in task.peer_roles().iteritems():
fqdns = roles.setdefault(unicode(role), [])
for task in tasks:
if not task.recipe.resource or not task.recipe.resource.fqdn:
continue
fqdn = unicode(task.recipe.resource.fqdn)
if fqdn not in fqdns:
fqdns.append(fqdn)
return roles
示例11: to_xml
# 需要导入模块: from bkr.server.model import RecipeTask [as 别名]
# 或者: from bkr.server.model.RecipeTask import by_id [as 别名]
def to_xml(self, id):
taskxml = RecipeTask.by_id(id).to_xml().toprettyxml()
return dict(xml=taskxml)