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:
parent
9e95a13008
commit
fd939faf6b
8 changed files with 43 additions and 26 deletions
|
@ -9,6 +9,7 @@ module Fog
|
|||
identity :id
|
||||
|
||||
attribute :ip
|
||||
attribute :pool
|
||||
attribute :fixed_ip
|
||||
attribute :instance_id
|
||||
|
||||
|
@ -20,7 +21,6 @@ module Fog
|
|||
|
||||
def destroy
|
||||
requires :id
|
||||
|
||||
connection.release_address(id)
|
||||
true
|
||||
end
|
||||
|
|
|
@ -180,6 +180,16 @@ module Fog
|
|||
connection.live_migrate_server(id, host, block_migration, disk_over_commit)
|
||||
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)
|
||||
@min_count = new_min_count
|
||||
end
|
||||
|
|
|
@ -3,11 +3,11 @@ module Fog
|
|||
class OpenStack
|
||||
class Real
|
||||
|
||||
def allocate_address
|
||||
def allocate_address(pool = nil)
|
||||
|
||||
request(
|
||||
:body => nil,
|
||||
:expects => 200,
|
||||
:body => MultiJson.encode({'pool' => pool}),
|
||||
:expects => [200, 202],
|
||||
:method => 'POST',
|
||||
:path => 'os-floating-ips.json'
|
||||
)
|
||||
|
|
|
@ -4,15 +4,8 @@ module Fog
|
|||
class Real
|
||||
|
||||
def associate_address(server_id, ip_address)
|
||||
body = { 'addFloatingIp' => { 'server' => server_id, 'address' => ip_address }}
|
||||
|
||||
request(
|
||||
:body => MultiJson.encode(body),
|
||||
:expects => 202,
|
||||
:method => 'POST',
|
||||
:path => "servers/#{server_id}/action.json"
|
||||
)
|
||||
|
||||
body = { "addFloatingIp" => {"address" => ip_address}}
|
||||
server_action(server_id, body)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -4,17 +4,8 @@ module Fog
|
|||
class Real
|
||||
|
||||
def disassociate_address(server_id, ip_address)
|
||||
|
||||
body = { 'removeFloatingIp' => { 'server' => server_id, 'address' => ip_address }}
|
||||
|
||||
request(
|
||||
:body => MultiJson.encode(body),
|
||||
:expects => 202,
|
||||
:method => 'POST',
|
||||
:path => "servers/#{server_id}/action.json"
|
||||
)
|
||||
|
||||
|
||||
body = { "removeFloatingIp" => {"address" => ip_address}}
|
||||
server_action(server_id, body)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
23
lib/fog/openstack/requests/compute/list_address_pools.rb
Normal file
23
lib/fog/openstack/requests/compute/list_address_pools.rb
Normal 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
|
|
@ -5,7 +5,7 @@ module Fog
|
|||
|
||||
def list_all_addresses(server_id)
|
||||
request(
|
||||
:expects => 200,
|
||||
:expects => [200, 203],
|
||||
:method => 'GET',
|
||||
:path => "os-floating-ips.json"
|
||||
)
|
||||
|
|
|
@ -5,7 +5,7 @@ module Fog
|
|||
|
||||
def release_address(address_id)
|
||||
request(
|
||||
:expects => 202,
|
||||
:expects => [200, 202],
|
||||
:method => 'DELETE',
|
||||
:path => "os-floating-ips/#{address_id}"
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue