On Thu, Oct 22, 2009 at 11:34 PM, Ivan Meredith ivan@ivan.net.nz wrote:
Hi all, I work at RimuHosting and am currently working on getting a deltacloud driver coded for our api. I'm pretty interested in this project so if I can find time I would like to contribute more than just our driver. I've done an inital commit that you can find at http://github.com/hadashi/deltacloud-driver-rimuhosting I've had the framework server up and running with what I've done. In the process of writing and testing the driver I noticed some weird things going on, like the framework interface showing the flavors correctly (http://localhost:3000/api/flavors) but then only showing the same plan when going to different actually flavors such as http://localhost:3000/api/flavors/MIRO3B was actually showing the EU2 flavor. After looking at the base driver I saw why.. def flavor(credentials, opts) flavors = flavors(credentials, opts) return flavors.first unless flavors.empty? nil end That will always return the first flavor. I overrode it in my driver to look like def flavor(credentials, opts=nil) flav = flavors(credentials, opts) flav.each { |x| return x if x.id == opts[:id] } nil end and it worked properly. My question really is, Is the flavor method just not implemented fully yet, or am I missing something :). And if its not implemented yet, I guess you would take patches? (I'm not sure if what I did was OK, this is my first attempt at ruby.)
Regards, Ivan Meredith RimuHosting
Ivan, thanks for the effort to get this driver together. As Michael said, the issue is that your flavors method as implemented does not call filter_on. I would amend his snippet to add as the last line of your flavors(): filter_on(res, :id, opts) It need not be assigned to a variable here, as all you want to do is return the collection, which filter_on does for you. Also, you shouldn't even need the flavor method, as that is generic and defined in base_driver. Once you have the filtering right, it should just work. Kind of hard to ack as I do not have a rimu account (is there some sort of free developer signup we could use?), though I otherwise agree with Michael's comments. Also, for it to work (and you may have done this in your local version), framework's environment.rb file needs to be updated with something like:
diff --git a/config/environment.rb b/config/environment.rb index eab79e2..560dc2f 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -51,8 +51,9 @@ Rails::Initializer.run do |config| end
#DEFAULT_DRIVER=:ec2 -DEFAULT_DRIVER=:mock +#DEFAULT_DRIVER=:mock #DEFAULT_DRIVER=:rhevm +DEFAULT_DRIVER=:rimuhosting
unless defined?( DRIVER ) @@ -81,4 +82,6 @@ case DRIVER DRIVER_CLASS_NAME = "Ec2Driver" when :rhevm DRIVER_CLASS_NAME = "RHEVMDriver" + when :rimuhosting + DRIVER_CLASS_NAME = "RimuHostingDriver" end