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

[brightbox] Make Cloud IP model's map nicer to use

* API accepts a load balancer or interface ID
* Model accepts a Server and figures out a suitable interface
This commit is contained in:
Paul Thornthwaite 2011-09-30 16:15:23 +01:00
parent 6fb4247c07
commit bea5bfe80a

View file

@ -23,9 +23,17 @@ module Fog
attribute :server_id, :aliases => "server", :squash => "id"
attribute :load_balancer, :alias => "load_balancer", :squash => "id"
def map(interface_to_map)
def map(destination)
requires :identity
connection.map_cloud_ip(identity, :interface => interface_to_map)
case destination
when Fog::Compute::Brightbox::Server
final_destination = destination.interfaces.first["id"]
when Fog::Compute::Brightbox::LoadBalancer
final_destination = destination.id
else
final_destination = destination
end
connection.map_cloud_ip(identity, :destination => final_destination)
end
def mapped?