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

Merge pull request #2677 from evertrue/mock_network_attachments

Mock out the attachment of network interfaces from the instance's perspective
This commit is contained in:
Wesley Beary 2014-02-18 08:25:31 -06:00
commit 243cfc53e4
2 changed files with 24 additions and 2 deletions

View file

@ -205,6 +205,19 @@ module Fog
if self.data[:instances][instance['instanceId']]
instance['networkInterfaces'] = self.data[:network_interfaces].select{|ni,ni_conf|
ni_conf['attachment']['instanceId'] == instance['instanceId']
}.map{|ni,ni_conf|
{
'ownerId' => ni_conf['ownerId'],
'subnetId' => ni_conf['subnetId'],
'vpcId' => ni_conf['vpcId'],
'networkInterfaceId' => ni_conf['networkInterfaceId'],
'groupSet' => ni_conf['groupSet'],
'attachmentId' => ni_conf['attachment']['attachmentId']
}
}
reservation_set[instance['reservationId']] ||= {
'groupSet' => instance['groupSet'],
'groupIds' => instance['groupIds'],

View file

@ -201,6 +201,15 @@ Shindo.tests('Fog::Compute[:aws] | instance requests', ['aws']) do
body
end
# Test network interface attachment
tests('#describe_instances networkInterfaces') do
data = Fog::Compute[:aws].create_network_interface('subnet-12345678').body
@network_interface_id = data['networkInterface']['networkInterfaceId']
Fog::Compute[:aws].attach_network_interface(@network_interface_id, @instance_id, 1)
body = Fog::Compute[:aws].describe_instances('instance-id' => "#{@instance_id}").body
tests("returns 1 attachment").returns(1) { body['reservationSet'].first['instancesSet'].first['networkInterfaces'].size }
end
another_server.destroy
tests("#get_console_output('#{@instance_id}')").formats(@get_console_output_format) do