Merge lp://qastaging/~stylesen/lava-scheduler/more-xml-rpc-apis into lp://qastaging/lava-scheduler
Proposed by
Senthil Kumaran S
Status: | Merged |
---|---|
Merged at revision: | 243 |
Proposed branch: | lp://qastaging/~stylesen/lava-scheduler/more-xml-rpc-apis |
Merge into: | lp://qastaging/lava-scheduler |
Diff against target: |
173 lines (+150/-3) 1 file modified
lava_scheduler_app/api.py (+150/-3) |
To merge this branch: | bzr merge lp://qastaging/~stylesen/lava-scheduler/more-xml-rpc-apis |
Related bugs: | |
Related blueprints: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Antonio Terceiro | Approve | ||
Zygmunt Krynicki (community) | Needs Fixing | ||
Linaro Validation Team | Pending | ||
Review via email: mp+158400@code.qastaging.launchpad.net |
Description of the change
Add more xml-rpc APIs to make life easier in lava-scheduler. Following are new APIs added:
1) job_output(self, job_id)
2) all_devices(self)
3) all_device_
4) pending_jobs(self)
To post a comment you must log in.
Hi Senthil,
Cool that you already have something working here! I'm thinking about
shifting some items from my TODO list to you. :-)
> === modified file 'lava_scheduler _app/api. py' app/api. py 2012-05-09 05:57:15 +0000 app/api. py 2013-04-11 15:27:29 +0000 django_ xmlrpc. models import ExposedAPI app.models import ( app.views import ( ExposedAPI) : Fault(403, "Permission denied.") objects. get(pk= job_id) Binary( job.output_ file(). read())
> --- lava_scheduler_
> +++ lava_scheduler_
> @@ -1,15 +1,16 @@
> import xmlrpclib
> -
> from simplejson import JSONDecodeError
> -
> from linaro_
> -
> from lava_scheduler_
> Device,
> DeviceType,
> JSONDataError,
> TestJob,
> )
> +from lava_scheduler_
> + SumIfSQL,
> + SumIf
> +)
>
>
> class SchedulerAPI(
> @@ -51,3 +52,132 @@
> raise xmlrpclib.
> job.cancel()
> return True
> +
> + def job_output(self, job_id):
> + """
> + Name
> + ----
> + `job_output` (`job_id`)
> +
> + Description
> + -----------
> + Get the output of given job id.
> +
> + Arguments
> + ---------
> + `job_id`: string
> + Job id for which the output is required.
> +
> + Return value
> + ------------
> + This function returns an XML-RPC binary data of output file.
> + """
> +
> + job = TestJob.
> + return xmlrpclib.
Shouldn't this endpoint do some permission checking before just piping
the log to the client?
> + def all_devices(self): objects. all() list.append( (device. hostname, device_ type.name, STATUS_ CHOICES[ device. status] [1]))
> + """
> + Name
> + ----
> + `all_devices` ()
> +
> + Description
> + -----------
> + Get all the available devices with their state and type information.
> +
> + Arguments
> + ---------
> + None
> +
> + Return value
> + ------------
> + This function returns an XML-RPC array in which each item is a list of
> + device hostname, device type and device state. For example:
> +
> + [['qemu01', 'qemu', 'Idle'], ['panda01', 'panda', 'Idle']]
> + """
> +
> + device_list = []
> + devices = Device.
> + for device in devices:
> + device_
> + device.
> + Device.
> + return device_list
> +
is it possible to get the status names in a way that looks like
programming identifier names (i.e. all lower case, no spaces etc)?
> + def all_device_ types(self) :
> + """
> + Name
> + ----
> + `all_device_types` ()
> +
> + Description
> + -----------
> + Get all the available device types with their state and count
> + information.
> +
> + Arguments
> + ---------
> + None
> +
> + Return value
> + ------------
> + This function returns an XML-RPC array in which each item is a dict
> + which contains name (device type), idle, busy, offline counts.
> + For example:
> +
> + [{'idle': 1, 'busy': 0, 'name': 'panda', 'offline': 0},
> +...