1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Merge pull request #912 from aia/aws-instances-network

Adding network interface information and security group ids
This commit is contained in:
Wesley Beary 2012-05-18 10:59:13 -07:00
commit 1d866ac238
3 changed files with 22 additions and 7 deletions

View file

@ -14,6 +14,7 @@ module Fog
attribute :ami_launch_index, :aliases => 'amiLaunchIndex'
attribute :availability_zone, :aliases => 'availabilityZone'
attribute :block_device_mapping, :aliases => 'blockDeviceMapping'
attribute :network_interfaces, :aliases => 'networkInterfaces'
attribute :client_token, :aliases => 'clientToken'
attribute :dns_name, :aliases => 'dnsName'
attribute :groups

View file

@ -65,7 +65,7 @@ module Fog
load(
data['reservationSet'].map do |reservation|
reservation['instancesSet'].map do |instance|
instance.merge(:groups => reservation['groupSet'])
instance.merge(:groups => reservation['groupSet'], :security_group_ids => reservation['groupIds'])
end
end.flatten
)

View file

@ -7,10 +7,11 @@ module Fog
def reset
@block_device_mapping = {}
@network_interface = {}
@context = []
@contexts = ['blockDeviceMapping', 'groupSet', 'instancesSet', 'instanceState', 'networkInterfaceSet', 'placement', 'productCodes', 'stateReason', 'tagSet']
@instance = { 'blockDeviceMapping' => [], 'instanceState' => {}, 'monitoring' => {}, 'placement' => {}, 'productCodes' => [], 'stateReason' => {}, 'tagSet' => {} }
@reservation = { 'groupSet' => [], 'instancesSet' => [] }
@instance = { 'blockDeviceMapping' => [], 'networkInterfaces' => [], 'instanceState' => {}, 'monitoring' => {}, 'placement' => {}, 'productCodes' => [], 'stateReason' => {}, 'tagSet' => {} }
@reservation = { 'groupIds' => [], 'groupSet' => [], 'instancesSet' => [] }
@response = { 'reservationSet' => [] }
@tag = {}
end
@ -31,7 +32,7 @@ module Fog
when 'architecture', 'clientToken', 'dnsName', 'imageId',
'instanceId', 'instanceType', 'ipAddress', 'kernelId',
'keyName', 'platform', 'privateDnsName', 'privateIpAddress', 'ramdiskId',
'reason', 'rootDeviceType', 'subnetId', 'vpcId'
'reason', 'rootDeviceType'
@instance[name] = value
when 'attachTime'
@block_device_mapping[name] = Time.parse(value)
@ -43,10 +44,20 @@ module Fog
@block_device_mapping[name] = (value == 'true')
when 'deviceName', 'status', 'volumeId'
@block_device_mapping[name] = value
when 'subnetId', 'vpcId', 'ownerId', 'networkInterfaceId', 'attachmentId'
@network_interface[name] = value
@instance[name] = value
when 'groupId', 'groupName'
case @context.last
when 'groupSet'
@reservation['groupSet'] << value if @context.first != "instancesSet"
(name == 'groupName') ? current_key = 'groupSet' : current_key = 'groupIds'
case @context[-2]
when 'instancesSet'
@reservation[current_key] << value
when 'networkInterfaceSet'
@network_interface[current_key] ||= []
@network_interface[current_key] << value
end
when 'placement'
@instance['placement'][name] = value
end
@ -55,15 +66,18 @@ module Fog
when 'blockDeviceMapping'
@instance['blockDeviceMapping'] << @block_device_mapping
@block_device_mapping = {}
when 'networkInterfaceSet'
@instance['networkInterfaces'] << @network_interface
@network_interface = {}
when 'instancesSet'
@reservation['instancesSet'] << @instance
@instance = { 'blockDeviceMapping' => [], 'instanceState' => {}, 'monitoring' => {}, 'placement' => {}, 'productCodes' => [], 'stateReason' => {}, 'tagSet' => {} }
@instance = { 'blockDeviceMapping' => [], 'networkInterfaces' => [], 'instanceState' => {}, 'monitoring' => {}, 'placement' => {}, 'productCodes' => [], 'stateReason' => {}, 'tagSet' => {} }
when 'tagSet'
@instance['tagSet'][@tag['key']] = @tag['value']
@tag = {}
when nil
@response['reservationSet'] << @reservation
@reservation = { 'groupSet' => [], 'instancesSet' => [] }
@reservation = { 'groupIds' => [], 'groupSet' => [], 'instancesSet' => [] }
end
when 'key', 'value'
@tag[name] = value