Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Provide mocked console output #367

Merged
merged 1 commit into from

2 participants

@dylanegan
Collaborator

Wanted some console output for our local application. Only providing if it the server has been up for greater than the delay. Not sure if that is the proper check or checking the instance state, although as far as I can tell the state is only updated through the same check.

@geemus geemus merged commit 570fc0a into from
@alanthing alanthing referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
2  lib/fog/compute/requests/aws/get_console_output.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
7 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
@@ -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
Something went wrong with that request. Please try again.