1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[aws] segregate mock data by region

This commit is contained in:
geemus 2010-09-24 13:50:44 -07:00
parent a291086009
commit cdca74ff6a
2 changed files with 53 additions and 47 deletions

View file

@ -67,48 +67,50 @@ module Fog
class Mock
def self.data
@data ||= Hash.new do |hash, key|
@data ||= Hash.new do |hash, region|
owner_id = Fog::AWS::Mock.owner_id
hash[key] = {
:deleted_at => {},
:addresses => {},
:instances => {},
:key_pairs => {},
:limits => { :addresses => 5 },
:owner_id => owner_id,
:security_groups => {
'default' => {
'groupDescription' => 'default group',
'groupName' => 'default',
'ipPermissions' => [
{
'groups' => [{'groupName' => 'default', 'userId' => owner_id}],
'fromPort' => -1,
'toPort' => -1,
'ipProtocol' => 'icmp',
'ipRanges' => []
},
{
'groups' => [{'groupName' => 'default', 'userId' => owner_id}],
'fromPort' => 0,
'toPort' => 65535,
'ipProtocol' => 'tcp',
'ipRanges' => []
},
{
'groups' => [{'groupName' => 'default', 'userId' => owner_id}],
'fromPort' => 0,
'toPort' => 65535,
'ipProtocol' => 'udp',
'ipRanges' => []
}
],
'ownerId' => owner_id
}
},
:snapshots => {},
:volumes => {}
}
hash[region] = Hash.new do |hash, key|
hash[key] = {
:deleted_at => {},
:addresses => {},
:instances => {},
:key_pairs => {},
:limits => { :addresses => 5 },
:owner_id => owner_id,
:security_groups => {
'default' => {
'groupDescription' => 'default group',
'groupName' => 'default',
'ipPermissions' => [
{
'groups' => [{'groupName' => 'default', 'userId' => owner_id}],
'fromPort' => -1,
'toPort' => -1,
'ipProtocol' => 'icmp',
'ipRanges' => []
},
{
'groups' => [{'groupName' => 'default', 'userId' => owner_id}],
'fromPort' => 0,
'toPort' => 65535,
'ipProtocol' => 'tcp',
'ipRanges' => []
},
{
'groups' => [{'groupName' => 'default', 'userId' => owner_id}],
'fromPort' => 0,
'toPort' => 65535,
'ipProtocol' => 'udp',
'ipRanges' => []
}
],
'ownerId' => owner_id
}
},
:snapshots => {},
:volumes => {}
}
end
end
end
@ -120,7 +122,8 @@ module Fog
def initialize(options={})
@aws_access_key_id = options[:aws_access_key_id]
@data = self.class.data[@aws_access_key_id]
@region = options[:region] || 'us-east-1'
@data = self.class.data[@region][@aws_access_key_id]
@owner_id = @data[:owner_id]
end

View file

@ -74,10 +74,12 @@ module Fog
include Utils
def self.data
@data ||= Hash.new do |hash, key|
hash[key] = {
:buckets => {}
}
@data ||= Hash.new do |hash, region|
hash[region] = Hash.new do |hash, key|
hash[key] = {
:buckets => {}
}
end
end
end
@ -89,7 +91,8 @@ module Fog
def initialize(options={})
@aws_access_key_id = options[:aws_access_key_id]
@data = self.class.data[@aws_access_key_id]
@region = options[:region] || 'us-east-1'
@data = self.class.data[@region][@aws_access_key_id]
end
def signature(params)