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

[ec2] Add blockDeviceMapping information to images

This commit is contained in:
Caleb Tennis 2010-07-26 04:13:35 +08:00 committed by Wesley Beary
parent 9696e21c71
commit 55e1d281e8
4 changed files with 27 additions and 13 deletions

View file

@ -68,6 +68,7 @@ module Fog
end
{
"imageOwnerId" => letters(rand(5) + 4),
"blockDeviceMapping" => [],
"productCodes" => [],
"kernelId" => kernel_id,
"ramdiskId" => ramdisk_id,

View file

@ -9,6 +9,7 @@ module Fog
identity :id, 'imageId'
attribute :architecture
attribute :block_device_mapping, 'blockDeviceMapping'
attribute :location, 'imageLocation'
attribute :owner_id, 'imageOwnerId'
attribute :state, 'imageState'

View file

@ -6,7 +6,7 @@ module Fog
class DescribeImages < Fog::Parsers::Base
def reset
@image = { 'productCodes' => [] }
@image = { 'productCodes' => [], 'blockDeviceMapping' => nil }
@response = { 'imagesSet' => [] }
end
@ -14,6 +14,11 @@ module Fog
super
if name == 'productCodes'
@in_product_codes = true
elsif name == 'blockDeviceMapping'
@in_block_device_mapping = true
@image['blockDeviceMapping'] = []
elsif name == 'item' && @in_block_device_mapping
@image['blockDeviceMapping'] << {}
end
end
@ -28,7 +33,8 @@ module Fog
@image[name] = false
end
when 'item'
unless @in_product_codes
if @in_block_device_mapping
elsif !@in_product_codes
@response['imagesSet'] << @image
@image = { 'productCodes' => [] }
end
@ -36,8 +42,13 @@ module Fog
@image['productCodes'] << @value
when 'productCodes'
@in_product_codes = false
when 'blockDeviceMapping'
@in_block_device_mapping = false
when 'requestId'
@response[name] = @value
when 'deviceName','virtualName','snapshotId','volumeSize','deleteOnTermination'
l = @image['blockDeviceMapping'].length
@image['blockDeviceMapping'][l-1].store(name,@value)
end
end

View file

@ -20,6 +20,7 @@ module Fog
# * 'requestId'<~String> - Id of request
# * 'imagesSet'<~Array>:
# * 'architecture'<~String> - Architecture of the image
# * 'blockDeviceMapping'<~Array> - An array of mapped block devices
# * 'imageId'<~String> - Id of the image
# * 'imageLocation'<~String> - Location of the image
# * 'imageOwnerId'<~String> - Id of the owner of the image