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

[aws] mock block device mapping on run_instances

This commit is contained in:
Josh Lane 2013-12-27 12:26:29 -08:00
parent 7940b301ce
commit aa1d8d0bd8
2 changed files with 17 additions and 3 deletions

View file

@ -75,7 +75,7 @@ module Fog
when 'ebsOptimized'
@instance['ebsOptimized'] = (value == 'true')
when 'associatePublicIP'
@instance['associatePublicIP'] = (value == 'true')
@instance['associatePublicIP'] = (value == 'true')
end
end

View file

@ -139,11 +139,25 @@ module Fog
min_count.times do |i|
instance_id = Fog::AWS::Mock.instance_id
availability_zone = options['Placement.AvailabilityZone'] || Fog::AWS::Mock.availability_zone(@region)
block_device_mapping = (options['BlockDeviceMapping'] || []).inject([]) do |mapping, device|
volume_id = create_volume(availability_zone, device["Ebs.VolumeSize"]).data[:body]["volumeId"]
mapping << {
"deviceName" => device["DeviceName"],
"volumeId" => volume_id,
"status" => "attached",
"attachTime" => Time.now,
"deleteOnTermination" => true,
}
end
instance = {
'amiLaunchIndex' => i,
'associatePublicIP' => options['associatePublicIP'] || false,
'architecture' => 'i386',
'blockDeviceMapping' => [],
'blockDeviceMapping' => block_device_mapping,
'clientToken' => options['clientToken'],
'dnsName' => nil,
'ebsOptimized' => options['EbsOptimized'] || false,
@ -156,7 +170,7 @@ module Fog
'keyName' => options['KeyName'],
'launchTime' => Time.now,
'monitoring' => { 'state' => options['Monitoring.Enabled'] || false },
'placement' => { 'availabilityZone' => options['Placement.AvailabilityZone'] || Fog::AWS::Mock.availability_zone(@region), 'groupName' => nil, 'tenancy' => options['Placement.Tenancy'] || 'default' },
'placement' => { 'availabilityZone' => availability_zone, 'groupName' => nil, 'tenancy' => options['Placement.Tenancy'] || 'default' },
'privateDnsName' => nil,
'productCodes' => [],
'reason' => nil,