Hello Deltacloud community,                                                     
I started on implementing Deltacloud library (discussed few weeks ago on this   
mailing list). Because I have not enough time to continue on this, I'm sending  
an experimental patch with work I did so far. If anyone would appreciate DC as a
lib and has some time, feel free to continue on this or check it for 
inspiration.
                                                                                
This patch wraps DC drivers in a library (Deltacloud::Library) which defines a 
set
of methods for working with providers. The set of methods is taken from Michal's
ruby-deltacloud-client. This lib is called from the existing DC sinatra app -   
by calling 'driver', this lib is actually called now (naming is confusing), also
this lib can be used directly from your app or script, e.g.:                    
                                                                                
#!/usr/bin/ruby                                                                 
                                                                                
require 'deltacloud/api'                                                        
                                                                                
mock = Deltacloud.new('mock', :user => 'mockuser', :password => 'mockpassword') 
inst = mock.create_instance(mock.images.first, {                                
  :name => "libtest-#{Time.now.to_i}"                                           
})                                                                              
                                                                                
mock.instances.each do |i|                                                      
  puts "#{i.id} - #{i.name}"                                                    
end                                                                             
                                                                                
mock.stop_instance(inst.id)                                                     
mock.destroy_instance(inst.id)                                                  
                                                                                
                                                                                
This patch is far from being finished, though basic listing of objects 
(instances,
images, hw profiles...) and instance launching should work both in DC service   
 
and when using lib directly. Some methods (driver helper) were moved around in  
a hacky way to make things work both from lib and from current DC service.      
                                                                                
                                                                                
Jan

Reply via email to