From 27d4dc348a89b04651f826d49747d9602fe51152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Lindstr=C3=B6m?= Date: Tue, 12 Jun 2012 14:54:07 +0200 Subject: [PATCH] [glesys|compute] add reboot and compute test params This commit adds the reboot feature as well as updated get() call and compute test parameters to be able to run server tests --- lib/fog/glesys/compute.rb | 1 + lib/fog/glesys/models/compute/server.rb | 5 +++++ lib/fog/glesys/models/compute/servers.rb | 22 ++++++++++++++-------- lib/fog/glesys/requests/compute/reboot.rb | 14 ++++++++++++++ tests/compute/helper.rb | 4 ++++ 5 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 lib/fog/glesys/requests/compute/reboot.rb diff --git a/lib/fog/glesys/compute.rb b/lib/fog/glesys/compute.rb index 702d12c44..b2ec3e546 100644 --- a/lib/fog/glesys/compute.rb +++ b/lib/fog/glesys/compute.rb @@ -21,6 +21,7 @@ module Fog request :server_details request :server_status request :start + request :reboot request :stop # Templates request :template_list diff --git a/lib/fog/glesys/models/compute/server.rb b/lib/fog/glesys/models/compute/server.rb index 0c67f8996..78c84c995 100644 --- a/lib/fog/glesys/models/compute/server.rb +++ b/lib/fog/glesys/models/compute/server.rb @@ -40,6 +40,11 @@ module Fog connection.stop(:serverid => identity) end + def reboot + requires :identity + connection.reboot(:serverid => identity) + end + def destroy requires :identity connection.destroy(:serverid => identity, :keepip => keepip) diff --git a/lib/fog/glesys/models/compute/servers.rb b/lib/fog/glesys/models/compute/servers.rb index 1c431954c..a3280ad11 100644 --- a/lib/fog/glesys/models/compute/servers.rb +++ b/lib/fog/glesys/models/compute/servers.rb @@ -16,14 +16,20 @@ module Fog def get(identifier) return nil if identifier.nil? || identifier == "" - details = connection.server_details(identifier).body['response'] - status = connection.server_status(identifier).body['response'] - if details.empty? || status.empty? - nil - else - status['server'].merge!({ :serverid => identifier}) - details['server'].merge!(status['server']) - new(details['server']) + + begin + details = connection.server_details(identifier).body['response'] + status = connection.server_status(identifier).body['response'] + + if details.empty? || status.empty? + nil + else + status['server'].merge!({ :serverid => identifier}) + details['server'].merge!(status['server']) + new(details['server']) + end + rescue + return nil end end diff --git a/lib/fog/glesys/requests/compute/reboot.rb b/lib/fog/glesys/requests/compute/reboot.rb new file mode 100644 index 000000000..c3e3d69ec --- /dev/null +++ b/lib/fog/glesys/requests/compute/reboot.rb @@ -0,0 +1,14 @@ +module Fog + module Compute + class Glesys + class Real + + def reboot(param) + request("/server/reboot", param) + end + end + + end + end +end + diff --git a/tests/compute/helper.rb b/tests/compute/helper.rb index 6a23bd3c8..196229a91 100644 --- a/tests/compute/helper.rb +++ b/tests/compute/helper.rb @@ -44,6 +44,10 @@ def compute_providers :mocked => true }, :glesys => { + :server_attributes => { + :rootpassword => "secret_password_#{Time.now.to_i}", + :hostname => "fog.example#{Time.now.to_i}.com" + }, :mocked => false }, :hp => {