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:
commit
1d866ac238
3 changed files with 22 additions and 7 deletions
|
@ -14,6 +14,7 @@ module Fog
|
||||||
attribute :ami_launch_index, :aliases => 'amiLaunchIndex'
|
attribute :ami_launch_index, :aliases => 'amiLaunchIndex'
|
||||||
attribute :availability_zone, :aliases => 'availabilityZone'
|
attribute :availability_zone, :aliases => 'availabilityZone'
|
||||||
attribute :block_device_mapping, :aliases => 'blockDeviceMapping'
|
attribute :block_device_mapping, :aliases => 'blockDeviceMapping'
|
||||||
|
attribute :network_interfaces, :aliases => 'networkInterfaces'
|
||||||
attribute :client_token, :aliases => 'clientToken'
|
attribute :client_token, :aliases => 'clientToken'
|
||||||
attribute :dns_name, :aliases => 'dnsName'
|
attribute :dns_name, :aliases => 'dnsName'
|
||||||
attribute :groups
|
attribute :groups
|
||||||
|
|
|
@ -65,7 +65,7 @@ module Fog
|
||||||
load(
|
load(
|
||||||
data['reservationSet'].map do |reservation|
|
data['reservationSet'].map do |reservation|
|
||||||
reservation['instancesSet'].map do |instance|
|
reservation['instancesSet'].map do |instance|
|
||||||
instance.merge(:groups => reservation['groupSet'])
|
instance.merge(:groups => reservation['groupSet'], :security_group_ids => reservation['groupIds'])
|
||||||
end
|
end
|
||||||
end.flatten
|
end.flatten
|
||||||
)
|
)
|
||||||
|
|
|
@ -7,10 +7,11 @@ module Fog
|
||||||
|
|
||||||
def reset
|
def reset
|
||||||
@block_device_mapping = {}
|
@block_device_mapping = {}
|
||||||
|
@network_interface = {}
|
||||||
@context = []
|
@context = []
|
||||||
@contexts = ['blockDeviceMapping', 'groupSet', 'instancesSet', 'instanceState', 'networkInterfaceSet', 'placement', 'productCodes', 'stateReason', 'tagSet']
|
@contexts = ['blockDeviceMapping', 'groupSet', 'instancesSet', 'instanceState', 'networkInterfaceSet', 'placement', 'productCodes', 'stateReason', 'tagSet']
|
||||||
@instance = { 'blockDeviceMapping' => [], 'instanceState' => {}, 'monitoring' => {}, 'placement' => {}, 'productCodes' => [], 'stateReason' => {}, 'tagSet' => {} }
|
@instance = { 'blockDeviceMapping' => [], 'networkInterfaces' => [], 'instanceState' => {}, 'monitoring' => {}, 'placement' => {}, 'productCodes' => [], 'stateReason' => {}, 'tagSet' => {} }
|
||||||
@reservation = { 'groupSet' => [], 'instancesSet' => [] }
|
@reservation = { 'groupIds' => [], 'groupSet' => [], 'instancesSet' => [] }
|
||||||
@response = { 'reservationSet' => [] }
|
@response = { 'reservationSet' => [] }
|
||||||
@tag = {}
|
@tag = {}
|
||||||
end
|
end
|
||||||
|
@ -31,7 +32,7 @@ module Fog
|
||||||
when 'architecture', 'clientToken', 'dnsName', 'imageId',
|
when 'architecture', 'clientToken', 'dnsName', 'imageId',
|
||||||
'instanceId', 'instanceType', 'ipAddress', 'kernelId',
|
'instanceId', 'instanceType', 'ipAddress', 'kernelId',
|
||||||
'keyName', 'platform', 'privateDnsName', 'privateIpAddress', 'ramdiskId',
|
'keyName', 'platform', 'privateDnsName', 'privateIpAddress', 'ramdiskId',
|
||||||
'reason', 'rootDeviceType', 'subnetId', 'vpcId'
|
'reason', 'rootDeviceType'
|
||||||
@instance[name] = value
|
@instance[name] = value
|
||||||
when 'attachTime'
|
when 'attachTime'
|
||||||
@block_device_mapping[name] = Time.parse(value)
|
@block_device_mapping[name] = Time.parse(value)
|
||||||
|
@ -43,10 +44,20 @@ module Fog
|
||||||
@block_device_mapping[name] = (value == 'true')
|
@block_device_mapping[name] = (value == 'true')
|
||||||
when 'deviceName', 'status', 'volumeId'
|
when 'deviceName', 'status', 'volumeId'
|
||||||
@block_device_mapping[name] = value
|
@block_device_mapping[name] = value
|
||||||
|
when 'subnetId', 'vpcId', 'ownerId', 'networkInterfaceId', 'attachmentId'
|
||||||
|
@network_interface[name] = value
|
||||||
|
@instance[name] = value
|
||||||
when 'groupId', 'groupName'
|
when 'groupId', 'groupName'
|
||||||
case @context.last
|
case @context.last
|
||||||
when 'groupSet'
|
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'
|
when 'placement'
|
||||||
@instance['placement'][name] = value
|
@instance['placement'][name] = value
|
||||||
end
|
end
|
||||||
|
@ -55,15 +66,18 @@ module Fog
|
||||||
when 'blockDeviceMapping'
|
when 'blockDeviceMapping'
|
||||||
@instance['blockDeviceMapping'] << @block_device_mapping
|
@instance['blockDeviceMapping'] << @block_device_mapping
|
||||||
@block_device_mapping = {}
|
@block_device_mapping = {}
|
||||||
|
when 'networkInterfaceSet'
|
||||||
|
@instance['networkInterfaces'] << @network_interface
|
||||||
|
@network_interface = {}
|
||||||
when 'instancesSet'
|
when 'instancesSet'
|
||||||
@reservation['instancesSet'] << @instance
|
@reservation['instancesSet'] << @instance
|
||||||
@instance = { 'blockDeviceMapping' => [], 'instanceState' => {}, 'monitoring' => {}, 'placement' => {}, 'productCodes' => [], 'stateReason' => {}, 'tagSet' => {} }
|
@instance = { 'blockDeviceMapping' => [], 'networkInterfaces' => [], 'instanceState' => {}, 'monitoring' => {}, 'placement' => {}, 'productCodes' => [], 'stateReason' => {}, 'tagSet' => {} }
|
||||||
when 'tagSet'
|
when 'tagSet'
|
||||||
@instance['tagSet'][@tag['key']] = @tag['value']
|
@instance['tagSet'][@tag['key']] = @tag['value']
|
||||||
@tag = {}
|
@tag = {}
|
||||||
when nil
|
when nil
|
||||||
@response['reservationSet'] << @reservation
|
@response['reservationSet'] << @reservation
|
||||||
@reservation = { 'groupSet' => [], 'instancesSet' => [] }
|
@reservation = { 'groupIds' => [], 'groupSet' => [], 'instancesSet' => [] }
|
||||||
end
|
end
|
||||||
when 'key', 'value'
|
when 'key', 'value'
|
||||||
@tag[name] = value
|
@tag[name] = value
|
||||||
|
|
Loading…
Reference in a new issue