mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[google|compute] Change target pool code to be correct and consistent with fog.
This commit is contained in:
parent
a130429a75
commit
a2d41af9d7
4 changed files with 21 additions and 25 deletions
|
@ -22,15 +22,14 @@ module Fog
|
||||||
def get(identity, region=nil)
|
def get(identity, region=nil)
|
||||||
response = nil
|
response = nil
|
||||||
if region.nil?
|
if region.nil?
|
||||||
service.list_regions.body['items'].each do |region|
|
service.regions.all.each do |region|
|
||||||
begin
|
begin
|
||||||
response = service.get_target_pool(identity, region['name'])
|
response = service.get_target_pool(identity, region.name)
|
||||||
break if response.status == 200
|
break if response.status == 200
|
||||||
rescue Fog::Errors::Error
|
rescue Fog::Errors::Error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
region = region['name'] if region['name']
|
|
||||||
response = service.get_target_pool(identity, region)
|
response = service.get_target_pool(identity, region)
|
||||||
end
|
end
|
||||||
return nil if response.nil?
|
return nil if response.nil?
|
||||||
|
|
|
@ -3,18 +3,18 @@ module Fog
|
||||||
class Google
|
class Google
|
||||||
class Mock
|
class Mock
|
||||||
def get_region(identity)
|
def get_region(identity)
|
||||||
region_name = identity.split('/')[-1]
|
rname = identity.split('/')[-1]
|
||||||
region = self.data[:regions][region_name] || {
|
region = self.data[:regions][rname] || {
|
||||||
"error" => {
|
"error" => {
|
||||||
"errors" => [
|
"errors" => [
|
||||||
{
|
{
|
||||||
"domain" => "global",
|
"domain" => "global",
|
||||||
"reason" => "notFound",
|
"reason" => "notFound",
|
||||||
"message" => "The resource 'projects/#{project}/regions/#{region_name}' was not found"
|
"message" => "The resource 'projects/#{project}/regions/#{rname}' was not found"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"code" => 404,
|
"code" => 404,
|
||||||
"message" => "The resource 'projects/#{project}/regions/#{region_name}' was not found"
|
"message" => "The resource 'projects/#{project}/regions/#{rname}' was not found"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
build_excon_response(region)
|
build_excon_response(region)
|
||||||
|
|
|
@ -3,24 +3,18 @@ module Fog
|
||||||
class Google
|
class Google
|
||||||
class Mock
|
class Mock
|
||||||
def get_target_pool(name, region_name)
|
def get_target_pool(name, region_name)
|
||||||
region_name = get_region(region_name).body['name']
|
region = get_region(region_name)
|
||||||
region = data(project)[:regions][region_name]
|
target_pool = self.data[:target_pools][name] || {
|
||||||
target_pool = data(project)[:target_pools][name]
|
"error" => {
|
||||||
if target_pool.nil? or target_pool['region'] != region['selfLink']
|
"errors" => [{
|
||||||
return build_excon_response ({
|
"domain" => "global",
|
||||||
"error" => {
|
"reason" => "notFound",
|
||||||
"errors" => [
|
|
||||||
{
|
|
||||||
"domain" => "global",
|
|
||||||
"reason" => "notFound",
|
|
||||||
"message" => "The resource 'projects/#{project}/regions/#{region_name}/targetPools/#{name}' was not found"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"code" => 404,
|
|
||||||
"message" => "The resource 'projects/#{project}/regions/#{region_name}/targetPools/#{name}' was not found"
|
"message" => "The resource 'projects/#{project}/regions/#{region_name}/targetPools/#{name}' was not found"
|
||||||
}
|
}],
|
||||||
})
|
"code" => 404,
|
||||||
end
|
"message" => "The resource 'projects/#{project}/regions/#{region_name}/targetPools/#{name}' was not found"
|
||||||
|
}
|
||||||
|
}
|
||||||
build_excon_response(target_pool)
|
build_excon_response(target_pool)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,5 +4,8 @@ Shindo.tests("Fog::Compute[:google] | target pools model", ['google']) do
|
||||||
region = 'us-central1'
|
region = 'us-central1'
|
||||||
instance = create_test_server(Fog::Compute[:google], 'us-central1-a')
|
instance = create_test_server(Fog::Compute[:google], 'us-central1-a')
|
||||||
health_check = create_test_http_health_check(Fog::Compute[:google])
|
health_check = create_test_http_health_check(Fog::Compute[:google])
|
||||||
collection_tests(Fog::Compute[:google].target_pools, {:name => "fog-test-target-pool-#{random_string}", :region => region, :instances => [instance.self_link], :healthChecks => [health_check.self_link]})
|
collection_tests(
|
||||||
|
Fog::Compute[:google].target_pools,
|
||||||
|
{:name => "fog-test-target-pool-#{random_string}", :region => region, :instances => [instance.self_link], :healthChecks => [health_check.self_link]}
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue