summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Callaghan <dcallagh@redhat.com>2017-10-19 17:32:29 +1000
committerDan Callaghan <dcallagh@redhat.com>2017-10-19 17:32:29 +1000
commit5807bc1a3cb21e7daefae5f180eb56bbe66cb3f6 (patch)
treed381d754179876263af29bb834fbe91060a514ea
parent555d54163872b310cef830f94dc54e75f83dc10e (diff)
lab controllers need to be permitted to power any system
-rw-r--r--IntegrationTests/src/bkr/inttest/labcontroller/test_proxy.py20
-rw-r--r--Server/bkr/server/model/inventory.py4
2 files changed, 24 insertions, 0 deletions
diff --git a/IntegrationTests/src/bkr/inttest/labcontroller/test_proxy.py b/IntegrationTests/src/bkr/inttest/labcontroller/test_proxy.py
index 3bf758e..644cc91 100644
--- a/IntegrationTests/src/bkr/inttest/labcontroller/test_proxy.py
+++ b/IntegrationTests/src/bkr/inttest/labcontroller/test_proxy.py
@@ -682,6 +682,26 @@ class PostrebootTest(LabControllerTestCase):
self.assertEqual(self.system.command_queue[0].action, 'on')
self.assertEqual(self.system.command_queue[1].action, 'off')
+class PowerTest(LabControllerTestCase):
+
+ def setUp(self):
+ with session.begin():
+ system = data_setup.create_system(lab_controller=self.get_lc())
+ self.target_system = data_setup.create_system(lab_controller=self.get_lc())
+ recipe = data_setup.create_recipe()
+ target_recipe = data_setup.create_recipe()
+ job = data_setup.create_job_for_recipes([recipe, target_recipe])
+ self.addCleanup(self.cleanup_job, job)
+ data_setup.mark_recipe_running(recipe, system=system)
+ data_setup.mark_recipe_running(target_recipe, system=self.target_system)
+
+ # https://bugzilla.redhat.com/show_bug.cgi?id=1501671
+ def test_power(self):
+ s = xmlrpclib.ServerProxy(self.get_proxy_url())
+ s.power(self.target_system.fqdn, 'off')
+ with session.begin():
+ session.expire_all()
+ self.assertEqual(self.target_system.command_queue[0].action, 'off')
class LogUploadTestRestartProxy(LabControllerTestCase):
diff --git a/Server/bkr/server/model/inventory.py b/Server/bkr/server/model/inventory.py
index 1303569..531bbbc 100644
--- a/Server/bkr/server/model/inventory.py
+++ b/Server/bkr/server/model/inventory.py
@@ -1044,6 +1044,10 @@ class System(DeclarativeMappedObject, ActivityMixin):
self._ensure_user_is_authenticated(user)
if self.can_configure_netboot(user):
return True
+ # Lab controllers can power any system, to implement the
+ # power() XMLRPC method for rhts-power
+ if user.in_group(['lab_controller']):
+ return True
# Anyone else needs the "control_system" permission
if (self.active_access_policy and
self.active_access_policy.grants(user, SystemPermission.control_system)):