当前位置: 首页>>代码示例>>Python>>正文


Python System.by_id方法代码示例

本文整理汇总了Python中bkr.server.model.System.by_id方法的典型用法代码示例。如果您正苦于以下问题:Python System.by_id方法的具体用法?Python System.by_id怎么用?Python System.by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bkr.server.model.System的用法示例。


在下文中一共展示了System.by_id方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_power_quiescent_period_statefulness_not_elapsed

# 需要导入模块: from bkr.server.model import System [as 别名]
# 或者: from bkr.server.model.System import by_id [as 别名]
 def test_power_quiescent_period_statefulness_not_elapsed(self):
     if daemons_running_externally():
         raise SkipTest('cannot examine logs of remote beaker-provision')
     provision_process, = [p for p in processes if p.name == \
         'beaker-provision']
     # Initial lookup of this system will reveal no state, so will delay
     # for the whole quiescent period
     try:
         provision_process.start_output_capture()
         with session.begin():
             system = data_setup.create_system(lab_controller=self.get_lc())
             system.power.power_type = PowerType.lazy_create(name=u'dummy')
             system.power.power_quiescent_period = 1
             system.power.power_id = u'' # make power script not sleep
             system.power.delay_until = None
             system.action_power(action=u'off', service=u'testdata')
         wait_for_commands_to_finish(system, timeout=10)
     finally:
         provision_output = provision_process.finish_output_capture()
     self.assertIn('Entering quiescent period, delaying 1 seconds for '
         'command %s'  % system.command_queue[0].id, provision_output)
     # Increase the quiescent period, to ensure we enter it
     try:
         provision_process.start_output_capture()
         with session.begin():
             system = System.by_id(system.id, User.by_user_name('admin'))
             system.power.power_quiescent_period = 10
             system.action_power(action=u'on', service=u'testdata')
         wait_for_commands_to_finish(system, timeout=15)
     finally:
         provision_output = provision_process.finish_output_capture()
     self.assertIn('Entering quiescent period', provision_output)
开发者ID:ShaolongHu,项目名称:beaker,代码行数:34,代码来源:test_provision.py

示例2: reserve

# 需要导入模块: from bkr.server.model import System [as 别名]
# 或者: from bkr.server.model.System import by_id [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)
开发者ID:ustbgaofan,项目名称:beaker,代码行数:45,代码来源:reserve_workflow.py

示例3: removeSystem

# 需要导入模块: from bkr.server.model import System [as 别名]
# 或者: from bkr.server.model.System import by_id [as 别名]
    def removeSystem(self, group_id=None, id=None, **kw):
        group = Group.by_id(group_id)
        system = System.by_id(id, identity.current.user)

        # A group owner can remove a system from their group.
        # A system owner can remove their system from a group.
        # But note this is not symmetrical with adding systems.
        if not (group.can_edit(identity.current.user) or
                system.can_edit(identity.current.user)):
            flash(_(u'Not permitted to remove %s from %s') % (system, group))
            redirect('../groups/mine')

        group.systems.remove(system)
        activity = GroupActivity(identity.current.user, u'WEBUI', u'Removed', u'System', system.fqdn, u"")
        sactivity = SystemActivity(identity.current.user, u'WEBUI', u'Removed', u'Group', group.display_name, u"")
        group.activity.append(activity)
        system.activity.append(sactivity)
        flash( _(u"%s Removed" % system.fqdn))
        raise redirect("./edit?group_id=%s" % group_id)
开发者ID:ustbgaofan,项目名称:beaker,代码行数:21,代码来源:group.py


注:本文中的bkr.server.model.System.by_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。