mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
describe availability zones and regions mocks
This commit is contained in:
parent
8a2ba3ca4e
commit
1d780119ca
2 changed files with 115 additions and 43 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
unless Fog.mocking?
|
||||||
|
|
||||||
module Fog
|
module Fog
|
||||||
module AWS
|
module AWS
|
||||||
class EC2
|
class EC2
|
||||||
|
@ -25,3 +27,38 @@ module Fog
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
module Fog
|
||||||
|
module AWS
|
||||||
|
class EC2
|
||||||
|
|
||||||
|
def describe_availability_zones(zone_name = [])
|
||||||
|
response = Fog::Response.new
|
||||||
|
zone_name = [*zone_name]
|
||||||
|
zones = {
|
||||||
|
'us-east-1a' => {"zoneName"=>"us-east-1a", "regionName"=>"us-east-1", "zoneState"=>"available"},
|
||||||
|
'us-east-1b' => {"zoneName"=>"us-east-1b", "regionName"=>"us-east-1", "zoneState"=>"available"},
|
||||||
|
'us-east-1c' => {"zoneName"=>"us-east-1c", "regionName"=>"us-east-1", "zoneState"=>"available"},
|
||||||
|
'us-east-1d' => {"zoneName"=>"us-east-1d", "regionName"=>"us-east-1", "zoneState"=>"available"}
|
||||||
|
}
|
||||||
|
if zone_name != []
|
||||||
|
availability_zone_info = zones.reject {|key, value| !zone_name.include?(key)}.values
|
||||||
|
else
|
||||||
|
availability_zone_info = zones.values
|
||||||
|
end
|
||||||
|
|
||||||
|
response.status = 200
|
||||||
|
response.body = {
|
||||||
|
'requestId' => Fog::AWS::Mock.request_id,
|
||||||
|
'availabilityZoneInfo' => availability_zone_info
|
||||||
|
}
|
||||||
|
response
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
unless Fog.mocking?
|
||||||
|
|
||||||
module Fog
|
module Fog
|
||||||
module AWS
|
module AWS
|
||||||
class EC2
|
class EC2
|
||||||
|
@ -24,3 +26,36 @@ module Fog
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
module Fog
|
||||||
|
module AWS
|
||||||
|
class EC2
|
||||||
|
|
||||||
|
def describe_regions(region_name = [])
|
||||||
|
response = Fog::Response.new
|
||||||
|
region_name = [*region_name]
|
||||||
|
regions = {
|
||||||
|
'eu-west-1' => {"regionName"=>"eu-west-1", "regionEndpoint"=>"eu-west-1.ec2.amazonaws.com"},
|
||||||
|
'us-east-1' => {"regionName"=>"us-east-1", "regionEndpoint"=>"us-east-1.ec2.amazonaws.com"}
|
||||||
|
}
|
||||||
|
if region_name != []
|
||||||
|
region_info = regions.reject {|key, value| !region_name.include?(key)}.values
|
||||||
|
else
|
||||||
|
region_info = regions.values
|
||||||
|
end
|
||||||
|
|
||||||
|
response.status = 200
|
||||||
|
response.body = {
|
||||||
|
'requestId' => Fog::AWS::Mock.request_id,
|
||||||
|
'regionInfo' => region_info
|
||||||
|
}
|
||||||
|
response
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in a new issue