Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: fog/fog
base: master
...
head fork: adelcambre/fog
compare: hack-volume-status
Checking mergeability… Don't worry, you can still create the pull request.
  • 1 commit
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Commits on Jun 15, 2012
@adelcambre adelcambre WARNING: NOT YET CORRECT
hack the describe_volume_status parser to work
38509c3
Showing with 83 additions and 35 deletions.
  1. +83 −35 lib/fog/aws/parsers/compute/describe_volume_status.rb
View
118 lib/fog/aws/parsers/compute/describe_volume_status.rb
@@ -3,64 +3,112 @@ module Parsers
module Compute
module AWS
class DescribeVolumeStatus < Fog::Parsers::Base
+ # <?xml version="1.0" encoding="UTF-8"?>
+ # <DescribeVolumeStatusResponse xmlns="http://ec2.amazonaws.com/doc/2012-03-01/">
+ # <requestId>af8dd421-f9c2-434a-8f20-363d4bf475a8</requestId>
+ # <volumeStatusSet>
+ # <item>
+ # <volumeId>vol-b93655d4</volumeId>
+ # <availabilityZone>us-east-1b</availabilityZone>
+ # <volumeStatus>
+ # <status>impaired</status>
+ # <details>
+ # <item>
+ # <name>io-enabled</name>
+ # <status>failed</status>
+ # </item>
+ # </details>
+ # </volumeStatus>
+ # <eventsSet>
+ # <item>
+ # <description>Awaiting Action: Enable IO</description>
+ # <notBefore>2012-06-15T07:43:54.000Z</notBefore>
+ # <eventId>evol-a4ed0bcd</eventId>
+ # <eventType>potential-data-inconsistency</eventType>
+ # </item>
+ # </eventsSet>
+ # <actionsSet>
+ # <item>
+ # <description>Action requried: Verify data consistency and enable IO.</description>
+ # <code>enable-volume-io</code>
+ # <eventId>evol-a4ed0bcd</eventId>
+ # <eventType>potential-data-inconsistency</eventType>
+ # </item>
+ # </actionsSet>
+ # </item>
+ # </volumeStatusSet>
+ # </DescribeVolumeStatusResponse>
+
def new_volume
- @volume = { 'volumeStatus' => { 'details' => [] }, 'eventSet' => {}, 'actionSet' => {} }
+ @volume = { 'volumeStatus' => { 'details' => [] }, 'eventsSet' => [], 'actionsSet' => [] }
end
def reset
@volume_status = {}
@response = { 'volumeStatusSet' => [] }
@inside = nil
+ @current_item = nil
end
def start_element(name, attrs=[])
super
case name
when 'item'
- new_volume if @inside.nil?
+ if @inside.nil?
+ new_volume
+ else
+ @current_item = {}
+ end
when 'volumeStatus'
@inside = :volume_status
when 'details'
@inside = :details
- when 'eventSet'
- @inside = :event
- when 'actionSet'
- @inside = :action
+ when 'eventsSet'
+ @inside = :eventsSet
+ when 'actionsSet'
+ @inside = :actionsSet
end
end
def end_element(name)
- case name
- #Simple closers
- when 'details'
- @inside = nil
- when 'volumeStatus'
- @inside = nil
- when 'eventSet'
- @inside = nil
- when 'actionSet'
- @inside = nil
- when 'item'
- @response['volumeStatusSet'] << @volume if @inside.nil?
- #Top level
- when 'nextToken', 'requestId'
- @response[name] = value
- # Volume Stuff
- when 'volumeId', 'availabilityZone'
- @volume[name] = value
- #The mess...
- when 'name', 'status'
- case @inside
- when :details
- @volume['volumeStatus']['details'] << {name => value }
- when :volume_status
- @volume['volumeStatus'][name] = value
+ if name != "item" && @current_item
+ if name =~ /(After|Before)$/
+ @current_item[name] = Time.parse(value)
+ else
+ @current_item[name] = value
+ end
+ else
+ case name
+ #Simple closers
+ when 'details'
+ @inside = nil
+ when 'volumeStatus'
+ @inside = nil
+ when 'eventsSet'
+ @inside = nil
+ when 'actionsSet'
+ @inside = nil
+ when 'item'
+ if @inside.nil?
+ @response['volumeStatusSet'] << @volume
+ else
+ @volume[@inside.to_s] = @current_item
+ @current_item = nil
+ end
+ #Top level
+ when 'nextToken', 'requestId'
+ @response[name] = value
+ # Volume Stuff
+ when 'volumeId', 'availabilityZone'
+ @volume[name] = value
+ #The mess...
+ when 'name', 'status'
+ case @inside
+ when :volume_status
+ @volume['volumeStatus'][name] = value
+ end
end
- when 'code', 'eventId', 'eventType', 'description'
- @volume["#{@inside}Set"][name] = value.strip
- when 'notAfter', 'notBefore'
- @volume["#{@inside}Set"][name] = Time.parse(value)
end
end
end

No commit comments for this range

Something went wrong with that request. Please try again.