Class: Fog::Parsers::Compute::AWS::DescribeInstanceStatus

Inherits:
Base
  • Object
show all
Defined in:
lib/fog/aws/parsers/compute/describe_instance_status.rb

Instance Attribute Summary

Attributes inherited from Base

#response

Instance Method Summary collapse

Methods inherited from Base

#attr_value, #characters, #initialize, #value

Constructor Details

This class inherits a constructor from Fog::Parsers::Base

Instance Method Details

#end_element(name) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/fog/aws/parsers/compute/describe_instance_status.rb', line 39

def end_element(name)
  case name
  when 'name'
    if @in_details
      @item[name] = value
    else
      @instance['instanceState'][name] = value
    end
  when 'status'
    if @in_details
      @item[name] = value
    elsif @in_system_status
      @instance['systemStatus'][name] = value
    elsif @in_instance_status
      @instance['instanceStatus'][name] = value
    end
  when 'details'
    @in_details = false
  when 'item'
    if @in_system_status
      @instance['systemStatus']['details'] << @item
    elsif @in_instance_status
      @instance['instanceStatus']['details'] << @item
    else
      @response['instanceStatusSet'] << @instance
      new_instance
    end
    new_item
  when 'instanceStatus'
    @in_instance_status = false
  when 'systemStatus'
    @in_system_status = false
  when 'code'
    if @in_event
      @instance['event'][name] = value.strip
    else
      @instance['instanceState'][name] = value
    end
  when 'description'
    if @in_event
      @instance['event'][name] = value.strip
    end
  when 'notAfter', 'notBefore'
    if @in_event
      @instance['event'][name] = Time.parse(value)
    end
  when 'event'
    @in_event = false
  when 'instanceId', 'availabilityZone'
    @instance[name] = value
  when 'requestId'
    @response[name] = value
  end
end

#new_instanceObject



7
8
9
# File 'lib/fog/aws/parsers/compute/describe_instance_status.rb', line 7

def new_instance
  @instance = { 'instanceState' => {}, 'systemStatus' => { 'details' => [] }, 'instanceStatus' => { 'details' => [] }, 'event' => {} }
end

#new_itemObject



11
12
13
# File 'lib/fog/aws/parsers/compute/describe_instance_status.rb', line 11

def new_item
  @item = {}
end

#resetObject



15
16
17
18
19
20
21
22
23
# File 'lib/fog/aws/parsers/compute/describe_instance_status.rb', line 15

def reset
  @instance_status = {}
  @response = { 'instanceStatusSet' => [] }
  @in_system_status = false
  @in_details = false
  @in_event = false
  new_instance
  new_item
end

#start_element(name, attrs = []) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fog/aws/parsers/compute/describe_instance_status.rb', line 25

def start_element(name, attrs=[])
  super
  case name
  when 'systemStatus'
    @in_system_status = true
  when 'instanceStatus'
    @in_instance_status = true
  when 'details'
    @in_details = true
  when 'event'
    @in_event = true
  end
end