On May 12, 2011, at 1:33 AM, David Lutterkort wrote:

> On Wed, 2011-05-11 at 11:24 +0200, [email protected] wrote:
>> Hi,
>> 
>> this patch add possibility to create a new instance using POST body XML.
>> 
>> How it works:
>> 
>> instance.xml:
>> <instance>
>>  <name>testinst10</name>
>>  <realm id="us"/>
>>  <hardware_profile id="m1-small">
>>    <memory>512</memory>
>>    <cpu>2</cpu>
>>    <storage>10</storage>
>>    <architecture>i386</architecture>
>>  </hardware_profile>
>> </instance>
> 
> I assume the HWP entries are meant to override defaults from m1-small
> here ?

Yes, but in this example they just demonstrate how overriding of default
values should work.

> As for the patch, parsing an instance from XML should be done in a class
> method in Instance; that should probably happen in server.rb, and the
> code there should ensure the params hash only has an :instance entry for
> XML.

Yes, moving parsing to Instance sounds good. With 'server.rb' you mean something
like this? :
 
....
    control do
      params = Instance.parse_body(request.body.read)
      @instance = driver.create_instance(credentials, params[:image_id], params)
      respond_to do |format|
        format.xml do
....

It will match params to be same as 'query' params and then continue as usual.
Also '.parse_body' should distinguish between JSON and XML (or optionally parse
HTTP header which will tell to Instance what content parser to use 
(JSON/XML/whatever).


  -- Michal

------------------------------------------------------
Michal Fojtik, [email protected]
Deltacloud API: http://deltacloud.org

Reply via email to