From bea5bfe80a69f10cbe2d24b60275b399f38dae8d Mon Sep 17 00:00:00 2001 From: Paul Thornthwaite Date: Fri, 30 Sep 2011 16:15:23 +0100 Subject: [PATCH] [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 --- lib/fog/brightbox/models/compute/cloud_ip.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/fog/brightbox/models/compute/cloud_ip.rb b/lib/fog/brightbox/models/compute/cloud_ip.rb index 0636f1e19..dbcea802b 100644 --- a/lib/fog/brightbox/models/compute/cloud_ip.rb +++ b/lib/fog/brightbox/models/compute/cloud_ip.rb @@ -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?