[openstack-dev] [WSME] Dynamic types and POST requests

Sylvain Bauza sylvain.bauza at gmail.com
Tue Feb 25 22:44:37 UTC 2014


Thanks Doug for replying,



2014-02-25 23:10 GMT+01:00 Doug Hellmann <doug.hellmann at dreamhost.com>:

>
>
>
>> Do you have any idea on how I could get my goal, ie. having a static
>> input plus some extra variable inputs ? I was also thinking about playing
>> with __getattr__ and __setattr__ but I'm not sure the Registry could handle
>> that.
>>
>
> Why don't you know what the data is going to look like before you receive
> it?
>
> One last important point, this API endpoint (Host) is admin-only in case
>> of you mention the potential security issues it could lead.
>>
>
> My issue with this sort of API isn't security, it's that describing how to
> use it for an end user is more difficult than having a clearly defined
> static set of inputs and outputs.
>
>>
>>>>
tl;dr: Admin can provide extra key/value pairs for defining a single Host
thanks to the API, so we should have possibility to have dynamic key/value
pairs for Host.

Ok, sounds like I have to explain the use-case there. Basically, Climate
provides an API where admin has to enroll hosts for provisioning purposes.
The thing is, we only need to get the hostname because we place a call to
Nova for getting the metrics.
Based on these metrics, we do allow users to put requests for leases based
on given metrics (like VCPUs or memory limits) and we elect some hosts.

As the Nova scheduler is not yet available as a service, we do need to
implement our own possibilities for adding metrics that are not provided by
Nova, and thus we allow the possibility to add extra key/value pairs within
the API call for adding a Host.

With API v1 (Flask with no input validation), the possibility was quite
easy, as we were getting the dict and diretly passing it to the Manager.
Now, I have to find some way to still leave the possibility to add extra
metrics.

Example of a Host request body is :
{ 'name': foo,
  'fruits': 'bananas',
  'vgpus': 2}

As 'fruits' and 'vgpus' are dynamic keys, I should be able to accept them
anyway using WSME.

Hope it's clearer now, because at the moment I'm thinking of bypassing WSME
for handling the POST/PUT requests...

-Sylvain
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20140225/99ef08fe/attachment.html>


More information about the OpenStack-dev mailing list