mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[Brightbox] Add CloudIp#destination_id
Abstraction over the number of possible mapped targets to consistently access the identifier.
This commit is contained in:
parent
86b235e72f
commit
3d0c439cb2
2 changed files with 36 additions and 0 deletions
|
@ -56,6 +56,10 @@ module Fog
|
|||
service.destroy_cloud_ip(identity)
|
||||
end
|
||||
|
||||
def destination_id
|
||||
server_id || load_balancer || server_group || interface_id
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
32
tests/brightbox/models/compute/cloud_ip_tests.rb
Normal file
32
tests/brightbox/models/compute/cloud_ip_tests.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
Shindo.tests("Fog::Compute[:brightbox] | CloudIp model", ["brightbox"]) do
|
||||
pending if Fog.mocking?
|
||||
|
||||
@test_service = Fog::Compute[:brightbox]
|
||||
|
||||
tests("success") do
|
||||
@server = Brightbox::Compute::TestSupport.get_test_server
|
||||
server_id = @server.id
|
||||
|
||||
@cip = @test_service.cloud_ips.allocate
|
||||
|
||||
tests("#destination_id") do
|
||||
returns(true) do
|
||||
@cip.respond_to?(:destination_id)
|
||||
end
|
||||
|
||||
@cip.map(@server)
|
||||
@cip.wait_for { mapped? }
|
||||
|
||||
returns(server_id) do
|
||||
@cip.destination_id
|
||||
end
|
||||
|
||||
@cip.unmap
|
||||
@cip.wait_for { !mapped? }
|
||||
end
|
||||
|
||||
@cip.destroy
|
||||
|
||||
@server.destroy
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue