Class: Fog::Parsers::Compute::AWS::SpotInstanceRequests

Inherits:
Base
  • Object
show all
Defined in:
lib/fog/compute/parsers/aws/spot_instance_requests.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



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/fog/compute/parsers/aws/spot_instance_requests.rb', line 23

def end_element(name)
  case name
  when 'attachTime'
    @block_device_mapping[name] = Time.parse(value)
  when *@contexts
    @context.pop
  when 'code', 'message'
    @spot_instance_request['fault'] ||= {}
    @spot_instance_request['fault'][name] = value
  when 'createTime'
    @spot_instance_request[name] = Time.parse(value)
  when 'deleteOnTermination'
    @block_device_mapping[name] = (value == 'true')
  when 'deviceName', 'status', 'volumeId'
    @block_device_mapping[name] = value
  when 'groupId'
    @spot_instance_request['launchSpecification']['groupSet'] << value
  when 'instanceId', 'launchedAvailabilityZone', 'productDescription', 'spotInstanceRequestId', 'state', 'type'
    @spot_instance_request[name] = value
  when 'item'
    case @context.last
    when 'blockDeviceMapping'
      @instance['blockDeviceMapping'] << @block_device_mapping
      @block_device_mapping = {}
    when nil
      @response['spotInstanceRequestSet'] << @spot_instance_request
      @spot_instance_request = { 'launchSpecification' => { 'blockDeviceMapping' => [], 'groupSet' => [] } }
    end
  when 'imageId', 'instanceType', 'keyname'
    @spot_instance_request['launchSpecification'][name] = value
  when 'enabled'
    @spot_instance_request['launchSpecification']['monitoring'] = (value == 'true')
  when 'requestId'
    @response[name] = value
  when 'spotPrice'
    @spot_instance_request[name] = value.to_f
  end
end

#resetObject



8
9
10
11
12
13
14
# File 'lib/fog/compute/parsers/aws/spot_instance_requests.rb', line 8

def reset
  @block_device_mapping = []
  @context = []
  @contexts = ['blockDeviceMapping', 'groupSet']
  @spot_instance_request = { 'launchSpecification' => { 'blockDeviceMapping' => [], 'groupSet' => [] } }
  @response = { 'spotInstanceRequestSet' => [] }
end

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



16
17
18
19
20
21
# File 'lib/fog/compute/parsers/aws/spot_instance_requests.rb', line 16

def start_element(name, attrs = [])
  super
  if @contexts.include?(name)
    @context.push(name)
  end
end