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

Merge pull request #375 from eddiej/ej-fix-describe-images

Fix Fog::Compute::AWS::Images#all
This commit is contained in:
Josh Lane 2017-07-18 09:48:21 -07:00 committed by GitHub
commit 5c3f8f43d8
3 changed files with 53 additions and 3 deletions

View file

@ -75,7 +75,7 @@ module Fog
@image[name] = false
end
when 'creationDate'
@image[name] = Time.parse(value)
@image[name] = Time.parse(value) if value && !value.empty?
when 'item'
@response['imagesSet'] << @image
@image = { 'blockDeviceMapping' => [], 'productCodes' => [], 'stateReason' => {}, 'tagSet' => {} }

View file

@ -0,0 +1,33 @@
require 'fog/xml'
require 'fog/aws/parsers/compute/describe_images'
DESCRIBE_IMAGES_RESULT = <<-EOF
<DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">
<requestId>180a8433-ade0-4a6c-b35b-107897579572</requestId>
<imagesSet>
<item>
<imageId>aki-02486376</imageId>
<imageLocation>ec2-public-images-eu/vmlinuz-2.6.21-2.fc8xen-ec2-v1.0.i386.aki.manifest.xml</imageLocation>
<imageState>available</imageState>
<imageOwnerId>206029621532</imageOwnerId>
<creationDate/>
<isPublic>true</isPublic>
<architecture>i386</architecture>
<imageType>kernel</imageType>
<imageOwnerAlias>amazon</imageOwnerAlias>
<rootDeviceType>instance-store</rootDeviceType>
<blockDeviceMapping/>
<virtualizationType>paravirtual</virtualizationType>
<hypervisor>xen</hypervisor>
</item>
</imagesSet>
</DescribeImagesResponse>
EOF
Shindo.tests('Compute::AWS | parsers | describe_images', ['compute', 'aws', 'parser']) do
tests('parses the xml').formats(AWS::Compute::Formats::DESCRIBE_IMAGES) do
parser = Nokogiri::XML::SAX::Parser.new(Fog::Parsers::Compute::AWS::DescribeImages.new)
parser.parse(DESCRIBE_IMAGES_RESULT)
parser.document.response
end
end

View file

@ -2,9 +2,26 @@ class AWS
module Compute
module Formats
BASIC = {
'requestId' => String,
'return' => ::Fog::Boolean
'requestId' => String
}
DESCRIBE_IMAGES = BASIC.merge({
"imagesSet" => [{
"imageId" => String,
"imageLocation" => String,
"imageState" => String,
"imageOwnerId" => String,
"creationDate" => Fog::Nullable::String,
"isPublic" => Fog::Nullable::Boolean,
"architecture" => String,
"imageType" => String,
"imageOwnerAlias" => String,
"rootDeviceType" => String,
"blockDeviceMapping" => Array,
"virtualizationType" => String,
"hypervisor" => String
}]
})
end
end
end