Closed jacksonp2008 closed 7 years ago
TBH I tried to work with this GEM some years back, raise a ticket or two but found it to be somewhat limited in functionality. vCloud API is just RESTapi so you can bind using the standard rest-client gem.
thanks to KMorey for this snippet demonstrating this;
def login_vcloud(servername, username, password, ref)
url = "https://#{servername}"+"#{ref}"
headers = {}
headers[:content_type] = :xml
headers[:accept] = 'application/*+xml;version=5.1'
headers[:content_length] = 0
params = {
:method=>:post,
:url=>url,
:user=>username,
:password=>password,
:headers=>headers
}
log(:info, "Logging into vCloud: #{url}")
authorization_response = RestClient::Request.new(params).execute
log(:info, "Successfully logged into vCloud: #{authorization_response.code}")
@cookie = authorization_response.headers[:x_vcloud_authorization]
log(:info, "Detected API session cookie: #{@cookie}")
unless authorization_response.code == 200 || authorization_response.code == 201 || authorization_response.code == 202
raise "Failed to log into vCloud: #{authorization_response.code}"
end
end
Every call I make using this module is ending up with a happy mapper error.
Simple code: require 'vcloud' @session = VCloud::Client.new("https://vlabs.fi.com/api/", '1.5', :verify_ssl => false) @session.login('steven.pollock@se-lab-dirty', 'ubba') org_ref_hash = @session.get_org_references_by_name
Returns: spollock-mbpr:~ steven.pollock$ ruby testvcloud.rb /Library/Ruby/Gems/2.0.0/gems/nokogiri-happymapper-0.5.9/lib/happymapper.rb:468:in'
spollock-mbpr:~ steven.pollock$
initialize': wrong number of arguments (1 for 0) (ArgumentError) from /Library/Ruby/Gems/2.0.0/gems/vcloud-0.0.1.1/lib/vcloud/base_vcloud_entity.rb:29:in
new' from /Library/Ruby/Gems/2.0.0/gems/vcloud-0.0.1.1/lib/vcloud/base_vcloud_entity.rb:29:infrom_reference' from /Library/Ruby/Gems/2.0.0/gems/vcloud-0.0.1.1/lib/vcloud/client.rb:66:in
get_org_references' from /Library/Ruby/Gems/2.0.0/gems/vcloud-0.0.1.1/lib/vcloud/client.rb:59:inget_org_references_by_name' from testvcloud.rb:5:in
Any help appreciated. thanks!!