Cheers, that worked! I've pushed your patch as David ACKed it. I've just send a patch to the ML with the changes for mock ([PATCH] mock: fix href urls in mock system and subcollections. Also include start action for newly created system), and I also found good use for it with fgcp ([PATCH] FGCP: use url_for helpers for Rabbit subcollections).
Regards, Dies Koper > -----Original Message----- > From: Michal Fojtik [mailto:mfoj...@redhat.com] > Sent: Friday, 5 April 2013 2:00 AM > To: Koper, Dies > Subject: Re: [PATCH] added Template subcollections to SystemTemplate > > On 04/04/2013 03:38 PM, Koper, Dies wrote: > > Hi Dies, > > > Hi Michal, > > > >> To use this method, you will need to pass 'context' parameter and then > >> call the helper using: > >> > >> context.system_volume_url(system_id, volume_id) > > I tried hard to fix it :-) I found we completely lack support for > generating URL helpers for all sub-collections. I have patch[1] to fix > it. However I was not able to make the syntax the same as in your > example, without making url generation code super long :-) > > So once you have my patch applied you can use this syntax: > > context.system_volume_url(:id => system_id, :ent_id => volume_id) > > Does this work for you? > > [1] http://tracker.deltacloud.org/set/408 > > -- Michal > > > > > This is what I tried: (you can do the same in master) > > > > diff --git > a/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb > b/server/lib/deltacloud/drivers/mock/mock_driver_cimi_metho > > index b0d4f9a..f236935 100644 > > --- > a/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb > > +++ > b/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb > > @@ -80,7 +80,8 @@ module Deltacloud::Drivers::Mock > > end > > #FIXME: with ":machines", delete url becomes > 'http://localhost:3001/cimi/machines?id=sysmach1' > > #with ":system_machine"/":system_machines", undefined method > `system_machine_url' for #<CIMI::Collections::Systems:0x44fe338> in > > - machines.map{|mach|convert_cimi_mock_urls(:machines, mach, > opts[:env])}.flatten > > +# machines.map{|mach|convert_cimi_mock_urls(:machines, mach, > opts[:env])}.flatten > > + machines.map{|mach|convert_urls(mach, opts[:env])}.flatten > > end > > > > def system_volumes(credentials, opts={}) > > @@ -337,10 +338,20 @@ module Deltacloud::Drivers::Mock > > return s > > end > > return s unless u.scheme == 'http' && u.host == > 'cimi.example.org' > > - _, coll, id = u.path.split("/") > > + puts u.path > > + _, coll, id, sub_coll, sub_id = u.path.split("/") > > + puts coll > > + puts id > > + puts sub_coll > > + puts sub_id > > method = "#{coll.singularize}_url" > > + method = "#{coll.singularize}_#{sub_coll.singularize}_url" if > sub_coll > > + puts "method: #{method}" > > if context.respond_to?(method) > > - context.send(method, id) > > + s = context.send(method, id) unless sub_coll > > + s = context.send(method, id, sub_id) if sub_coll > > + puts "s: #{s}" > > + s > > else > > s > > end > > > > So I'm trying to change rewrite_url to also cater for urls with > subcollections. > > > > The debugging output shows that the context does not respond to system > related methods such as system_machine_url. > > > > What now? > > > > Regards, > > Dies Koper > > > > > >> -----Original Message----- > >> From: Michal Fojtik [mailto:mfoj...@redhat.com] > >> Sent: Wednesday, 3 April 2013 7:31 PM > >> To: dev@deltacloud.apache.org > >> Subject: Re: [PATCH] added Template subcollections to SystemTemplate > >> > >> On 04/02/2013 02:26 AM, David Lutterkort wrote: > >> > >>> This seems to be a Rabbit problem with the names of the subcollections; > >>> somehow URL helpers for the subcollections do not get generated > >>> correctly. Michal ? > >> > >> Sry, I overlooked this one :) > >> > >> I checked the patch and seems you are trying to use 'system_volume_url' > >> helper in driver (not in Sinatra context). > >> > >> To use this method, you will need to pass 'context' parameter and then > >> call the helper using: > >> > >> context.system_volume_url(system_id, volume_id) > >> > >> (check David patch for example :-) > >> > >> -- Michal > >> > >>> > >>> BTW, attached is a patch that addresses a few URL conversion problems > >> I > >>> found in the mock driver; feel free to commit if it doesn't make things > >>> worse ;) > >>> > >>> David > >>> > >> > >> > >> -- > >> > >> Michal Fojtik <mfoj...@redhat.com> > >> Deltacloud API, CloudForms > > > > > -- > > Michal Fojtik <mfoj...@redhat.com> > Deltacloud API, CloudForms