From aa66911a4bb71ea12cdacbd918aa12184e5d2015 Mon Sep 17 00:00:00 2001 From: Paul Thornthwaite Date: Mon, 24 Dec 2012 03:41:55 +0000 Subject: [PATCH] [Brightbox] Adds #dns_name to server Little known fact is that the public version of the domain name of a Brightbox cloud server is the `fqdn` prefixed with public. This is now fixed here until it is fixed in the main API and the value can be referenced directly from the response. --- lib/fog/brightbox/models/compute/server.rb | 8 +++++++ .../brightbox/models/compute/server_tests.rb | 21 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 tests/brightbox/models/compute/server_tests.rb diff --git a/lib/fog/brightbox/models/compute/server.rb b/lib/fog/brightbox/models/compute/server.rb index 2c5177d048..3a4287ebe7 100644 --- a/lib/fog/brightbox/models/compute/server.rb +++ b/lib/fog/brightbox/models/compute/server.rb @@ -129,6 +129,14 @@ def image connection.images.get(image_id) end + # Returns the public DNS name of the server + # + # @return [String] + # + def dns_name + ["public", fqdn].join(".") + end + def private_ip_address unless interfaces.empty? interfaces.first["ipv4_address"] diff --git a/tests/brightbox/models/compute/server_tests.rb b/tests/brightbox/models/compute/server_tests.rb new file mode 100644 index 0000000000..3e2468e7b4 --- /dev/null +++ b/tests/brightbox/models/compute/server_tests.rb @@ -0,0 +1,21 @@ +Shindo.tests("Fog::Compute[:brightbox] | Server model", ["brightbox"]) do + + pending if Fog.mocking? + + tests("success") do + + unless Fog.mocking? + @server = Brightbox::Compute::TestSupport.get_test_server + server_id = @server.id + end + + tests("#dns_name") do + pending if Fog.mocking? + returns("public.#{@server.fqdn}") { @server.dns_name } + end + + unless Fog.mocking? + @server.destroy + end + end +end