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

[Openstack|Compute] Minor address cleanup

This commit is contained in:
Hunter Nield 2012-02-24 11:37:35 +08:00 committed by Nelvin Driz
parent 9e95a13008
commit fd939faf6b
8 changed files with 43 additions and 26 deletions

View file

@ -9,6 +9,7 @@ module Fog
identity :id identity :id
attribute :ip attribute :ip
attribute :pool
attribute :fixed_ip attribute :fixed_ip
attribute :instance_id attribute :instance_id
@ -20,7 +21,6 @@ module Fog
def destroy def destroy
requires :id requires :id
connection.release_address(id) connection.release_address(id)
true true
end end

View file

@ -180,6 +180,16 @@ module Fog
connection.live_migrate_server(id, host, block_migration, disk_over_commit) connection.live_migrate_server(id, host, block_migration, disk_over_commit)
end end
def associate_address(floating_ip)
requires :id
connection.associate_address id, floating_ip
end
def disassociate_address(floating_ip)
requires :id
connection.disassociate_address id, floating_ip
end
def min_count=(new_min_count) def min_count=(new_min_count)
@min_count = new_min_count @min_count = new_min_count
end end

View file

@ -3,11 +3,11 @@ module Fog
class OpenStack class OpenStack
class Real class Real
def allocate_address def allocate_address(pool = nil)
request( request(
:body => nil, :body => MultiJson.encode({'pool' => pool}),
:expects => 200, :expects => [200, 202],
:method => 'POST', :method => 'POST',
:path => 'os-floating-ips.json' :path => 'os-floating-ips.json'
) )

View file

@ -4,15 +4,8 @@ module Fog
class Real class Real
def associate_address(server_id, ip_address) def associate_address(server_id, ip_address)
body = { 'addFloatingIp' => { 'server' => server_id, 'address' => ip_address }} body = { "addFloatingIp" => {"address" => ip_address}}
server_action(server_id, body)
request(
:body => MultiJson.encode(body),
:expects => 202,
:method => 'POST',
:path => "servers/#{server_id}/action.json"
)
end end
end end

View file

@ -4,17 +4,8 @@ module Fog
class Real class Real
def disassociate_address(server_id, ip_address) def disassociate_address(server_id, ip_address)
body = { "removeFloatingIp" => {"address" => ip_address}}
body = { 'removeFloatingIp' => { 'server' => server_id, 'address' => ip_address }} server_action(server_id, body)
request(
:body => MultiJson.encode(body),
:expects => 202,
:method => 'POST',
:path => "servers/#{server_id}/action.json"
)
end end
end end

View file

@ -0,0 +1,23 @@
module Fog
module Compute
class OpenStack
class Real
def list_address_pools
request(
:expects => [200, 203],
:method => 'GET',
:path => "os-floating-ip-pools"
)
end
end
class Mock
end
end
end
end

View file

@ -5,7 +5,7 @@ module Fog
def list_all_addresses(server_id) def list_all_addresses(server_id)
request( request(
:expects => 200, :expects => [200, 203],
:method => 'GET', :method => 'GET',
:path => "os-floating-ips.json" :path => "os-floating-ips.json"
) )

View file

@ -5,7 +5,7 @@ module Fog
def release_address(address_id) def release_address(address_id)
request( request(
:expects => 202, :expects => [200, 202],
:method => 'DELETE', :method => 'DELETE',
:path => "os-floating-ips/#{address_id}" :path => "os-floating-ips/#{address_id}"
) )