Skip to content

Commit

Permalink
Provide mocked console output if server has been up for over the dela…
Browse files Browse the repository at this point in the history
…y time.
  • Loading branch information
dylanegan committed Jun 21, 2011
1 parent ed35bba commit 28139f0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/fog/compute/requests/aws/get_console_output.rb
Expand Up @@ -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
}
Expand Down
7 changes: 6 additions & 1 deletion lib/fog/providers/aws.rb
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.