Hi all,

I'm getting through some of the basic plumbing for the CloudStack
driver, and have been battling something that's probably dead simple for
those of you in the know.  It's also possible that my lack of ruby experience 
is a contributing factor in this... ;-) 

Within my unit tests, I need to be able to set the API URL to talk to (I
know this isn't the right way to do a pure unit test, but I need to
bootstrap my work).

Here's the test code:

require 'rubygems'                                                              
                         
require 'require_relative' if RUBY_VERSION < '1.9'                              
                         
                                                                                
                         
require_relative 'common'                                                       
                         
                                                                                
                         
describe 'CloudStack Instances' do                                              
                         
                                                                                
                         
  def credentials                                                               
                         
  {                                                                             
                         
    :user => 
'yy0sfCPpyKnvREhgpeIWzXORIIvyteq_iCgFpKXnqpdbnHuoYiK78nprSggG4hcx-hxwW897nU-XvGB0Tq8YFw',
   
    :password => 
'Pse4fqYNnr1xvoRXlAe8NQKCSXeK_VGdwUxUzyLEPVQ7B3cI1Q7B8jmZ42FQpz2jIICFax1foIzg2716lJFZVw'
,                                                                               
                         
    :provider => 'http://192.168.56.10:8080/client/api/'                        
                         
  }                                                                             
                         
  end                                                                           
                         
                                                                                
                         
  before do                                                                     
                         
    @driver = Deltacloud::new(:cloudstack, credentials)                         
                         
  end                                                                           
                         
                                                                                
                         
  it 'must return list of instances' do                                         
                         
    @driver.instances.wont_be_empty                                             
                         
    @driver.instances.first.must_be_kind_of Instance                            
                         
  end                                                                           
                         
                                                                                
                         
end                  

And here's the relevant method of the driver where I'm attempting to access 
credentials.provider:

                                                                                
                                              
def new_client(credentials)                                                     
                                              
  safely do                                                                     
                                              
    if credentials.user.empty?                                                  
                                              
      raise AuthenticationFailure.new(Exception.new("Error: you must supply 
your CloudStack API key as your username"))       
    end                                                                         
                                              
    if credentials.password.empty?                                              
                                              
      raise AuthenticationFailure.new(Exception.new("Error: you must supply 
your CloudStack Secret key as your password"))    
    end                                                                         
                                              
    puts credentials.to_s                                                       
                                              
    return CloudstackRubyClient::Client.new(credentials.provider, 
credentials.user, credentials.password, false)              
  end                                                                           
                                              
end 

When I run the tests, I get the following exception:

CloudStack Instances
#<OpenStruct 
user="yy0sfCPpyKnvREhgpeIWzXORIIvyteq_iCgFpKXnqpdbnHuoYiK78nprSggG4hcx-hxwW897nU-XvGB0Tq8YFw
", 
password="Pse4fqYNnr1xvoRXlAe8NQKCSXeK_VGdwUxUzyLEPVQ7B3cI1Q7B8jmZ42FQpz2jIICFax1foIzg2716lJFZVw">
    ERROR (0:00:00.238) test_0001_must return list of instances
          undefined method `request_uri' for #<URI::Generic:0x007ffbca4316b0>
        @ 
/Users/chip.childers/.rvm/gems/ruby-1.9.2-p320/gems/cloudstack_ruby_client-0.0.2/lib/cloudstack
_ruby_client/base_client.rb:37:in `request'
          
/Users/chip.childers/.rvm/gems/ruby-1.9.2-p320/gems/cloudstack_ruby_client-0.0.2/lib/cloudstack
_ruby_client/client.rb:1242:in `listVirtualMachines'
          lib/deltacloud/drivers/cloudstack/cloudstack_driver.rb:140:in 
`instances'
          lib/deltacloud/api.rb:118:in `method_missing'
          tests/drivers/cloudstack/instances_test.rb:21:in `block (2 levels) in 
<top (required)>'


Note the output of the puts debug statement before the ERROR report.  
credentials.provider seems to be lost.

Any advice?

Thanks in advance for any help you can provide.

-chip                                                                           
                                                                                
                                                   

Reply via email to