Exemple #1
0
 def test_clear_running_commands(self):
     with session.begin():
         system = data_setup.create_system(lab_controller=self.lc)
         command = CommandActivity(
                 user=None, service=u'testdata', action=u'on',
                 status=CommandStatus.running)
         system.command_queue.append(command)
         other_system = data_setup.create_system()
         other_command = CommandActivity(
                 user=None, service=u'testdata', action=u'on',
                 status=CommandStatus.running)
         other_system.command_queue.append(other_command)
     self.server.auth.login_password(self.lc.user.user_name, u'logmein')
     self.server.labcontrollers.clear_running_commands(u'Staleness')
     with session.begin():
         session.refresh(command)
         self.assertEquals(command.status, CommandStatus.aborted)
         self.assertEquals(other_command.status, CommandStatus.running)
Exemple #2
0
 def setUp(self):
     with session.begin():
         self.system = data_setup.create_system()
         user = data_setup.create_user()
         self.activity = CommandActivity(user,
                                         'Just',
                                         'testing',
                                         status=CommandStatus.queued)
         self.system.command_queue.append(self.activity)
     self.browser = self.get_browser()
Exemple #3
0
 def add_completed_command(self, fqdn, action):
     # Reports completion of a command that was executed
     # synchronously by the lab controller
     user = identity.current.user
     system = System.by_fqdn(fqdn, user)
     cmd = CommandActivity(user=user,
                           service=u"XMLRPC",
                           action=action,
                           status=CommandStatus.completed)
     system.command_queue.append(cmd)
     session.flush()  # Populates cmd.system (needed for next call)
     cmd.log_to_system_history()
     return True
Exemple #4
0
 def _make_command(lc=None, creation_date=None):
     job = data_setup.create_job(distro_tree=distro_tree)
     recipe = job.recipesets[0].recipes[0]
     system = data_setup.create_system(lab_controller=lc)
     data_setup.mark_recipe_waiting(recipe, system=system)
     command = CommandActivity(
             user=None, service=u'testdata', action=u'on',
             status=CommandStatus.running,
             callback=u'bkr.server.model.auto_cmd_handler')
     if creation_date is not None:
         command.created = command.updated = creation_date
     system.command_queue.append(command)
     return recipe.tasks[0], command