Permalink
Browse files

Provide mocked console output if server has been up for over the dela…

…y time.
  • Loading branch information...
1 parent ed35bba commit 28139f0c94915b7e11ef117b509315ceda0f0655 @dylanegan dylanegan committed Jun 21, 2011
Showing with 7 additions and 2 deletions.
  1. +1 −1 lib/fog/compute/requests/aws/get_console_output.rb
  2. +6 −1 lib/fog/providers/aws.rb
@@ -38,7 +38,7 @@ def get_console_output(instance_id)
response.status = 200
response.body = {
'instanceId' => instance_id,
- 'output' => nil,
+ 'output' => (Time.now - instance['launchTime'] >= Fog::Mock.delay) ? nil : Fog::AWS::Mock.console_output,
'requestId' => Fog::AWS::Mock.request_id,
'timestamp' => Time.now
}
View
@@ -1,6 +1,7 @@
require 'fog/core'
require 'fog/core/parser'
require 'openssl' # For RSA key pairs
+require 'base64' # For console output
module Fog
module AWS
@@ -78,6 +79,11 @@ def self.box_usage
sprintf("%0.10f", rand / 100).to_f
end
+ def self.console_output
+ # "[ 0.000000] Linux version 2.6.18-xenU-ec2-v1.2 (root@domU-12-31-39-07-51-82) (gcc version 4.1.2 20070626 (Red Hat 4.1.2-13)) #2 SMP Wed Aug 19 09:04:38 EDT 2009"
+ Base64.decode64("WyAwLjAwMDAwMF0gTGludXggdmVyc2lvbiAyLjYuMTgteGVuVS1lYzItdjEu\nMiAocm9vdEBkb21VLTEyLTMxLTM5LTA3LTUxLTgyKSAoZ2NjIHZlcnNpb24g\nNC4xLjIgMjAwNzA2MjYgKFJlZCBIYXQgNC4xLjItMTMpKSAjMiBTTVAgV2Vk\nIEF1ZyAxOSAwOTowNDozOCBFRFQgMjAwOQ==\n")
+ end
+
def self.dns_name_for(ip_address)
"ec2-#{ip_address.gsub('.','-')}.compute-1.amazonaws.com"
end
@@ -173,7 +179,6 @@ def self.snapshot_id
def self.volume_id
"vol-#{Fog::Mock.random_hex(8)}"
end
-
end
end
end

0 comments on commit 28139f0

Please sign in to comment.