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)
|
||||
response = nil
|
||||
if region.nil?
|
||||
service.list_regions.body['items'].each do |region|
|
||||
service.regions.all.each do |region|
|
||||
begin
|
||||
response = service.get_target_pool(identity, region['name'])
|
||||
response = service.get_target_pool(identity, region.name)
|
||||
break if response.status == 200
|
||||
rescue Fog::Errors::Error
|
||||
end
|
||||
end
|
||||
else
|
||||
region = region['name'] if region['name']
|
||||
response = service.get_target_pool(identity, region)
|
||||
end
|
||||
return nil if response.nil?
|
||||
|
|
|
@ -3,18 +3,18 @@ module Fog
|
|||
class Google
|
||||
class Mock
|
||||
def get_region(identity)
|
||||
region_name = identity.split('/')[-1]
|
||||
region = self.data[:regions][region_name] || {
|
||||
rname = identity.split('/')[-1]
|
||||
region = self.data[:regions][rname] || {
|
||||
"error" => {
|
||||
"errors" => [
|
||||
{
|
||||
"domain" => "global",
|
||||
"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,
|
||||
"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)
|
||||
|
|
|
@ -3,24 +3,18 @@ module Fog
|
|||
class Google
|
||||
class Mock
|
||||
def get_target_pool(name, region_name)
|
||||
region_name = get_region(region_name).body['name']
|
||||
region = data(project)[:regions][region_name]
|
||||
target_pool = data(project)[:target_pools][name]
|
||||
if target_pool.nil? or target_pool['region'] != region['selfLink']
|
||||
return build_excon_response ({
|
||||
"error" => {
|
||||
"errors" => [
|
||||
{
|
||||
"domain" => "global",
|
||||
"reason" => "notFound",
|
||||
"message" => "The resource 'projects/#{project}/regions/#{region_name}/targetPools/#{name}' was not found"
|
||||
}
|
||||
],
|
||||
"code" => 404,
|
||||
region = get_region(region_name)
|
||||
target_pool = self.data[:target_pools][name] || {
|
||||
"error" => {
|
||||
"errors" => [{
|
||||
"domain" => "global",
|
||||
"reason" => "notFound",
|
||||
"message" => "The resource 'projects/#{project}/regions/#{region_name}/targetPools/#{name}' was not found"
|
||||
}
|
||||
})
|
||||
end
|
||||
}],
|
||||
"code" => 404,
|
||||
"message" => "The resource 'projects/#{project}/regions/#{region_name}/targetPools/#{name}' was not found"
|
||||
}
|
||||
}
|
||||
build_excon_response(target_pool)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,5 +4,8 @@ Shindo.tests("Fog::Compute[:google] | target pools model", ['google']) do
|
|||
region = 'us-central1'
|
||||
instance = create_test_server(Fog::Compute[:google], 'us-central1-a')
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue