From cf75fb1358cf2d64f5dd0a304afc7ea8d8603348 Mon Sep 17 00:00:00 2001 From: Jeff McCune Date: Tue, 30 Aug 2011 13:44:31 -0700 Subject: [PATCH] (#9241) Add current_time request Without this patch, no actual API calls are being made through the Fog layer to the underlying rbvmobi later and ultimately to the vSphere target API. This patch adds a simple current_time request which is similar to a "ping" The layers and API are exercised fully using this simple API call to retrieve the current time on the remote system. This provides: >> Fog::Compute[:vsphere].current_time Tue Aug 30 20:46:27 UTC 2011 >> Fog::Compute[:vsphere].requests [:current_time] --- lib/fog/vsphere/compute.rb | 3 +++ .../vsphere/requests/compute/current_time.rb | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 lib/fog/vsphere/requests/compute/current_time.rb diff --git a/lib/fog/vsphere/compute.rb b/lib/fog/vsphere/compute.rb index db2ffe239..133805842 100644 --- a/lib/fog/vsphere/compute.rb +++ b/lib/fog/vsphere/compute.rb @@ -8,6 +8,9 @@ module Fog recognizes :vsphere_port, :vsphere_path, :vsphere_ns recognizes :vsphere_rev, :vsphere_ssl, :vsphere_expected_pubkey_hash + request_path 'fog/vsphere/requests/compute' + request :current_time + class Mock def initialize(options={}) diff --git a/lib/fog/vsphere/requests/compute/current_time.rb b/lib/fog/vsphere/requests/compute/current_time.rb new file mode 100644 index 000000000..9e50bd989 --- /dev/null +++ b/lib/fog/vsphere/requests/compute/current_time.rb @@ -0,0 +1,21 @@ +module Fog + module Compute + class Vsphere + class Real + + def current_time + @connection.serviceInstance.CurrentTime + end + + end + + class Mock + + def current_time + Time.now.utc + end + + end + end + end +end