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

ec2 - added support for associating public ip with vpc instance on launch

This commit is contained in:
Gabriel Rosendorf 2013-09-17 10:05:41 -04:00
parent 34a55f5da8
commit 5726d18167
4 changed files with 22 additions and 1 deletions

View file

@ -372,7 +372,7 @@ module Fog
@region = options[:region] ||= 'us-east-1'
@instrumentor = options[:instrumentor]
@instrumentor_name = options[:instrumentor_name] || 'fog.aws.compute'
@version = options[:version] || '2012-12-01'
@version = options[:version] || '2013-08-15'
if @endpoint = options[:endpoint]
endpoint = URI.parse(@endpoint)

View file

@ -12,6 +12,7 @@ module Fog
attr_accessor :architecture
attribute :ami_launch_index, :aliases => 'amiLaunchIndex'
attribute :associate_public_ip, :aliases => 'associatePublicIP'
attribute :availability_zone, :aliases => 'availabilityZone'
attribute :block_device_mapping, :aliases => 'blockDeviceMapping'
attribute :network_interfaces, :aliases => 'networkInterfaces'
@ -154,6 +155,7 @@ module Fog
'KernelId' => kernel_id,
'KeyName' => key_name,
'Monitoring.Enabled' => monitoring,
'NetworkInterface.n.AssociatePublicIpAddress' => associate_public_ip,
'Placement.AvailabilityZone' => availability_zone,
'Placement.GroupName' => placement_group,
'Placement.Tenancy' => tenancy,
@ -172,6 +174,22 @@ module Fog
# use of Security Group Ids when working in a VPC.
if subnet_id
options.delete('SecurityGroup')
if associate_public_ip
options['NetworkInterface.0.DeviceIndex'] = 0
options['NetworkInterface.0.AssociatePublicIpAddress'] = associate_public_ip
options['NetworkInterface.0.SubnetId'] = options['SubnetId']
options.delete('SubnetId')
grp_num = 0
if options['SecurityGroupId'].kind_of?(Array)
options['SecurityGroupId'].each {|id|
options["NetworkInterface.0.SecurityGroupId.#{grp_num}"] = id
grp_num += 1
}
else
options["NetworkInterface.0.SecurityGroupId.0"] = options['SecurityGroupId']
end
options.delete('SecurityGroupId')
end
else
options.delete('SubnetId')
end

View file

@ -74,6 +74,8 @@ module Fog
@response[name] = value
when 'ebsOptimized'
@instance['ebsOptimized'] = (value == 'true')
when 'associatePublicIP'
@instance['associatePublicIP'] = (value == 'true')
end
end

View file

@ -139,6 +139,7 @@ module Fog
instance_id = Fog::AWS::Mock.instance_id
instance = {
'amiLaunchIndex' => i,
'associatePublicIP' => options['associatePublicIP'] || false,
'architecture' => 'i386',
'blockDeviceMapping' => [],
'clientToken' => options['clientToken'],