Hey Adam,
to make it work you need two things:
1. xsd schema
2. RSDL
then you will be able to generate SDK which is the key
to shell.
1. xsd schema, basically this is a /standard/ for
restful application to have it, so consuming application
will be able to generate bindings to your api in different
languages, in ovirt-sdk i'm using generateDS to generate python
bindings from our schema,
of course since your api written in python, you can bypass
this, but i still strongly recommend you exposing xsd schema,
and as about format - nothing special. just should compile with lxml
2. RSDL - i'm in a middle of writing spec for it, but in general
you can see RSDL structure in our xsd schema and can easlly figure out
how to use it (let me know if you have questions)
once you have these two, you can generate SDK, see src/codegen/README
in sdk repo, and after you'll have sdk, all is left is to point it from
cli, and as you mentioned cli will dynamically discover it at runtime.
On 04/04/2012 01:03 AM, Adam Litke wrote:
Hi all,
At the oVirt Workshop in Beijing I learned about how the ovirt-shell dynamically
discovers: the collections, resource schemas, and allowed actions based on an
RSDL file and API xsd schema. I am working on a REST API for vdsm and would
like to make my API compatible with the ovirt-engine api such that the same
ovirt-shell program could work with either the engine api or the vdsm api.
There are many differences between ovirt-engine and vdsm (namely that one is
implemented in Java and the other in Python). I think the easiest way to test
whether this is possible is to try and create a new, minimalist REST service with
python Cherrypy. Such a service would have a root URL with no collections or
actions. From my understanding I will need to write the following files:
/api - A basic XML representation of the API root resource
/api?schema - An xsd that describes the simple API
/api?rsdl - An rsdl (XML file) that describes the available links
for /api, I want to start with something dead-simple:
<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
<api>
<messages>
<message id='foo' href='bar'>
Hello from vdsm!
</message>
</messages>
</api>
Once I can use ovirt-shell to list messages and show messages I will be happy to
build on it. Can anyone help me figure out the minimal xsd and rsdl that would
be needed for such an API to be consumable by ovirt-shell? Thanks for your
help!
--
Michael Pasternak
RedHat, ENG-Virtualization R&D