2013-12-13 15:21:18 -05:00
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class AWS
|
|
|
|
class Real
|
|
|
|
|
|
|
|
require 'fog/aws/parsers/compute/assign_private_ip_addresses'
|
|
|
|
|
|
|
|
# Assigns one or more secondary private IP addresses to the specified network interface.
|
|
|
|
#
|
|
|
|
# ==== Parameters
|
2013-12-17 15:40:05 -05:00
|
|
|
# * NetworkInterfaceId<~String> - The ID of the network interface
|
|
|
|
# * PrivateIpAddresses<~Array> - One or more IP addresses to be assigned as a secondary private IP address (conditional)
|
|
|
|
# * SecondaryPrivateIpAddressCount<~String> - The number of secondary IP addresses to assign (conditional)
|
|
|
|
# * AllowReassignment<~Boolean> - Whether to reassign an IP address
|
2013-12-13 15:21:18 -05:00
|
|
|
# ==== Returns
|
|
|
|
# * response<~Excon::Response>:
|
|
|
|
# * body<~Hash>:
|
|
|
|
# * 'requestId'<~String> - The ID of the request.
|
|
|
|
# * 'return'<~Boolean> - success?
|
|
|
|
#
|
|
|
|
# {Amazon API Reference}[http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-AssignPrivateIpAddresses.html]
|
2013-12-17 15:40:05 -05:00
|
|
|
def assign_private_ip_addresses(network_interface_id, options={})
|
|
|
|
|
|
|
|
if options['PrivateIpAddresses'] && options['SecondaryPrivateIpAddressCount']
|
|
|
|
raise Fog::Compute::AWS::Error.new("You may specify secondaryPrivateIpAddressCount or specific secondary private IP addresses, but not both.")
|
|
|
|
end
|
|
|
|
|
|
|
|
if private_ip_address = options.delete('PrivateIpAddresses')
|
|
|
|
options.merge!(Fog::AWS.indexed_param('PrivateIpAddress.%d', [*private_ip_addresses]))
|
|
|
|
end
|
|
|
|
|
|
|
|
request({
|
2013-12-13 15:21:18 -05:00
|
|
|
'Action' => 'AssignPrivateIpAddresses',
|
|
|
|
'NetworkInterfaceId' => network_interface_id,
|
|
|
|
:parser => Fog::Parsers::Compute::AWS::AssignPrivateIpAddresses.new
|
2013-12-17 15:40:05 -05:00
|
|
|
}.merge(options))
|
2013-12-13 15:21:18 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
class Mock
|
|
|
|
|
2013-12-17 15:40:05 -05:00
|
|
|
def assign_private_ip_addresses(network_interface_id, options={})
|
|
|
|
if options['PrivateIpAddresses'] && options['SecondaryPrivateIpAddressCount']
|
2013-12-17 14:12:43 -05:00
|
|
|
raise Fog::Compute::AWS::Error.new("You may specify secondaryPrivateIpAddressCount or specific secondary private IP addresses, but not both.")
|
2013-12-17 12:49:01 -05:00
|
|
|
end
|
2013-12-17 15:40:05 -05:00
|
|
|
|
|
|
|
response = Excon::Response.new
|
|
|
|
response.status = 200
|
|
|
|
response.body = {
|
|
|
|
'requestId' => Fog::AWS::Mock.request_id,
|
|
|
|
'return' => true
|
|
|
|
}
|
|
|
|
response
|
2013-12-13 15:21:18 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|