From b27f7473e7d8db1d3d5531bd52c6ed8d3d6587d1 Mon Sep 17 00:00:00 2001 From: Josh Lane Date: Sat, 28 Dec 2013 11:07:57 -0800 Subject: [PATCH] [aws] mock setup block device deleteOnTermination --- lib/fog/aws/requests/compute/run_instances.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/fog/aws/requests/compute/run_instances.rb b/lib/fog/aws/requests/compute/run_instances.rb index d375d6f94..623efce72 100644 --- a/lib/fog/aws/requests/compute/run_instances.rb +++ b/lib/fog/aws/requests/compute/run_instances.rb @@ -142,14 +142,20 @@ module Fog 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"] + device_name = device.fetch("DeviceName", "/dev/sda1") + volume_size = device.fetch("Ebs.VolumeSize", 15) # @todo should pull this from the image + delete_on_termination = device.fetch("Ebs.DeleteOnTermination", true) # @todo should pull this from the image + + volume_id = create_volume(availability_zone, volume_size).data[:body]["volumeId"] + + self.data[:volumes][volume_id].merge!("DeleteOnTermination" => delete_on_termination) mapping << { - "deviceName" => device["DeviceName"], + "deviceName" => device_name, "volumeId" => volume_id, "status" => "attached", "attachTime" => Time.now, - "deleteOnTermination" => true, + "deleteOnTermination" => delete_on_termination, } end