Commit 8f93f06e authored by Rémi Duraffort's avatar Rémi Duraffort
Browse files

xmlrpc api: allow to show and update worker job limit

Signed-off-by: default avatarRémi Duraffort <>
parent 8625aacf
......@@ -289,14 +289,15 @@ class SchedulerWorkersAPI(ExposedV2API):
d.hostname for d in worker.device_set.all().order_by("hostname")
"last_ping": worker.last_ping,
"job_limit": worker.job_limit,
def update(self, hostname, description=None, health=None):
def update(self, hostname, description=None, health=None, job_limit=None):
`scheduler.workers.update` (`hostname`, `description=None`, `health=None`)
`scheduler.workers.update` (`hostname`, `description=None`, `health=None`, `job_limit=None`)
......@@ -311,6 +312,8 @@ class SchedulerWorkersAPI(ExposedV2API):
Description of the worker
`health`: string
Set worker health ("ACTIVE", "MAINTENANCE" or "RETIRED")
`job_limit`: positive integer
Set job limit for this worker
Return value
......@@ -335,4 +338,9 @@ class SchedulerWorkersAPI(ExposedV2API):
raise xmlrpc.client.Fault(400, "Invalid health: %s" % health)
if job_limit is not None:
if not isinstance(job_limit, int) or job_limit < 0:
raise xmlrpc.client.fault(400, "Invalid job limit")
worker.job_limit = job_limit
......@@ -1772,9 +1772,18 @@ def test_workers_list(setup):
def test_workers_show(setup):
data = server()"")
assert set(data.keys()) == set( # nosec
["hostname", "description", "state", "health", "devices", "last_ping"]
assert data["hostname"] == "" # nosec
assert data["job_limit"] == 0 # nosec
with pytest.raises(xmlrpc.client.Fault) as exc:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment