From a80fa7c32a6a989c524be60884332d2aa06ff85a Mon Sep 17 00:00:00 2001 From: Paul Thornthwaite Date: Fri, 19 Oct 2012 09:26:21 +0100 Subject: [PATCH] [Brightbox] Reuses connection for image selection Fixes #1214 - Server initialisation failed unless you had a configuration file because it tried to create a second connection directly using the config details. We now get access to the 'connection' that exists and use that so it is already configured and authenticated. --- lib/fog/brightbox/compute.rb | 2 +- lib/fog/brightbox/models/compute/server.rb | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/fog/brightbox/compute.rb b/lib/fog/brightbox/compute.rb index b299c0b5f..3a6e56430 100644 --- a/lib/fog/brightbox/compute.rb +++ b/lib/fog/brightbox/compute.rb @@ -209,7 +209,7 @@ module Fog def select_default_image return @default_image_id unless @default_image_id.nil? - all_images = Fog::Compute[:brightbox].list_images + all_images = list_images official_images = all_images.select {|img| img["official"] == true} ubuntu_lts_images = official_images.select {|img| img["name"] =~ /Ubuntu.*LTS/} ubuntu_lts_i686_images = ubuntu_lts_images.select {|img| img["arch"] == "i686"} diff --git a/lib/fog/brightbox/models/compute/server.rb b/lib/fog/brightbox/models/compute/server.rb index c1e2e9549..70cfab2a5 100644 --- a/lib/fog/brightbox/models/compute/server.rb +++ b/lib/fog/brightbox/models/compute/server.rb @@ -38,8 +38,10 @@ module Fog attribute :server_type def initialize(attributes={}) - self.image_id ||= Fog::Compute[:brightbox].default_image + # Call super first to initialize the 'connection' object for our default image super + # FIXME connection is actually not + self.image_id ||= connection.default_image end def zone_id