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/hp/requests/compute/allocate_address.rb

50 lines
1.3 KiB
Ruby
Raw Normal View History

module Fog
module Compute
class HP
class Real
# Acquires a floating IP address
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
# * 'floating_ip'<~Hash> -
# * 'id'<~Integer> - Id of the address
# * 'ip'<~String> - Floating IP of the address
# * 'instance_id'<~String> - Id of the associated server instance
# * 'fixed_ip'<~String> - Fixed IP of the address
def allocate_address
request(
:body => nil,
:expects => 200,
:method => 'POST',
:path => 'os-floating-ips.json'
)
end
end
class Mock
def allocate_address
response = Excon::Response.new
response.status = 200
data = {
'instance_id' => Fog::HP::Mock.instance_id.to_i,
'ip' => Fog::HP::Mock.ip_address,
'fixed_ip' => Fog::HP::Mock.ip_address,
'id' => Fog::Mock.random_numbers(3).to_i
}
self.data[:last_modified][:addresses][data['id']] = Time.now
self.data[:addresses][data['id']] = data
response.body = { 'floating_ip' => data }
response
end
end
end
end
end