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

[ec2] include default security group in mocks, and maintain same owner id

This commit is contained in:
geemus (Wesley Beary) 2010-03-26 11:16:14 -07:00
parent 9c5460c77b
commit 70962e81c3
5 changed files with 35 additions and 5 deletions

View file

@ -76,7 +76,36 @@ module Fog
:addresses => {}, :addresses => {},
:instances => {}, :instances => {},
:key_pairs => {}, :key_pairs => {},
:security_groups => {}, :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 => {}, :snapshots => {},
:volumes => {} :volumes => {}
} }
@ -91,6 +120,7 @@ module Fog
def initialize(options={}) def initialize(options={})
@aws_access_key_id = options[:aws_access_key_id] @aws_access_key_id = options[:aws_access_key_id]
@owner_id = Fog::AWS::Mock.owner_id
@data = self.class.data[@aws_access_key_id] @data = self.class.data[@aws_access_key_id]
end end

View file

@ -41,10 +41,9 @@ module Fog
group['ipPermissions'] ||= [] group['ipPermissions'] ||= []
if options['GroupName'] && options['SourceSecurityGroupName'] && options['SourceSecurityGroupOwnerId'] if options['GroupName'] && options['SourceSecurityGroupName'] && options['SourceSecurityGroupOwnerId']
owner = Fog::AWS::Mock.owner_id
['icmp', 'tcp', 'udp'].each do |protocol| ['icmp', 'tcp', 'udp'].each do |protocol|
group['ipPermissions'] << { group['ipPermissions'] << {
'groups' => [{'groupName' => options['GroupName'], 'userId' => owner}], 'groups' => [{'groupName' => options['GroupName'], 'userId' => @owner_id}],
'fromPort' => 1, 'fromPort' => 1,
'ipRanges' => [], 'ipRanges' => [],
'ipProtocol' => protocol, 'ipProtocol' => protocol,

View file

@ -36,7 +36,7 @@ module Fog
'groupDescription' => description, 'groupDescription' => description,
'groupName' => name, 'groupName' => name,
'ipPermissions' => [], 'ipPermissions' => [],
'ownerId' => Fog::AWS::Mock.owner_id 'ownerId' => @owner_id
} }
@data[:security_groups][name] = data @data[:security_groups][name] = data
response.body = { response.body = {

View file

@ -102,7 +102,7 @@ module Fog
group_set = [ (options['GroupId'] || 'default') ] group_set = [ (options['GroupId'] || 'default') ]
instances_set = [] instances_set = []
owner_id = Fog::AWS::Mock.owner_id owner_id = @owner_id
reservation_id = Fog::AWS::Mock.reservation_id reservation_id = Fog::AWS::Mock.reservation_id
min_count.times do |i| min_count.times do |i|

View file

@ -18,6 +18,7 @@ describe 'Slicehost.create_slice' do
actual['bw-out'].should be_an(Float) actual['bw-out'].should be_an(Float)
actual['flavor-id'].should be_an(Integer) actual['flavor-id'].should be_an(Integer)
actual['id'].should be_an(Integer) actual['id'].should be_an(Integer)
@slice_id = actual['id']
actual['image-id'].should be_an(Integer) actual['image-id'].should be_an(Integer)
actual['name'].should be_an(String) actual['name'].should be_an(String)
actual['progress'].should be_an(Integer) actual['progress'].should be_an(Integer)