mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
properly handle blockDeviceMapping, which was throwing of server counts
This commit is contained in:
parent
17d748ddac
commit
62e2a603ac
3 changed files with 60 additions and 23 deletions
|
@ -6,21 +6,27 @@ module Fog
|
|||
|
||||
identity :id, 'instanceId'
|
||||
|
||||
attribute :ami_launch_index, 'amiLaunchIndex'
|
||||
attribute :availability_zone, 'availabilityZone'
|
||||
attribute :dns_name, 'dnsName'
|
||||
attribute :architecture
|
||||
attribute :ami_launch_index, 'amiLaunchIndex'
|
||||
attribute :availability_zone, 'availabilityZone'
|
||||
attribute :block_device_mapping, 'blockDeviceMapping'
|
||||
attribute :dns_name, 'dnsName'
|
||||
attribute :groups
|
||||
attribute :image_id, 'imageId'
|
||||
attribute :state, 'instanceState'
|
||||
attribute :flavor_id, 'instanceType'
|
||||
attribute :kernel_id, 'kernelId'
|
||||
attribute :key_name, 'keyName'
|
||||
attribute :created_at, 'launchTime'
|
||||
attribute :flavor_id, 'instanceType'
|
||||
attribute :image_id, 'imageId'
|
||||
attribute :ip_address, 'ipAddress'
|
||||
attribute :kernel_id, 'kernelId'
|
||||
attribute :key_name, 'keyName'
|
||||
attribute :created_at, 'launchTime'
|
||||
attribute :monitoring
|
||||
attribute :product_codes, 'productCodes'
|
||||
attribute :private_dns_name, 'privateDnsName'
|
||||
attribute :ramdisk_id, 'ramdiskId'
|
||||
attribute :product_codes, 'productCodes'
|
||||
attribute :private_dns_name, 'privateDnsName'
|
||||
attribute :private_ip_address, 'privateIpAddress'
|
||||
attribute :ramdisk_id, 'ramdiskId'
|
||||
attribute :reason
|
||||
attribute :root_device_name, 'rootDeviceName'
|
||||
attribute :root_device_type, 'rootDeviceType'
|
||||
attribute :state, 'instanceState'
|
||||
attribute :user_data
|
||||
|
||||
def initialize(attributes)
|
||||
|
|
|
@ -6,15 +6,19 @@ module Fog
|
|||
class DescribeInstances < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@instance = { 'instanceState' => {}, 'monitoring' => {}, 'placement' => {}, 'productCodes' => [] }
|
||||
@block_device_mapping = {}
|
||||
@instance = { 'blockDeviceMapping' => [], 'instanceState' => {}, 'monitoring' => {}, 'placement' => {}, 'productCodes' => [] }
|
||||
@reservation = { 'groupSet' => [], 'instancesSet' => [] }
|
||||
@response = { 'reservationSet' => [] }
|
||||
end
|
||||
|
||||
def start_element(name, attrs = [])
|
||||
if name == 'groupSet' || name == 'productCodes'
|
||||
case name
|
||||
when 'blockDeviceMapping'
|
||||
@in_block_device_mapping = true
|
||||
when'groupSet', 'productCodes'
|
||||
@in_subset = true
|
||||
elsif name == 'instancesSet'
|
||||
when 'instancesSet'
|
||||
@in_instances_set = true
|
||||
end
|
||||
@value = ''
|
||||
|
@ -26,20 +30,38 @@ module Fog
|
|||
@instance[name] = @value.to_i
|
||||
when 'availabilityZone'
|
||||
@instance['placement'][name] = @value
|
||||
when 'architecture', 'dnsName', 'imageId', 'instanceId',
|
||||
'instanceType', 'ipAddress', 'kernelId', 'keyName',
|
||||
'privateDnsName', 'privateIpAddress', 'ramdiskId', 'reason',
|
||||
'rootDeviceType'
|
||||
@instance[name] = @value
|
||||
when 'attachTime'
|
||||
@block_device_mapping[name] = Time.parse(@value)
|
||||
when 'blockDeviceMapping'
|
||||
@in_block_device_mapping = false
|
||||
when 'code'
|
||||
@instance['instanceState'][name] = @value.to_i
|
||||
when 'dnsName', 'imageId', 'instanceId', 'instanceType', 'kernelId', 'keyName', 'privateDnsName', 'ramdiskId', 'reason'
|
||||
@instance[name] = @value
|
||||
when 'deleteOnTermination'
|
||||
if @value == 'true'
|
||||
@block_device_mapping[name] = true
|
||||
else
|
||||
@block_device_mapping[name] = false
|
||||
end
|
||||
when 'deviceName', 'status', 'volumeId'
|
||||
@block_device_mapping[name] = @value
|
||||
when 'groupId'
|
||||
@reservation['groupSet'] << @value
|
||||
when 'groupSet'
|
||||
when 'groupSet', 'productCodes'
|
||||
@in_subset = false
|
||||
when 'instancesSet'
|
||||
@in_instances_set = false
|
||||
when 'item'
|
||||
if @in_instances_set
|
||||
if @in_block_device_mapping
|
||||
@instance['blockDeviceMapping'] << @block_device_mapping
|
||||
@block_device_mapping = {}
|
||||
elsif @in_instances_set
|
||||
@reservation['instancesSet'] << @instance
|
||||
@instance = { 'instanceState' => {}, 'monitoring' => {}, 'placement' => {}, 'productCodes' => [] }
|
||||
@instance = { 'blockDeviceMapping' => [], 'instanceState' => {}, 'monitoring' => {}, 'placement' => {}, 'productCodes' => [] }
|
||||
elsif !@in_subset
|
||||
@response['reservationSet'] << @reservation
|
||||
@reservation = { 'groupSet' => [], 'instancesSet' => [] }
|
||||
|
@ -54,8 +76,6 @@ module Fog
|
|||
@response[name] = @value
|
||||
when 'productCode'
|
||||
@instance['productCodes'] << @value
|
||||
when 'productCodes'
|
||||
@in_subset = false
|
||||
when 'state'
|
||||
if @value == 'true'
|
||||
@instance['monitoring'][name] = true
|
||||
|
|
|
@ -19,7 +19,14 @@ unless Fog.mocking?
|
|||
# * 'reservationId'<~String> - Id of the reservation
|
||||
# * 'instancesSet'<~Array>:
|
||||
# * instance<~Hash>:
|
||||
# * 'architecture'<~String> - architecture of image in [i386, x86_64]
|
||||
# * 'amiLaunchIndex'<~Integer> - reference to instance in launch group
|
||||
# * 'blockDeviceMapping'<~Array>
|
||||
# * 'attachTime'<~Time> - time of volume attachment
|
||||
# * 'deleteOnTermination'<~Boolean> - whether or not to delete volume on termination
|
||||
# * 'deviceName'<~String> - specifies how volume is exposed to instance
|
||||
# * 'status'<~String> - status of attached volume
|
||||
# * 'volumeId'<~String> - Id of attached volume
|
||||
# * 'dnsName'<~String> - public dns name, blank until instance is running
|
||||
# * 'imageId'<~String> - image id of ami used to launch instance
|
||||
# * 'instanceId'<~String> - id of the instance
|
||||
|
@ -27,7 +34,8 @@ unless Fog.mocking?
|
|||
# * 'code'<~Integer> - current status code
|
||||
# * 'name'<~String> - current status name
|
||||
# * 'instanceType'<~String> - type of instance
|
||||
# * 'kernelId'<~String> - Id of kernel used to launch instance
|
||||
# * 'ipAddress'<~String> - public ip address assigned to instance
|
||||
# * 'kernelId'<~String> - id of kernel used to launch instance
|
||||
# * 'keyName'<~String> - name of key used launch instances or blank
|
||||
# * 'launchTime'<~Time> - time instance was launched
|
||||
# * 'monitoring'<~Hash>:
|
||||
|
@ -36,6 +44,9 @@ unless Fog.mocking?
|
|||
# * 'availabilityZone'<~String> - Availability zone of the instance
|
||||
# * 'productCodes'<~Array> - Product codes for the instance
|
||||
# * 'privateDnsName'<~String> - private dns name, blank until instance is running
|
||||
# * 'privateIpAddress'<~String> - private ip address assigned to instance
|
||||
# * 'rootDeviceName'<~String> - specifies how the root device is exposed to the instance
|
||||
# * 'rootDeviceType'<~String> - root device type used by AMI in [ebs, instance-store]
|
||||
# * 'ramdiskId'<~String> - Id of ramdisk used to launch instance
|
||||
# * 'reason'<~String> - reason for most recent state transition, or blank
|
||||
def describe_instances(instance_id = [])
|
||||
|
|
Loading…
Reference in a new issue