Merge lp:~mwhudson/lava-scheduler/more-helpful-401s-bug-917390 into lp:lava-scheduler

Proposed by Michael Hudson-Doyle
Status: Merged
Approved by: Zygmunt Krynicki
Approved revision: 120
Merged at revision: 121
Proposed branch: lp:~mwhudson/lava-scheduler/more-helpful-401s-bug-917390
Merge into: lp:lava-scheduler
Diff against target: 20 lines (+7/-2)
1 file modified
lava_scheduler_app/api.py (+7/-2)
To merge this branch: bzr merge lp:~mwhudson/lava-scheduler/more-helpful-401s-bug-917390
Reviewer Review Type Date Requested Status
Zygmunt Krynicki (community) Approve
Review via email: mp+90036@code.launchpad.net

Description of the change

This changes the permission errors produced by submit_job a bit. They now look like this:

$ lava-tool submit-job http://locallava/RPC2/ ~/canonical/repos/lava-dispatcher/lava-ltp-job-justtest
EXPERIMENTAL - SUBJECT TO CHANGE (See --experimental-notice for more info)
ERROR: <Fault 401: 'Authentication with user and token required for this API.'>

$ lava-tool submit-job http://test@locallava/RPC2/ ~/canonical/repos/lava-dispatcher/lava-ltp-job-justtest
EXPERIMENTAL - SUBJECT TO CHANGE (See --experimental-notice for more info)
ERROR: <Fault 403: "Permission denied. User u'test' does not have the 'lava_scheduler_app.add_testjob' permission. Contact administrators to fix this.">

Let me know what you think (I think we could possibly try to display the errors a little better, but that's a client side thing).

To post a comment you must log in.
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lava_scheduler_app/api.py'
2--- lava_scheduler_app/api.py 2011-10-19 21:05:42 +0000
3+++ lava_scheduler_app/api.py 2012-01-25 03:00:33 +0000
4@@ -16,9 +16,14 @@
5
6 def submit_job(self, job_data):
7 if not self.user:
8- raise xmlrpclib.Fault(401, "Authentication required.")
9+ raise xmlrpclib.Fault(
10+ 401, "Authentication with user and token required for this "
11+ "API.")
12 if not self.user.has_perm('lava_scheduler_app.add_testjob'):
13- raise xmlrpclib.Fault(403, "Permission denied.")
14+ raise xmlrpclib.Fault(
15+ 403, "Permission denied. User %r does not have the "
16+ "'lava_scheduler_app.add_testjob' permission. Contact "
17+ "the administrators." % self.user.username)
18 try:
19 job = TestJob.from_json_and_user(job_data, self.user)
20 except JSONDecodeError as e:

Subscribers

People subscribed via source and target branches