mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[terremark_ecloud] setup login to also work like get_organizations would
This commit is contained in:
parent
54f4e8f235
commit
a406dc6c3f
4 changed files with 15 additions and 9 deletions
|
@ -11,7 +11,13 @@ module Fog
|
|||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::TerremarkEcloud::Compute::GetVersions.new
|
||||
});
|
||||
})
|
||||
version_info = response.body['SupportedVersions'].detect {|version_info| version_info['Version'] == @version}
|
||||
unless @login_url = version_info && version_info['LoginUrl']
|
||||
# no LoginUrl matches specified version
|
||||
raise "TerremarkEcloud does not support version #{@version}"
|
||||
end
|
||||
response
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -6,6 +6,9 @@ module Fog
|
|||
require 'fog/compute/parsers/terremark_ecloud/login'
|
||||
|
||||
def login
|
||||
unless @login_url
|
||||
get_versions
|
||||
end
|
||||
connection = Fog::Connection.new(@login_url)
|
||||
response = connection.request({
|
||||
:expects => 200,
|
||||
|
|
|
@ -80,14 +80,6 @@ module Fog
|
|||
private
|
||||
|
||||
def get_token_and_organization
|
||||
# lookup LoginUrl for specified version
|
||||
response = self.get_versions
|
||||
version_info = response.body['SupportedVersions'].detect {|version_info| version_info['Version'] == @version}
|
||||
unless @login_url = version_info && version_info['LoginUrl']
|
||||
# no LoginUrl matches specified version
|
||||
raise "TerremarkEcloud does not support version #{@version}"
|
||||
end
|
||||
|
||||
response = self.login
|
||||
# if there is only one organization we will note it as a starting point
|
||||
if (response.body['OrgList'].length == 1) && (organization = response.body['OrgList'].first)
|
||||
|
|
|
@ -13,6 +13,11 @@ Shindo.tests('TerremarkEcloud::Compute | organization requests', ['terremarkeclo
|
|||
|
||||
tests('success') do
|
||||
|
||||
tests("#login (get_organizations)").formats({'OrgList' => [{'href' => String, 'name' => String, 'type' => String}]}) do
|
||||
pending if Fog.mocking?
|
||||
TerremarkEcloud[:compute].login.body
|
||||
end
|
||||
|
||||
tests("#get_organization").formats(@organization_format) do
|
||||
pending if Fog.mocking?
|
||||
TerremarkEcloud[:compute].get_organization.body
|
||||
|
|
Loading…
Reference in a new issue