Class: Aws::Ec2::QEc2DescribeInstancesParser

Inherits:
AwsParser
  • Object
show all
Defined in:
lib/deltacloud/drivers/ec2/aws_vpc_monkey_patch.rb

Overview

The only change in this class compared to upstream is that we parse out subnetId and vpcId

Instance Method Summary collapse

Instance Method Details

#resetObject



221
222
223
# File 'lib/deltacloud/drivers/ec2/aws_vpc_monkey_patch.rb', line 221

def reset
  @result = []
end

#tagend(name) ⇒ Object



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/deltacloud/drivers/ec2/aws_vpc_monkey_patch.rb', line 138

def tagend(name)
  case name
    when  'rootDeviceType' then
      @instance[:root_device_type] = @text
    when 'architecture' then
      @instance[:architecture] = @text
    when 'rootDeviceName' then
      @instance[:root_device_name] = @text
    # reservation
    when 'reservationId' then
      @reservation[:aws_reservation_id] = @text
    when 'ownerId' then
      @reservation[:aws_owner] = @text
    when 'groupId' then
      @reservation[:aws_groups] << @text
    # instance
    when 'instanceId' then
      @instance[:aws_instance_id] = @text
    when 'imageId' then
      @instance[:aws_image_id] = @text
    when 'dnsName' then
      @instance[:dns_name] = @text
    when 'privateDnsName' then
      @instance[:private_dns_name] = @text
    when 'reason' then
      @instance[:aws_reason] = @text
    when 'keyName' then
      @instance[:ssh_key_name] = @text
    when 'amiLaunchIndex' then
      @instance[:ami_launch_index] = @text
    when 'code' then
      @instance[:aws_state_code] = @text
    when 'name' then
      @instance[:aws_state] = @text
    when 'productCode' then
      @instance[:aws_product_codes] << @text
    when 'instanceType' then
      @instance[:aws_instance_type] = @text
    when 'launchTime' then
      @instance[:aws_launch_time] = @text
    when 'kernelId' then
      @instance[:aws_kernel_id] = @text
    when 'ramdiskId' then
      @instance[:aws_ramdisk_id] = @text
    when 'platform' then
      @instance[:aws_platform] = @text
    when 'availabilityZone' then
      @instance[:aws_availability_zone] = @text
    when 'privateIpAddress' then
      @instance[:aws_private_ip_address] = @text
    when 'subnetId' then
      @instance[:subnet_id] = @text
    when 'vpcId' then
      @instance[:vpc_id] = @text
    when 'key' then
      @tag_key = @text
    when 'value' then
      @tag_value = @text
    when 'deviceName' then
      @device_name = @text
    when 'volumeId' then
      @volume_id = @text
    when 'state'
      if @xmlpath == 'DescribeInstancesResponse/reservationSet/item/instancesSet/item/monitoring' || # DescribeInstances property
      @xmlpath == 'RunInstancesResponse/instancesSet/item/monitoring' # RunInstances property
        @instance[:monitoring_state] = @text
      end
    when 'item'
      if @xmlpath=='DescribeInstancesResponse/reservationSet/item/instancesSet/item/tagSet' # Tags
        @instance[:tags][@tag_key] = @tag_value
      elsif @xmlpath == 'DescribeInstancesResponse/reservationSet/item/instancesSet/item/blockDeviceMapping' # Block device mappings
        @instance[:block_device_mappings] << { @device_name => @volume_id }
      elsif @xmlpath == 'DescribeInstancesResponse/reservationSet/item/instancesSet' || # DescribeInstances property
      @xmlpath == 'RunInstancesResponse/instancesSet' # RunInstances property
        @reservation[:instances_set] << @instance
      elsif @xmlpath=='DescribeInstancesResponse/reservationSet' # DescribeInstances property
        @result << @reservation
      end
    when 'RunInstancesResponse' then
      @result << @reservation # RunInstances property
  end
end

#tagstart(name, attributes) ⇒ Object

:nodoc:



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/deltacloud/drivers/ec2/aws_vpc_monkey_patch.rb', line 107

def tagstart(name, attributes)
  # DescribeInstances property
  if (name == 'item' && @xmlpath == 'DescribeInstancesResponse/reservationSet') ||
      # RunInstances property
  (name == 'RunInstancesResponse')
    @reservation = {:aws_groups    => [],
                    :instances_set => []}

  elsif (name == 'item') &&
      # DescribeInstances property
  (@xmlpath=='DescribeInstancesResponse/reservationSet/item/instancesSet' ||
      # RunInstances property
  @xmlpath=='RunInstancesResponse/instancesSet')
    # the optional params (sometimes are missing and we dont want them to be nil)
    @instance = {:aws_reason        => '',
                 :dns_name          => '',
                 :private_dns_name  => '',
                 :ami_launch_index  => '',
                 :ssh_key_name      => '',
                 :aws_state         => '',
                 :root_device_type  => '',
                 :root_device_name  => '',
                 :architecture      => '',
                 :subnet_id         => '',
                 :vpc_id            => '',
                 :block_device_mappings => [],
                 :aws_product_codes => [],
                 :tags              => {}}
  end
end