2010-03-16 18:46:21 -04:00
|
|
|
module Fog
|
2011-06-16 19:28:54 -04:00
|
|
|
module Compute
|
|
|
|
class AWS
|
2010-03-16 18:46:21 -04:00
|
|
|
class Real
|
2009-09-11 23:47:32 -04:00
|
|
|
|
2011-08-24 21:37:00 -04:00
|
|
|
require 'fog/aws/parsers/compute/get_console_output'
|
2010-06-12 18:31:17 -04:00
|
|
|
|
2009-09-11 23:47:32 -04:00
|
|
|
# Retrieve console output for specified instance
|
|
|
|
#
|
|
|
|
# ==== Parameters
|
|
|
|
# * instance_id<~String> - Id of instance to get console output from
|
|
|
|
#
|
|
|
|
# ==== Returns
|
2009-11-02 21:48:49 -05:00
|
|
|
# # * response<~Excon::Response>:
|
2009-09-11 23:47:32 -04:00
|
|
|
# * body<~Hash>:
|
|
|
|
# * 'instanceId'<~String> - Id of instance
|
|
|
|
# * 'output'<~String> - Console output
|
|
|
|
# * 'requestId'<~String> - Id of request
|
|
|
|
# * 'timestamp'<~Time> - Timestamp of last update to output
|
2011-05-19 12:31:56 -04:00
|
|
|
#
|
|
|
|
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-GetConsoleOutput.html]
|
2009-09-11 23:47:32 -04:00
|
|
|
def get_console_output(instance_id)
|
2010-03-16 01:15:33 -04:00
|
|
|
request(
|
|
|
|
'Action' => 'GetConsoleOutput',
|
|
|
|
'InstanceId' => instance_id,
|
2010-05-24 17:22:35 -04:00
|
|
|
:idempotent => true,
|
2011-06-16 19:28:54 -04:00
|
|
|
:parser => Fog::Parsers::Compute::AWS::GetConsoleOutput.new
|
2010-03-16 01:15:33 -04:00
|
|
|
)
|
2009-09-11 23:47:32 -04:00
|
|
|
end
|
|
|
|
|
2009-07-24 22:25:55 -04:00
|
|
|
end
|
|
|
|
|
2010-03-16 18:46:21 -04:00
|
|
|
class Mock
|
2009-09-11 23:47:32 -04:00
|
|
|
|
|
|
|
def get_console_output(instance_id)
|
2009-11-20 14:08:08 -05:00
|
|
|
response = Excon::Response.new
|
2011-05-19 18:35:33 -04:00
|
|
|
if instance = self.data[:instances][instance_id]
|
2009-09-11 23:47:32 -04:00
|
|
|
response.status = 200
|
|
|
|
response.body = {
|
|
|
|
'instanceId' => instance_id,
|
2011-06-21 13:27:08 -04:00
|
|
|
'output' => (Time.now - instance['launchTime'] >= Fog::Mock.delay) ? nil : Fog::AWS::Mock.console_output,
|
2009-09-11 23:47:32 -04:00
|
|
|
'requestId' => Fog::AWS::Mock.request_id,
|
|
|
|
'timestamp' => Time.now
|
|
|
|
}
|
2010-05-26 01:26:20 -04:00
|
|
|
response
|
|
|
|
else;
|
2011-06-16 19:28:54 -04:00
|
|
|
raise Fog::Compute::AWS::NotFound.new("The instance ID '#{instance_id}' does not exist")
|
2009-09-11 23:47:32 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2009-07-24 22:25:55 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|