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)

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

Reply via email to