Closed fishstick closed 11 years ago
@fishstick just to be sure, are you using the development version? If not, please do it and let me know if it works. I've made lots of changes since 0.3.0 (after all it's a 0.x.y :wink: ) and supporting different versions can be quite daunting at this stage.
This is what you should get:
orgs = connection.get_organizations
=> {"Test"=>"562f56be-fa9f-48bd-a5fe-a0f9b0acceae"}
I'm using a gem built from the current master branch (0.4.0) using bundler (eg, gem 'vcloud-rest', :git => 'https://github.com/astratto/vcloud-rest.git', :branch => 'master' ) using v5.1 of the API.
version.rb:
module VCloudClient
VERSION = "0.4.0"
end
Ok perfect.
Could you send me your logs?
$ export VCLOUD_REST_DEBUG_LEVEL=debug
$ export VCLOUD_REST_LOG_FILE=/tmp/log
...
Here's a login + get_organisations response, with the actual organisation name replaced with 'testorganisation'
Send request result: <?xml version="1.0" encoding="UTF-8"?>
<Session xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" user="bme" org="testorganisation" type="application/vnd.vmware.vcloud.session+xml" href="https://testvcloud.testorganisation.com/cloud/org/testorganisation/api/session/" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://testvcloud.testorganisation.com/cloud/org/testorganisation/api/v1.5/schema/master.xsd">
<Link rel="down" type="application/vnd.vmware.vcloud.orgList+xml" href="https://testvcloud.testorganisation.com/cloud/org/testorganisation/api/org/"/>
<Link rel="down" type="application/vnd.vmware.vcloud.org+xml" name="testorganisation" href="https://testvcloud.testorganisation.com/cloud/org/testorganisation/api/org/61b1fbaa-e499-4b9c-834b-4c2901a7da7f"/>
<Link rel="down" type="application/vnd.vmware.vcloud.query.queryList+xml" href="https://testvcloud.testorganisation.com/cloud/org/testorganisation/api/query"/>
<Link rel="entityResolver" type="application/vnd.vmware.vcloud.entity+xml" href="https://testvcloud.testorganisation.com/cloud/org/testorganisation/api/entity/"/>
<Link rel="down:extensibility" type="application/vnd.vmware.vcloud.apiextensibility+xml" href="https://testvcloud.testorganisation.com/cloud/org/testorganisation/api/extensibility"/>
</Session>
Send request result: <?xml version="1.0" encoding="UTF-8"?>
<OrgList xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" type="application/vnd.vmware.vcloud.orgList+xml" href="https://testvcloud.testorganisation.com/cloud/org/testorganisation/api/org/" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://testvcloud.testorganisation.com/cloud/org/testorganisation/api/v1.5/schema/master.xsd">
<Org type="application/vnd.vmware.vcloud.org+xml" name="testorganisation" href="https://testvcloud.testorganisation.com/cloud/org/testorganisation/api/org/61b1fbaa-e499-4b9c-834b-4c2901a7da7f"/>
</OrgList>
Interesting, can you post the result of puts connection.api_url
, please?
Haha, I was just looking at that myself, as that seems to be the issue. I think I see the problem, api_url doesn't match properly:
get_organisations:
orgs.each do |org|
results[org['name']] = org['href'].gsub("#{@api_url}/org/", "")
end
@api_url at this point is 'https://testvcloud.testorganisation.com/api" => Gsub doesn't work
1.9.3p448 :029 > url = "https://testvcloud.testorganisation.com/cloud/org/testorganisation/api/org/61b1fbaa-e499-4b9c-834b-4c2901a7da7f"
1.9.3p448 :030 > api_url="https://testvcloud.testorganisation.com/api"
1.9.3p448 :031 > url.gsub("#{api_url}/org/","")
=> "https://testvcloud.testorganisation.com/cloud/org/testorganisation/api/org/61b1fbaa-e499-4b9c-834b-4c2901a7da7f"
The connection was setup with the base host of 'https://testvcloud.testorganisation.com/', as using 'https://testvcloud.testorganisation.com/cloud/org/testorganisation/', would result in a 404 during login.
I've been sanitizing manually with url.gsub(/._\/organisationname\/api\/[^\/]\//,'')
yep, the point is that @api_url/stuff is still the right url to use when invoking commands....
I think that the right way to deal with this is to retrieve the correct base url after login, and then use that to do the replaces. I'll look into this next week, feel free to send a PR :wink:
I'll take a stab at it :). I don't see @host being used anywhere other than the specs, or I can keep track of an actual basE_url which is probably the best - since it's only being used for replacements.
Great! Please use a new variable.
PR merged, thanks again!
Hey,
I'm not sure if this is due to how our admins set up vCloud, or an issue in vcloud itself. In your examples you have something like this:
=> This never works in my setup, as the value of orgs['COE'] is the entire vcloud-url + id, rather than just the id:
As a result, all x_by_name and other combined helper methods fail. Again, I'm not sure if this is due to how our vcloud was setup, or an issue with vcloud-rest.