1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/clodo/requests/compute/add_ip_address.rb
Paul Thornthwaite 2e0b7e545a Standardise empty lines throughout codebase
Done with `rubocop --auto-correct --only EmptyLineBetweenDefs,EmptyLines,EmptyLinesAroundBody`
2014-05-26 14:20:02 +01:00

47 lines
1.3 KiB
Ruby

module Fog
module Compute
class Clodo
class Real
# Bye new IP-address for specified server
# ==== Paramaters
# * server_id<~Integer> - Id of server to bye IP for
#
# ==== Returns
# * response<~Excon::Response>
#
def add_ip_address(server_id)
request(
:expects => [204],
:method => 'PUT',
:path => "servers/#{server_id}/ips"
)
end
end
class Mock
def add_ip_address(server_id)
raise Excon::Errors::BadRequest.new(
"Invalid image ID"
) unless server_id > 0
data = {
'primary_ip' => false,
'isp' => false,
'ip' => "66.6.#{rand(255)}.#{rand(255)}"
}
raise Excon::Errors::BadRequest unless self.data[:servers][server_id]
raise Excon::Errors::BadRequest.new "No addresses" unless self.data[:servers][server_id]['addresses']
self.data[:servers][server_id]['addresses']['public'] << data
response = Excon::Response.new
response.status = 204
response
end
end
end
end
end