本文整理汇总了Python中bkr.server.model.System.by_type方法的典型用法代码示例。如果您正苦于以下问题:Python System.by_type方法的具体用法?Python System.by_type怎么用?Python System.by_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bkr.server.model.System
的用法示例。
在下文中一共展示了System.by_type方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reserve
# 需要导入模块: from bkr.server.model import System [as 别名]
# 或者: from bkr.server.model.System import by_type [as 别名]
def reserve(self, distro_tree_id, system_id=None, lab_controller_id=None):
""" Either queue or provision the system now """
if system_id == 'search':
redirect('/reserve_system', distro_tree_id=distro_tree_id)
elif system_id:
try:
system = System.by_id(system_id, identity.current.user)
except InvalidRequestError:
flash(_(u'Invalid System ID %s' % system_id))
system_name = system.fqdn
else:
system_name = 'Any System'
distro_names = []
return_value = dict(
system_id = system_id,
system = system_name,
distro = '',
distro_tree_ids = [],
)
warn = None
if not isinstance(distro_tree_id, list):
distro_tree_id = [distro_tree_id]
for id in distro_tree_id:
try:
distro_tree = DistroTree.by_id(id)
if System.by_type(type=SystemType.machine,
systems=distro_tree.systems(user=identity.current.user))\
.count() < 1:
warn = _(u'No systems compatible with %s') % distro_tree
distro_names.append(unicode(distro_tree))
return_value['distro_tree_ids'].append(id)
except NoResultFound:
flash(_(u'Invalid distro tree ID %s') % id)
distro = ", ".join(distro_names)
return_value['distro'] = distro
return dict(form=self.reserveform,
action='./doit',
value = return_value,
warn=warn,
options = None,
title='Reserve %s' % system_name)