On Fri, 2012-08-31 at 14:52 +0200, Michal Fojtik wrote:
> On Aug 31, 2012, at 2:48 PM, [email protected] wrote:
>
> Just more clarification why this is needed:
>
> If you try to run Deltacloud in OpenShift, our current
> config.ru will use 'mount' in Passenger. Without Sinatra
> 'url()' helper all links are broken (they does not have /api
> prefix). This patch should fix that as well.
While you're doing this: I just spent a major amount of time tracking
down why in the CIMI FE (before applying your patches), when I get the
details for a machine[1], I get the following:
<operation href="http://localhost:3001/cimi/restart_machines/inst0"
rel="http://www.dmtf.org/cimi/action/restart"/>
<operation href="http://localhost:3001/cimi/machines/inst0/stop"
rel="http://www.dmtf.org/cimi/action/stop"/>
IOW, the restart operation has a bogus href. I finally tracked that down
to Sinatra::UrlForHelper and the special treatment it gives known
actions. Lessons learned:
* method_missing considered dangerous, since it makes it
impossible to find where something is defined; you have the
head-scratching situation that
context.respond_to?(:restart_machine_url) is false, but
context.restart_machine_url(42) actually does something (in
lib/cimi/models/machine.rb(convert_instance_actions)
* doing the special handling of actions UrlForHelper breaks the
separation between Rabbit and the app
This is a longwinded way of saying: could we have Rabbit generate these
helpers when actions/operations are defined rather than try and guess
the right thing in UrlForHelper ? Ideally, with a check since there's an
ambiguity: if the helper would be called a_x_y_url, it could either be
for the a action in collection x_y, or for the a_x action in the y
collection - just failing loudly when we'd try and define the a_x_y_url
helper a second time would be good enough.
David
[1] http://localhost:3001/cimi/machines/inst0 running deltacloudd -i mock -f
cimi