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)
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)
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)
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"") group.activity.append(activity) system.record_activity(user=identity.current.user, service=u'WEBUI', action=u'Removed', field=u'Group', old=group.display_name, new=u"") flash(_(u"%s Removed" % system.fqdn)) raise redirect("./edit?group_id=%s" % group_id)